Reputation: 133
I am trying to plot Previous Day High and Low crossovers. It does fine when the price crosses during the day. However if the opening bar of the day is Higher than previous day it misses it out. Where am I going wrong?
Also on Daily TF ,how can we keep getting latest Daily OHLC various as day progress, as I see the Daily is getting calculated only on closed candles..ie next day.
my code
D1_High = security(syminfo.tickerid, 'D', high)
D1_Low = security(syminfo.tickerid, 'D', low)
PDH = crossover(high, D1_High)
PDL = crossunder(low, D1_Low)
Upvotes: 1
Views: 2377
Reputation: 136
study("Cross of previousday High Low", overlay = true)
//define previous day high & Low
h = security(syminfo.tickerid,'D',high[1], lookahead= true)
l = security(syminfo.tickerid,'D',low[1],lookahead= true)
//plot previous day Hi/lo
plot(h,color=color.blue)
plot(l,color= color.blue)
//create condition
pdhc = crossover(close,h)
pdlc = crossunder(close,l)
//plot condition
plotshape(pdhc,style=shape.triangleup, location = location.belowbar, color = color.green)
plotshape(pdlc,style=shape.triangledown, location = location.abovebar, color= color.red)
Upvotes: 1