Hello, i have a piece of code that i have assembled/Frankensteined, it works well on hourly and above, but when i swap down to lower timeframes something odd happens,
the problem is with the drawing the lines and rectangle, when i move to a smaller timeframe they either dont draw, or the vertical axis is way out?
I apologize for the messy code, i am no professional
defparam drawonlastbaronly=true
ATRperiod = 20
dTR = 0
for i = 0 to ATRperiod
dTR=dTR+max(abs(Dhigh(i)-Dlow(i)),max(abs(Dhigh(i)-Dclose(i+1)),abs(Dlow(i)-Dclose(i+1))))
next
avg = dTR/ATRperiod
converted = round(avg/pointsize*10)/10
//TimeRange = ( Time < 130100 AND Time > 135959 )
IF time = 150000 THEN
begin=BarIndex
daysopen = close
else
//backwards = barindex-begin
//daysopen = close[backwards]
ENDIF
//bindex = IntradayBarIndex
bindex = BarIndex
IF bindex-begin < 1 THEN
Ddhigh = highest[1](high)
Ddlow = lowest[1](low)
daysopen = close[1]
ELSE
bsince = (bindex-(begin))
Ddhigh = highest[bsince](high)
Ddlow = lowest[bsince](low)
daysopen = close[bsince]
ENDIF
//Ddhigh = highest[bsince](high)
htr = Ddlow+avg[1]
ltr = Ddhigh-avg[1]
bhtr = daysopen+(.3*avg[1])
bltr = daysopen-(.3*avg[1])
//just for calculation of text
bounce = (.3*avg[1])
drawsegment(begin,htr,bindex,htr) coloured(200,100,0)
drawtext("#htr# - (D1atr: #converted#)",bindex,htr+10*pointsize,Dialog,Bold,10) coloured(200,100,0)
drawsegment(begin,ltr,bindex,ltr) coloured(200,100,0)
drawtext("#ltr# - (D1atr: #converted#)",bindex,ltr-10*pointsize,Dialog,Bold,10) coloured(200,100,0)
drawsegment(begin,bhtr,bindex,bhtr) coloured(255,255,0)
drawtext("#bhtr# - (Short openers area: #bounce#)",bindex,bhtr+10*pointsize,Dialog,Bold,15) coloured(200,200,0)
// DRAWRECTANGLE (x1, y1, x2, y2) COLOURED (R, V, B, a)
DRAWRECTANGLE (begin, daysopen+bounce, bindex, daysopen) coloured(150,150,150)
//just to see if BLTR had anumber on smaller tf drawtext("#bltr# - (Long openers area: -#bounce#)",bindex,ddhigh-10*pointsize,Dialog,Bold,15) coloured(200,200,0)
drawsegment(begin,bltr,bindex,bltr) coloured(255,255,0)
drawtext("#bltr# - (Long openers area: -#bounce#)",bindex,bltr-10*pointsize,Dialog,Bold,15) coloured(200,200,0)
drawsegment(begin,daysopen,bindex,daysopen) coloured(0,0,255)
drawsegment(begin,ddhigh,bindex,ddhigh) coloured(0,50,0)
drawsegment(begin,ddlow,bindex,ddlow) coloured(0,50,0)
return