Hello Nicolas,
thanks first of all for sharing the ADR calculation code.
I am trying to utilise it for my intraday trading in the 2 min TF. I am basically plotting the ADR targets from current day’s low and high.
The problem is that these levels are not correctly showing and calculating in real-time. The ADR calculation that I am printing is also wrong during real time.
In order to make this work, I need every time to manually touch the indicator settings to sort of “reset” the plot during the live market.
Here’s the code I am using: (please find it also attached)
Do you have any idea how to adjust it?
thank you very much in advance again
defparam drawonlastbaronly = true
sum = 0
if day<>day[1] then
$drange[lastset($drange)+1]=dhigh(1)-dlow(1)
if lastset($drange)>=PERIODS then
for i = lastset($drange) downto lastset($drange)-PERIODS do
sum = sum+$drange[i]
next
ADR = sum/PERIODS
endif
endif
hi = dhigh(0)
lo = dlow(0)
bull50 = lo + (ADR * 0.5)
bull75 = lo + (ADR * 0.75)
bull100 = lo + ADR
bear50 = hi – (ADR * 0.5)
bear75 = hi – (ADR * 0.75)
bear100 = hi – ADR
if barindex > 0 then
DRAWTEXT(“dHI”,barindex+3,hi,SansSerif,Bold,10) COLOURED (0,0,0)
DRAWTEXT(“ADR: #ADR#”,barindex+10,hi,SansSerif,Bold,10) COLOURED (0,0,0)
DRAWTEXT(“dLO”,barindex+3,lo,SansSerif,Bold,10) COLOURED (0,0,0)
DRAWTEXT(“d50”,barindex+3,bear50,SansSerif,Bold,10) COLOURED (255,0,0)
DRAWTEXT(“d75”,barindex+3,bear75,SansSerif,Bold,10) COLOURED (255,0,0)
DRAWTEXT(“d100”,barindex+3,bear100,SansSerif,Bold,10) COLOURED (255,0,0)
DRAWTEXT(“d50”,barindex+3,bull50,SansSerif,Bold,10) COLOURED(62,154,72)
DRAWTEXT(“d75”,barindex+3,bull75,SansSerif,Bold,10) COLOURED(62,154,72)
DRAWTEXT(“d100”,barindex+3,bull100,SansSerif,Bold,10) COLOURED(62,154,72)
endif
return