horizontalRay

Draws a flat line that begins at the candle you choose and extends to the right into the future. This is very useful for marking support or resistance levels so you can see how price reacts when it comes back later.

Syntax

horizontalRay(time, price, styles?, text?)

Parameters

  • time: The candle time where the ray starts (for example, time(10) means the line starts from 10 candles ago).

  • price: The price level where the line is drawn (like low(10) or closeC(0)).

  • styles (optional) How the line looks:

    • linecolor: line color (e.g., color.green)

    • linewidth: thickness

    • linestyle: solid, dashed, dotted

    • showLabel: show the text label if you pass text

    • textcolor: color for the label text

  • text (optional): A short label you want to show on the line.

Return Value

  • string — A unique drawing id.

Example

Here we draw a green horizontal ray at the low price from 15 candles ago, and we only do it every 25 candles to keep the chart clean.

Result

Tips

  • Great for projecting old swing highs/lows forward in time.

  • Use different colors for support (green) and resistance (red) for clarity.

Warning

Good Practice

Last updated