Thanks.. i solved it like this
defparam DRAWONLASTBARONLY = true
mintimeFrame = 9
if GetTimeFrame/60 >= minTimeFrame then
maxCheck = 50
i = 0
lastOuterBar = -1
lastLow = low[maxcheck]
lastHigh = high[maxcheck]
for i = maxCheck-1 downto 0
if open[i] >= lastHigh or open[i] =< lastLow or close[i] >= lastHigh or close[i] =< lastLow then
lastLow = low[i]
lastHigh = high[i]
lastOuterBar = i
endif
next
if lastOuterBar > 0 then
x1 = barindex
y1 = high[lastOuterBar] //high[barindex+1]
x2 = barindex-lastOuterBar
y2 = low[lastOuterBar]//low[barindex+1]
DRAWRECTANGLE(x1, y1, x2,y2) coloured(255,155,0)FILLCOLOR(255,255,230)
endif
endif
RETURN
1 user thanked author for this post.