horizontalLine
Draws a flat line across the chart at a specific price level. Traders usually use it to mark support, resistance, or key levels like round numbers (e.g., 1.2000 in Forex).
Syntax
horizontalLine(time, price, styles?, text?)
Parameters
time The candle time where the line begins. You can use
time(0)for the current candle.price The price level where the line will be placed (e.g.,
closeC(0)or100).styles (optional) Customize how the line looks:
linecolor: color of the line (e.g.color.red)linewidth: thickness of the linelinestyle: solid, dashed, dotted, etc.showLabel: true/false to display the labeltextcolor: color of the label text
text (optional) A short label to display next to the line (if
showLabel: true).
Return Value
string — The unique
idof the drawing.
Example
This example draws one red horizontal line at the current closing price every 30 candles, labeled “Key Level.”
Result

Tips
Use horizontal lines to highlight support/resistance zones.
Try dashed lines (
linestyle: 2) for less important levels, and solid for key levels.
Warning
If you forget to include
price, nothing will be drawn.If you pass
textbut don’t setshowLabel: true, the label won’t appear.
Last updated