my expectation in the code below is that the "max_bars_back" will limit the history used for the indicator to 500 bars, but this seems to not work as intended. Do anyone have a suggestion for how this could be fixed?
//@version=4
study("Green Bars Count", max_bars_back = 500)
var count = 0
isGreen = close >= open
if isGreen
count := count + 1
plot(count)
The max_bars_back is for making sure that it knows how far back to look when it is unable to determine how far. I don't completely understand it as I haven't had issues with it for a while. From what I remember you should only use it if you're running into errors regarding the referencing length of a series.
// © bajaco
//@version=4
study("Green Count")
limit = input(title='Count limit', type=input.integer, defval=500)
green = close > open
score = green ? 1 : 0
green_count = sum(score,limit)
plot(green_count)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With