Relative Content

Tag Archive for pine-scriptpine-script-v5

Quadratic regression for Pine

Is there a way to create a quadratic regression in Pine that is reasonably simple?
I only need the result of the quadratic regression over the last X days (e.g. 20 days) so that I can create a continuous indicator.

Error: Index is out of bound in array.get function

I am trying to find the regression line with the largest value using a loop.
The regression line is calculated over several periods and then the period i with the highest value is to be output so that it can be used in the further calculation.
For example, if the regression line of the last 15 days is the highest, then 15 should be output.

Streaks/runs in pine

I’m trying to code it so that if the close is greater than the close yesterday, that counts as a streak of 1. If the next close is > yesterday then the streak continues on as 2 etc etc.
If the close is lower than yesterday however, the streak starts at -1, then if the close is lower than the close yesterday again, its now -2 etc etc
If the close is the same as the close yesterday the streak is 0

show lines only for today

I would like these lines only show just for today and doesn’t extend backward. I tried like in this post and plenty others, nothing works.
I’m not good at this so maybe I did it wrong or something. Please help.
Here is the script

How do I get these divergence labels to plot in pinescript

The below code is trying to print divergence labels based on price and a volume flow indicator. Currently no labels are plotting and I am unsure why. The logic of this looks correct. I would like to print a label when the close is greater than the highest price of the lookback period and when the current VFI reading is less than what the VFI reading was when price was highest.

label not aligning to the line

I’m a novice to pine script who need some help figuring this puzzle out.
The text is not showing in the horizontal line. I tried label.style_label_center and other lot of stuff, but nothing seems to work. Any help would be appreciated. Thank you!