DRAWVLINE is a function in the ProBuilder language used to draw a vertical line on a chart at a specified bar index. This function is particularly useful for highlighting specific points in time on a trading chart, such as the highest or lowest price within a given period.
DRAWVLINE(x1) COLOURED(R, V, B, a)
The DRAWVLINE function requires one parameter, x1, which specifies the bar index where the vertical line should be drawn. The COLOURED function is optional and allows you to specify the color of the line using RGB (Red, Green, Blue) values and an optional alpha (a) for transparency.
defparam drawonlastbaronly = true
period = 15
Yhh = highest[period](high)
Yll = lowest[period](low)
FOR i = 0 to period do
if high[i] = Yhh then
Xhh = barindex[i]
endif
if low[i] = Yll then
Xll = barindex[i]
endif
NEXT
DRAWVLINE(Xhh) COLOURED(0, 200, 0)
DRAWVLINE(Xll) COLOURED(200, 0, 0)
RETURN
In this example, the script first determines the highest and lowest prices over a specified period (15 bars). It then identifies the bar indices where these extreme values occur. Vertical lines are drawn at these indices: a green line at the highest price and a red line at the lowest price.
defparam drawonlastbaronly = true setting ensures that the drawing is updated only on the last bar to keep the chart clean.FOR loop iterates through each bar in the specified period to find the exact bars where the highest and lowest prices occur.DRAWVLINE function is used within the loop to place vertical lines at these points.This function is useful for traders and analysts who want to visually mark significant events or prices on a chart to aid in technical analysis without manually drawing lines each time.