DRAWRECTANGLE

Category: Graphical

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.

Syntax:

DRAWRECTANGLE(x1, y1, x2, y2) COLOURED(R, G, B, a)

Where:

  • x1, y1 – The x and y coordinates of the first corner of the rectangle.
  • x2, y2 – The x and y coordinates of the opposite corner of the rectangle.
  • COLOURED(R, G, B, a) – Optional. Specifies the color of the rectangle using RGB color codes and an alpha (transparency) value. Each component (R, G, B, and a) should be an integer between 0 and 255.

Example Usage:

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.

Additional Information:

  • The function can be used to visually mark consolidation zones, breakout areas, or patterns like chart candlestick formations.
  • Understanding the coordinates system (x1, y1, x2, y2) is crucial as it determines the position and size of the rectangle.
  • The optional color parameters allow for better visualization and can be adjusted to match the chart theme or highlight specific features.

Using DRAWRECTANGLE effectively can enhance chart analysis and help in identifying key trading areas or patterns visually.

Logo Logo
Loading...