//@version=4
study(title="Marker", shorttitle="Marker ", overlay=true)
// *get Q,W,M,D ohlc
f() => [open,high,low,close]
[o,h,l,c] = security(syminfo.tickerid, "D", f())
highv = security(syminfo.tickerid, "D", high)
if(barstate.islast)
var id = label.new(bar_index, h[1], style=label.style_none,
text= " -> " +" :"+ tostring (h[0]) +" High level Value", color=color.green )
label.set_textcolor(id, color.green)
var nid =label.new(bar_index, highv[1]+10, style=label.style_none,
text= "highv -> " +" :"+ tostring (highv[0]) +" :Highv Value", color=color.green )
label.set_textcolor(nid, color.green)
Here is simple code, which prints Daily High Value. The value shown is correct when on Daily time frame. But as soon the resolution in the tradingview window changes to Weekly or Monthly the h[0] or highv[0] value changes to different value.
Is it expected? Please help.
Pinescript does not support accessing to intrabar values (from higher time frames to lower ones). You should do the opposite - open Daily chart and load higher timeframe data with security function.