DRAWTRIANGLE

Category: Graphical

The DRAWTRIANGLE function in ProBuilder language is used to draw a triangle on a chart using three sets of x and y coordinates. This function can be particularly useful for visualizing specific patterns or marking certain areas on a chart based on calculated conditions.

Syntax:

DRAWTRIANGLE(x1, y1, x2, y2, x3, y3) COLOURED(R, G, B, a)

The COLOURED part is optional and is used to define the color and transparency of the triangle. R, G, and B represent the red, green, and blue components of the color, respectively, and ‘a’ represents the alpha (transparency) value.

Example:

Here is a simple example to demonstrate how to use the DRAWTRIANGLE function:

defparam drawonlastbaronly = true
period = 20
hh = highest[period](high)
ll = lowest[period](low)
for i = 1 to period
    if high[i] = hh then
        x1 = barindex[i]
    endif
    if low[i] = ll then
        x2 = barindex[i]
    endif
next
DRAWTRIANGLE(x1, hh, x2, ll, barindex, low) COLOURED(200, 120, 120, 255)
RETURN

In this example, the script first determines the highest and lowest points within a specified period on the chart. It then uses these points as vertices to draw a triangle. The triangle is colored with an RGB value of (200, 120, 120) and full opacity (255).

Additional Information:

  • The x1, y1, x2, y2, x3, y3 parameters in the DRAWTRIANGLE function represent the coordinates of the three vertices of the triangle.
  • The function can be used in combination with loops and conditional statements to dynamically place triangles based on real-time data.
  • Setting the defparam drawonlastbaronly to true ensures that the drawing is updated only on the last bar, making the script more efficient.

This function is a powerful tool for traders and analysts who want to highlight specific patterns or signals directly on the chart for better visualization and analysis.

Logo Logo
Loading...