StratBase.aiStratBase.ai
DashboardCreate BacktestMy BacktestsCatalogBlogNewsToolsHelp

Products

  • Researcher Dashboard
  • Create Backtest
  • My Backtests
  • Catalog
  • Blog
  • News

Alerts

  • Calendar
  • OI Screener
  • Funding Rate
  • REKT
  • Pump/Dump

Company

  • About Us
  • Pricing
  • Affiliate
  • AI Widget
  • Contact

Legal

  • Privacy
  • Terms
  • Refund Policy

Support

  • Help Center
  • Reviews
StratBase.aiStratBase.ai

Think it. Test it.

StratBase.ai does not provide financial advice or trading recommendations. AI only formalizes user ideas into testable strategy configurations for research purposes. Past backtesting performance does not guarantee future results. All trading decisions and associated risks are the sole responsibility of the user. This platform is not a broker and does not facilitate real trading.

© 2026 StratBase.ai · AI-powered strategy research and backtesting platform

support@stratbase.ai
Help Center/Indicators/Linear Regression

Linear Regression

📈Indicators
📌

Linear Regression

📋

What is Linear Regression?

The Linear Regression indicator fits a least-squares straight line through the last N closing prices and returns the endpoint value of that line. It projects where the trend "should" be based on the statistical best fit, effectively acting as a forward-looking moving average.

⚙️

How it works

LinReg(N) = a + b × N
where b = (N × Sum(i×Close_i) - Sum(i) × Sum(Close_i)) / (N × Sum(i^2) - Sum(i)^2)
      a = (Sum(Close_i) - b × Sum(i)) / N

The indicator outputs the regression value at the current bar (the right edge of the window).

⭐

Key features

  • Predictive element — unlike MA which averages past data, LinReg extends the best-fit line to the current point.
  • Less lag — tends to lead price during steady trends because the slope projects forward.
  • Slope = trend strength — steep positive slope means strong uptrend, steep negative means strong downtrend.
📌

Trading signals

Trend direction

  • LinReg rising — uptrend.
  • LinReg falling — downtrend.

Price vs. LinReg

  • Price above LinReg — price is outperforming the statistical trend (bullish momentum).
  • Price below LinReg — price is underperforming (bearish momentum or reversion expected).
📌

Parameters

| Parameter | Default | Description | |-----------|---------|-------------| | Period | 14 | Number of bars for the regression calculation |

💡

Example conditions

| Condition | Meaning | |-----------|---------| | close > LINEARREG(14) | Price above regression line — bullish | | close cross_over LINEARREG(20) | Price reclaims regression — potential reversal | | LINEARREG(14) > LINEARREG(50) | Short-term trend steeper than long-term — momentum building |

📌

Interpreting the Slope

The slope of the regression line (coefficient b) tells you the trend speed:

| Slope | Interpretation | |-------|---------------| | Steep positive | Strong uptrend — price gaining fast | | Gentle positive | Moderate uptrend — steady climb | | Near zero | No trend — consolidation or range | | Gentle negative | Moderate downtrend — gradual decline | | Steep negative | Strong downtrend — price falling fast |

A change in slope direction often precedes a change in price direction, making LinReg a leading signal.

📌

Regression Channel Strategy

Combine LinReg with standard deviation bands to create a regression channel:

  • Upper band = LinReg + 2 × StdDev(N) — overbought zone
  • Lower band = LinReg - 2 × StdDev(N) — oversold zone
  • Enter long when price touches lower band and slope is positive
  • Enter short when price touches upper band and slope is negative

This creates a powerful mean-reversion setup that adapts to the current trend direction.

💡

Tips

  • LinReg works well for mean-reversion strategies — if price deviates far from LinReg, expect a pullback.
  • Combine with standard deviation bands around LinReg for a regression channel.
  • Short periods (5-14) are popular for intraday; longer (20-50) for swing.
  • LinReg is especially useful on assets with steady trends (indices, blue-chip stocks).
Related Resources|Fibonacci CalculatorPivot Points CalculatorTrading Blog