Linear Regression Trend
Linear Regression Trend is a quantitative trend-following strategy for trending markets on daily bars.
Linear Regression Trend is a quantitative trend-following strategy for trending markets on daily bars. Rather than reading a moving-average crossover or a price level, it fits an ordinary least-squares regression line through the last 20 closes and follows the sign of its slope: long while the best-fit line rises (LRSLOPE(20) > 0), flat when it turns down (LRSLOPE(20) < 0). It is the statistically-grounded cousin of SMA Crossover — both detect trend direction, but this one uses every bar in the window through a regression fit instead of comparing two averages, which suppresses single-bar noise at the cost of a slight lag.
It is a medium, trending, daily strategy for trend trading.
How it trades
The regression slope answers a precise question: if you draw the single straight line that best fits the last 20 closes (minimising squared error), is it pointing up or down, and how steeply? The slope is in price units per bar — a slope of +2 means the fitted line gains 2 points per day across the window.
| Ingredient | Meaning |
|---|---|
| LRSLOPE(20) | Slope of the least-squares line through the last 20 closes; sign is trend direction |
Buy (regression line rising):
LRSLOPE(20) > 0
Sell (regression exit — line turns down):
LRSLOPE(20) < 0
Because every bar in the window contributes to the fit, a single sharp spike or dip barely moves the slope — it takes a genuine shift in the window's overall drift to flip the sign. That is what makes this a cleaner, less whippy trend read than a two-point momentum slope, and why the exit is simply the mirror of the entry: the trend is either mathematically up or mathematically down.
When it works best
Best on established names that hold sustained, multi-month directional runs, where the regression slope stays firmly on one side of zero and the strategy rides the whole leg. Its stated weakness is slight lag: the windowed fit confirms a turn a few bars late, giving back some of the top and entering some way into a new up-leg. In choppy, sideways markets the slope oscillates around zero and the sign flips repeatedly, producing whipsaw round-trips — a longer period or a slope-magnitude threshold (only act when the slope is meaningfully non-zero) are the natural hardenings.
Backtest this strategy yourself
Build these rules on the Free plan, adjust them, and see how they would have traded.