Series Data is delayed in plotting the previous day OHLC info in Tradingview

Viewed 104

Can someone suggest why does the series data is delayed in plotting. I am looking at plotting yesterday High and Low of the day and open of the current day on the chart. This is getting plotted after 1 day later. Line is plotted correctly only when I use lookahead = barmerge.lookahead_on. Is it mandatory to have parameter "lookahead = barmerge.lookahead_on " enabled?

//@version=4
study("SeriesData","SRD",overlay=true)
linew = input(title="Line Width",type = input.integer, defval=2,minval=1,maxval=5)

getSeriesData(val_,tf_,offset_)=>
    VAL = security(syminfo.tickerid, tf_, val_[offset_])

    //VAL = security(syminfo.tickerid, tf_, val_[offset_], lookahead =  barmerge.lookahead_on)

d_op  = getSeriesData(open,'D',0)          //current day open
pd_hi = getSeriesData(high,'D',1)           // Previous Day High
pd_lo = getSeriesData(low,'D',1)           // Previous Day Low
pd_cl = getSeriesData(close,'D',1)           //Previous Day Close


plot(d_op,color=color.silver,style=plot.style_circles,linewidth=linew, display = display.all)
plot(pd_hi,color=color.red,style=plot.style_circles,linewidth=linew, display = display.all)
plot(pd_lo,color=color.lime,style=plot.style_circles,linewidth=linew, display = display.all)
1 Answers

For me the plot is correct. The red and green dots are showing yesterday's high and low, as you wanted. And the yellow/grey shows today's open.

enter image description here

Related