Reputation: 583
I'm trying to counter a weird problem (bug?) in Pine. I want to get the offset to the bar of the lowest value because I need to know both offset and value so i can draw a line.
bool mwIsAnchorBot = mw < -60
int mwBarsSinceAnchBot = int(min(5000, barssince(mwIsAnchorBot)))
int loLowestBarsSinceAnchBot = lowestbars(low, max(1, mwBarsSinceAnchBot))
This returns a study error
Invalid value of the 'length' argument (0.0) in the lowest bar function. It must be > 0
How is this possible? I have set a minimal value of 1 and a maximum value of 5000? And why is it received as float? (0.0)? I never ever declared a float and explicitly declare integers and booleans.
Thanks in advance
Upvotes: 0
Views: 351
Reputation: 583
In case someone stumbles on this question, I found out that barssince returns na
if the condition was not found.
To avoid my problem I had to wrap nz
around it:
int(min(5000, nz(barssince(mwIsAnchorBot))))
Upvotes: 1