DRAWLINE

Category: Graphical

The DRAWLINE function in ProBuilder language is used to draw a line on a chart between two specified points. This function is particularly useful for visualizing relationships or trends between data points on financial charts. The line can be optionally colored to enhance visibility and differentiation from other chart elements.

Syntax:

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

Where x1 and y1 are the coordinates of the first point, and x2 and y2 are the coordinates of the second point. The COLOURED function is optional and specifies the color of the line using RGB (Red, Green, Blue) values and an alpha (a) value for transparency.

Example 1: Drawing Fibonacci Pivot Points

defparam drawonlastbaronly = true
dh = DHigh(1)
dl = DLow(1)
P = (dh + dl + DClose(1)) / 3
S1 = P - .382 * (dh - dl)
S2 = P - .618 * (dh - dl)
S3 = P - 1 * (dh - dl)
R1 = P + .382 * (dh - dl)
R2 = P + .618 * (dh - dl)
R3 = P + 1 * (dh - dl)
Voffset = 5 * pipsize
DRAWLINE(barindex-1, P, barindex, P) coloured(153, 153, 0)
DRAWLINE(barindex-1, R1, barindex, R1) coloured(0, 153, 0)
DRAWLINE(barindex-1, R2, barindex, R2) coloured(0, 153, 0)
DRAWLINE(barindex-1, R3, barindex, R3) coloured(0, 153, 0)
DRAWLINE(barindex-1, S1, barindex, S1) coloured(153, 0, 0)
DRAWLINE(barindex-1, S2, barindex, S2) coloured(153, 0, 0)
DRAWLINE(barindex-1, S3, barindex, S3) coloured(153, 0, 0)

This example calculates Fibonacci pivot points and draws horizontal lines at these levels on the last bar of the chart. The lines are colored differently to distinguish between support and resistance levels.

Example 2: Connecting Two Recent Lows

defparam drawonlastbaronly = true
period = 20
y2 = lowest[period](low)
for i = 0 to period do
    if low[i] = y2 then
        x2 = barindex[i]
    elsif low[i] < y2 then
        y1 = low[i]
        x1 = barindex[i]
    endif
next
DRAWLINE(x1, y1, x2, y2)

This example finds the two most recent lowest points within a specified period and draws a line connecting these points. This can be useful for identifying support levels or trends in price movements.

Using the DRAWLINE function can significantly aid in the visual analysis of charts by highlighting key data points, trends, or levels of interest such as support and resistance in trading charts.

Related Instructions:

  • DRAWHLINE graphical
  • DRAWSEGMENT graphical
  • DRAWVLINE graphical
  • Logo Logo
    Loading...