Hi, i’m using the draw rectangle code but i want to use this on different time frames that run through the 00:00 time
eg 173000 – 060000
when i set this the rectangle does not draw.
is there a way to do this?
thanks
period = 20
boxheight = 0.0020
hh = highest[period](high)
ll = lowest[period](low)
if hh-ll <= boxheight then
for i = 0 to period do
if high[i]=hh then
x2 = barindex[i]
endif
if low[i]=ll then
x1 = barindex[i]
endif
next
if ABS(x2-x1) >= period then
DRAWRECTANGLE(x1,ll,x2,hh)coloured(255,10,10)
endif
endif
RETURN
That code doesn’t use any time conditions to calculate and to plot. It only relies on period (bars quantity). So it should work at any time.
My guess would be that it has something to do with the boxheight (highest high – lowest low) needing to be <= 0.002 or the fact that line 15 expects the length of the box to be >= period which I am guessing is very unlikely.
That code is good for me, it plots boxes only if the range is less or equal to 20 pips and if they have been formed for at least X periods.
… but you are finding the highest high and lowest low in the last 20 bars and then if they are have a difference of less than or equal to 20 pips then line 15 has a condition that only lets you draw a rectangle if the HH and LL are 20 or more bars apart. Surely this condition is very rarely going to be hit as they cannot be over 20 bars apart as that is your look back period to find them within! So in reality we are looking for a HH and LL less than 20 pips in difference where the HH and LL are exactly 20 bars apart.