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)