regressionTrend
This tool draws a regression line between two points and creates a statistical “best fit” channel. It helps you see the average direction of price and whether candles are trading above or below the trend.
Syntax
regressionTrend(fromPoint, toPoint, styles?)
Parameters
fromPoint: First anchor (use
time). Defines where the regression starts.toPoint: Second anchor. Defines where the regression ends.
styles (optional) Customize the channel:
linestyle(number) – Defines the style of the regression line (0 = solid, 1 = dotted, 2 = dashed).linewidth(number) – Sets the thickness of the regression line.precision(string) – Controls how many decimal places are displayed.styles.baseLine(BandsStyles) – Style for the main regression line (color, width, and style).styles.upLine(BandsStyles) – Style for the upper deviation line.styles.downLine(BandsStyles) – Style for the lower deviation line.styles.extendLines(boolean) – If true, the regression line extends beyond the selected points.styles.showPearsons(boolean) – Displays or hides Pearson’s correlation coefficient on the chart.styles.transparency(number, 0–100) – Sets the transparency (0 = visible, 100 = invisible).
Return Value
string — Unique drawing
id.
Example
This script plots a regression trend every 50 candles, starting from 30 candles ago up to the current one.
In this example:
linestyle is set to solid, but you can try
1(dotted) or2(dashed).linewidth is
2for better visibility.precision ensures values are shown with two decimals.
baseLine / upLine / downLine each have their own colors and thickness.
extendLines lets the regression continue past your anchor points.
showPearsons displays the correlation value, which is helpful to confirm how “strong” the trend is.
transparency makes the drawing slightly lighter so it doesn’t dominate the chart.
Result

Tips
Perfect for checking if price is moving smoothly in a trend or drifting away from its average.
Watch how price reacts to the upper and lower bands — they often act as dynamic support/resistance.
Warning
If your points are too close (like only 2–3 candles apart), the regression won’t be meaningful.
Too many regression channels at once can overlap and cause confusion.
Last updated