The DRAWRECTANGLE function in ProBuilder language is used to visually represent a rectangle on a trading chart. This function is particularly useful for highlighting specific areas on the chart, such as price ranges, time periods, or patterns. The rectangle can be customized with optional color settings.
DRAWRECTANGLE(x1, y1, x2, y2) COLOURED(R, G, B, a)
Where:
This example demonstrates how to draw a rectangle on a chart to highlight a specific price range over a given period:
period = 20
boxheight = 20
hh = highest[period](high)
ll = lowest[period](low)
if hh - ll <= boxheight * pointsize 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
In this example, a rectangle is drawn if the highest high and the lowest low within a specified period (20 bars) are within a defined height (20 points). The rectangle is colored red with full opacity.
Using DRAWRECTANGLE effectively can enhance chart analysis and help in identifying key trading areas or patterns visually.