Systemicbeta

Linear Regression Predictor

systemic:core-lrpMachine learning

Inputs

NameTypeDescription
History Window SizeWhole numberThe number of bars in a row that the model looks at to predict the next bar.
Predictions countWhole numberHow many bars ahead each forecast looks.
Feature MatrixSeveral number seriesA matrix with one row per bar and one column per feature, used to train the linear regression model.

Outputs

NameTypeDescription
Predicted valuesNumber seriesThe forecast of the target made on each bar, using only data from that bar and earlier.
Model ScoreNumber seriesThe coefficient of determination (R²): how well the linear model fits its training data.

Cost

38
credits per run
1,000
bars

0.194 + 0.0209·n + 0.0000162·n² credits for n bars, rounded up. The marks are each plan's limit of bars.

At a Glance

y^=β0+β1x1+β2x2+⋯+βnxn\hat{y} = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \cdots + \beta_n x_n

Linear Regression Predictor is a machine learning module. It fits a linear model to historical data and forecasts future values. Most indicators describe past behavior. LRP is a predictive tool: it tries to extend trends into the future with a statistical model.


The Mathematics of Linear Regression

Core Concept

Linear regression finds the "best-fit" line (or plane, with several features) through the data points. It minimizes the sum of squared errors between predicted and actual values:

min⁡β∑i=1n(yi−y^i)2=min⁡β∑i=1n(yi−(β0+∑j=1pβjxij))2\min_{\beta} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2 = \min_{\beta} \sum_{i=1}^{n} \left( y_i - (\beta_0 + \sum_{j=1}^{p} \beta_j x_{ij}) \right)^2

The solution gives the coefficients β\beta that define the linear relationship between the features and the target.

The Prediction Process

flowchart TD
    A[Feature Matrix] --> B[Create Sliding Windows]
    B --> C[Train Linear Model]
    C --> D[Compute Coefficients β]
    D --> E[Predict Future Values]
    E --> F[Output: Predictions + R² Score]

R² Score: Model Quality

The module outputs an R² score (coefficient of determination). It measures how well the linear model explains the variance in the data it was trained on:

R2=1−∑(yi−y^i)2∑(yi−yˉ)2R^2 = 1 - \frac{\sum (y_i - \hat{y}_i)^2}{\sum (y_i - \bar{y})^2}
R² ValueInterpretation
1.0Perfect fit—model explains all variance
0.7 - 0.9Strong fit—good predictive power
0.4 - 0.7Moderate fit—some predictive value
< 0.4Weak fit—limited predictive reliability

How LRP Works in Systemic

Input Structure

LRP takes a feature matrix: several series that may influence the target. For example:

  • Price data from several correlated assets
  • Technical indicators (RSI, MACD values)
  • Volume data alongside price

The module:

  1. Creates sliding windows of historical data
  2. Trains a linear regression model on these windows
  3. Uses the trained model to forecast the target N bars ahead (N = Predictions count)

Window-Based Learning

The History Window Size sets how many bars in a row the model sees at once. Each training example is that many bars, used to predict the target on the next bar. A larger window can capture longer patterns, but it needs more history and can overfit.


Practical Applications

1. Short-Term Price Forecasting

Use LRP to project where an asset's price might be in the next few bars. This is useful for:

  • Setting profit targets
  • Anticipating resistance/support levels
  • Planning entry/exit timing

Caveat: Financial markets are very hard to predict. Linear models work best when trends are stable and the relationships are linear.

2. Feature Importance Analysis

Try different combinations of features to see which ones have the strongest linear relationship with your target. This guides further research and strategy design.

3. Trend Extrapolation

Combined with trend-following indicators, LRP can project where a trend might lead if current conditions continue. This is useful for scenario planning.


Important Considerations

Linearity Assumption

Linear regression assumes that relationships are linear. Financial markets often show:

  • Non-linear dynamics
  • Regime changes
  • Sudden volatility shifts

LRP works best in stable, trending conditions. Combine it with other tools that detect regime changes.

Overfitting Risk

With too many features or too little history, the model may "memorize" past patterns that do not hold on new data. Watch the R² score: if it is near 1.0 but the predictions fail, overfitting is likely.

Prediction Horizon

Short-term predictions (1-3 bars ahead) are generally more reliable than long-term forecasts. The further ahead you predict, the more the uncertainty grows.


Data Alignment in Systemic

LRP takes a Feature Matrix: one input with a row per bar and a column per feature. The first column is the prediction target. A missing cell (closed market, no data yet) stays empty. LRP never fills it.

Multi-Input Alignment

The series are aligned by time when the matrix is built, before LRP runs. A bar where a series has no value is an empty cell in that series' column.

Parameter Behavior

  • Predictions count: A constant integer. It sets how many bars ahead each forecast looks. The forecast is built one step at a time: each step uses the forecast of the step before, and the other features keep their latest values. predictions on a bar uses only data from that bar and earlier.
  • History Window Size: A constant integer. It is the number of bars in a row (bars with data) in each training example and in the input of each forecast.

Missing Data

predictions and score are computed only from bars with data (rows with no empty cell). The calculation never looks past the current bar:

  • The model for a bar is trained on all bars with data before it. Each training example is window bars in a row, used to predict the target on the next bar. The forecast starts from the last window bars with data, up to and including the current bar. A bar with a missing cell (e.g. a weekend on a business-day series) is skipped, so the model sees the trading days one after another.
  • An output is empty when the bar itself has a missing cell, when there is too little history (the first window + 2 bars with data), or when the fit's R² is not a finite number.

Indicator Profile

This chart compares how useful LRP is for stocks and for cryptocurrencies:

quadrantChart
    title LRP Indicator Profile
    x-axis Low Popularity --> High Popularity
    y-axis Low Reliability --> High Reliability
    quadrant-1 High potential  
    quadrant-2 Established leaders
    quadrant-3 Niche tools
    quadrant-4 Popular but risky
    LRP - Stocks: [0.35, 0.50]
    LRP - Crypto: [0.40, 0.40]

Dimension Ratings

DimensionStocksCryptoNotes
Popularity3.5/104.0/10Linear regression is well-known but rarely used for direct price prediction in professional settings. More popular in crypto retail trading.
Reliability5.0/104.0/10Moderate in stable trending markets; poor during volatility. Crypto's non-linear dynamics reduce reliability.
Complexity4.0/104.0/10Relatively simple math but requires understanding of feature selection, windows, and overfitting.
Versatility6.5/106.0/10Applicable to any numerical time series. More useful for trend extrapolation than precise forecasting.
Recent Interest5.0/105.5/10Renewed interest due to ML/AI hype. Crypto traders experiment more with predictive models.

References and Further Reading


Glossary

TermDefinition
Feature MatrixSeveral input series, one per column, used to train the model
Coefficients (β)Weights learned by the model for each feature
R² ScoreMeasure of how well the model fits the data (0 to 1, higher is better)
Prediction HorizonHow many bars ahead the forecast looks
History WindowNumber of bars in a row in each training example
OverfittingWhen a model learns noise rather than signal

This documentation is for educational purposes only and is not investment advice. Predictions are uncertain. Always validate them with other methods.

Rendering diagrams...
© 2026 WanoLabs. All rights reservedBeta v0.1.5