The request.security function doesn't seem to be working. I am on a daily time frame trying to request monthly closes. It works about half of the time, the other half it returns the same value as the previous value. Even get the error using the code straight from the documentation.
newMonth = ta.change(time("M"))
indexHighTF = barstate.isrealtime ? 1 : 0
indexCurrTF = barstate.isrealtime ? 0 : 1
nonRepaintingClose = request.security(syminfo.tickerid, "1M", close[indexHighTF])[indexCurrTF]
if newMonth
label.new(bar_index, high, str.tostring(nonRepaintingClose, format.mintick), color = color.aqua)
You can use the security()
with lookahead=barmerge.lookahead_on
and add one bar delay in your expression.
nonRepaintingClose = request.security(syminfo.tickerid, "1M", close[1], lookahead=barmerge.lookahead_on)