DRAWHLINE
DRAWHLINE in ProBuilder draws a horizontal line across the chart at a given price, with an optional COLOURED colour and transparency. Syntax and examples.
Syntax
DRAWHLINE(y1) COLOURED(R, G, B, a)Parameters
| Name | Type | Default | Description |
|---|---|---|---|
y1 | price | required | The price level at which the horizontal line is drawn. |
R, G, B | integer | platform default | Optional COLOURED red, green and blue components, 0 to 255. |
a | integer | 255 | Optional alpha (transparency), 0 fully transparent to 255 fully opaque. |
How it works
DRAWHLINE runs inside a ProBuilder indicator. It draws a single horizontal line that spans the visible chart at the price y1. Only a y coordinate is needed, since a horizontal line has no start or end bar. This makes it convenient for marking levels such as a recent high, a recent low, or a fixed threshold.
The optional COLOURED clause sets the colour and transparency. Because the line covers the whole chart width, drawing it once is enough, so scripts commonly set DEFPARAM DrawOnLastBarOnly = true to avoid redrawing it on every historical bar.
Examples
Example 1, Highest and lowest of the last 15 bars (Indicator)
// Draw the recent high in green and the recent low in red
DEFPARAM DrawOnLastBarOnly = true
hh = Highest[15](high)
ll = Lowest[15](low)
DRAWHLINE(hh) COLOURED(0, 200, 0)
DRAWHLINE(ll) COLOURED(200, 0, 0)
RETURNTwo horizontal lines mark the top and bottom of the recent range.
Example 2, A fixed round-number level (Indicator)
// A grey reference line at a fixed price
DEFPARAM DrawOnLastBarOnly = true
level = 15000
DRAWHLINE(level) COLOURED(128, 128, 128, 180)
RETURNA single line marks a static price of interest, at partial opacity so it sits behind the bars.
Example 3, Session open marker with a label (Indicator)
// Horizontal line at the current open, annotated with text
DEFPARAM DrawOnLastBarOnly = true
DRAWHLINE(open) COLOURED(0, 100, 255)
DRAWTEXT("open", BarIndex, open) COLOURED(0, 100, 255)
RETURNDRAWHLINE sets the level and DRAWTEXT names it.
Common errors and gotchas
- Indicator only.
DRAWHLINEhas no effect in ProScreener, ProOrder or ProBacktest. Keep it in a ProBuilder indicator. - One argument only. It takes a single price
y1. For a line between two arbitrary points useDRAWLINEorDRAWSEGMENT. - Redraw cost. Without
DrawOnLastBarOnly = true, the line is redrawn on every bar. Set it once at the top of the script. - Vertical counterpart. For a vertical marker at a bar index, use
DRAWVLINEinstead.
Related instructions
DRAWVLINE, a vertical line at one bar index, the counterpart of this instruction.DRAWLINE, a line between two arbitrary points.DRAWSEGMENT, a segment between two points.COLOURED, sets colour and transparency.DrawOnLastBarOnly, restricts drawing to the last bar for performance.Highest, supplies a recent high to mark.Lowest, supplies a recent low to mark.DRAWTEXT, labels the level with text.
