I’m creating an indicator for 1D and lower timeframes, but need to get the closing price of the higher timeframes (weekly candles or monthly candles).
When I need to get the highest closing price of the last 52 weekly candles (not counting the current week’s candles), I currently only know how to do the following:
var float[] W_closes = array.new_float(52, na)
array.set(W_closes, 0, request.security(syminfo.tickerid, 'W', close[1]))
array.set(W_closes, 1, request.security(syminfo.tickerid, 'W', close[2]))
array.set(W_closes, 2, request.security(syminfo.tickerid, 'W', close[3]))
...
array.set(W_closes, 50, request.security(syminfo.tickerid, 'W', close[51]))
array.set(W_closes, 51, request.security(syminfo.tickerid, 'W', close[52]))
max_W_close = array.max(array.slice(W_closes, 0, 52))
However, Tradingview only allows a maximum of 40 request.security in one script. I also can’t include request.security in the for loop (Tradingview doesn’t allow this). Please tell me how to get the highest closing price of the last 52 weekly candlesticks, thank you very much.