rayLine
Draw a line that starts at one point and keeps going to the right. Use it to project a level or trend into the future (for example, a line that begins at a pivot and extends forward). You can style the line and (optionally) show a short label. The function gives you an id so you can update or delete it later.
Syntax
rayLine(fromPoint, toPoint, styles?, text?)
Parameters
fromPoint
{ time, price }Point where the ray begins. Build it withnewPoint(time, price). If you passtextand want to see it, setstyles.showLabel = true.toPoint
{ time, price }A second point that sets the ray’s direction (the ray goes through this point and continues to the right).styles (optional) Look & feel for the line. Common fields include:
linecolor,linewidth,linestyle,extendLeft,extendRight,showLabel,textcolor, etc. Colors can be named (likecolor.blue) or RGBA viacolor.rgba(r,g,b,a). SeeBasicLineToolOverridesand the color helpers.text
string(optional) Short label attached at the start point. Setstyles.showLabel = trueto display it.
Helper you’ll use
newPoint(time, price) → returns a
{ time, price }point.
Return Value
string — Unique drawing
id. Use it withupdateDrawingById(id, data)ordeleteDrawingById(id).
Example
//@version=1
init = () => {
// Configure the indicator:
// - format: 'inherit' → use the chart’s format (price, decimals, etc.)
indicator({ onMainPanel: true, format: 'inherit' });
};
onTick = () => {
// --- Condition to control when to draw ---
// index is the bar counter. We check "index % 100 === 0":
// → Only every 100th bar will trigger the drawing.
if (index % 100 === 0) {
// time(10), low(10) = 10 bars ago → starting point of the ray (older pivot).
const start = newPoint(time(10), low(10));
// time(0), low(0) = current bar’s low → end point, where the ray passes through.
const end = newPoint(time(0), low(0));
// --- Draw the ray line ---
// Style options:
// - linecolor: red (taken from color set:contentReference[oaicite:1]{index=1})
// - linewidth: 2 → thicker line
// - showLabel: true → display a text label on the chart
// Label: "Support Ray"
rayLine(
start,
end,
{ linecolor: color.red, linewidth: 2, showLabel: true },
'Support Ray'
);
}
};
This draws one tidy ray and simply moves it as new candles arrive—no clutter. rayLine takes two points; the line begins at the first and extends right through the second.
Result

Tips
Use a meaningful start like a swing high/low to make the projection intuitive.
Prefer named colors (
color.blue,color.red) for consistency; switch tocolor.rgba(...)only when you need transparency.Save the returned
idand update it each tick to avoid stacking many drawings. UseupdateDrawingById.
Warning
If
fromPointortoPointis missingtimeorprice, the ray won’t be created (points must be valid).Passing
textwithoutstyles.showLabel = truewill hide the label.
Last updated