I'm getting Nan's / na when I try to iterate the candles what am I doing wrong? Also it's giving me the wrong values for high and low?
Notice SPY is @ 398 but the screen shot shows 440
` //@version=5 indicator("TriangleWaves", "TriangleWaves", true)
// Input options
_candleLen = input(40, "Default Candle Length")
_calcDefLen = input(true, "Auto Calculate Candle Length")
float _cHi=na
float _cLow=na
_counter = 0
_debugText=""
while _counter < _candleLen
if _counter == 0
_cHi := high
_cLow := low
else
_cHi := high[_counter]
_cLow := low[_counter]
if _counter <= 1
_debugText:=_debugText + "\n Candle " + str.tostring(_counter) + " _cHi " + str.tostring(_cHi) + " _cLow " + str.tostring(_cLow)
_counter := _counter+1
runtime.error(_debugText)
if barstate.islast
myLabel = label.new(x=bar_index + 3, y=close, color=color.blue, textcolor=color.white, style=label.style_label_up, size=size.large)
myLabel.set_text(_debugText)`
`
I expected the high and low of the candlesticks.