HI
am looking for help on regards the DRAWRECTANGLE function
Would like to paint a rectangle between two prices. e.g. 1 and 2.
and the width of the rectangle should be from OPEN to CLose (or 5 bars into the future)
Somehow I cant get this managed with Barindex and co,
Can someone help me ?
A rectangle is plotted according to two coordinates:
- price (from price 1 to price 2)
- bars (from bar 1 to bar 2), which can also be in the future, if you like.
The line width is specified by a numeric constant, not a price:
DEFPARAM DrawOnLastBarOnly = True
ONCE Price1 = 0
ONCE Price2 = 0
ONCE Bar1 = 0
ONCE Bar2 = 0
IF (Time >= 090000) AND (Time <= 210000) THEN
IF Time = 090000 THEN
Price1 = open
Bar1 = BarIndex
ENDIF
Price2 = close
Bar2 = BarIndex
ENDIF
IF Price1 <> 0 THEN
DrawRectangle(Bar1,Price1,Bar2,Price2) coloured("Grey",25) BorderColor("Fuchsia",255) style(Line,3)
ENDIF
RETURN
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