Logistic Regression
A statistical classifier that estimates the probability of a binary outcome (e.g., price up or down) from multiple input features.
Overview
Logistic Regression is a supervised machine learning algorithm that predicts the probability of a binary outcome — in trading, typically the probability that price will be higher or lower after N bars. It takes multiple input features (technical indicators, fundamental metrics, macro data) and learns linear decision boundaries between outcome classes. The output is a probability between 0 and 1, which can be thresholded to generate long/short signals.
How it looks on a chart
Illustration only — synthetic data generated for visual reference.
While most technical indicators tell you what price has been doing, Logistic Regression tries to predict what price is likely to do next — specifically, whether it is more likely to go up or down. It does this by looking at many indicators at once and learning which combinations have historically preceded up or down moves. The model produces a probability. A reading of 0.75 means the model estimates a 75% chance the asset will be higher after the forecast horizon. A reading of 0.25 means a 75% chance it will be lower. By setting a threshold (e.g., go long when probability > 0.60), you can turn these probabilities into actionable signals. The key advantage over single indicators is that logistic regression can combine the information from many signals simultaneously — RSI, MACD, volume, and volatility indicators can all feed in at once. The model learns which combination of these has the most predictive power.
Logistic Regression models the log-odds of a binary outcome as a linear function of inputs: log(p/(1-p)) = β₀ + β₁X₁ + β₂X₂ + ... + βₙXₙ. The sigmoid function converts this linear combination into a probability: p = 1 / (1 + e^(-z)). Coefficients are estimated by maximizing the likelihood of the observed outcomes. For trading signals, typical features include: RSI, MACD histogram, ATR percentile, volume ratio, linear regression slope, and calendar effects. The target variable is usually a binary label: 1 if returns over the next N bars are positive, 0 if negative. Cross-validation and walk-forward testing are essential to prevent overfitting. Regularization is critical: L1 regularization (Lasso) drives irrelevant feature coefficients to zero, automatically selecting the most predictive features. L2 regularization (Ridge) shrinks all coefficients, reducing variance. The regularization parameter C (inverse of strength) must be tuned using time-series cross-validation, not random k-fold, to prevent look-ahead bias.
Logistic Regression's interpretability is a key advantage in finance: coefficient signs and magnitudes can be directly inspected to understand which features drive the model's predictions. This aligns with regulatory requirements for model explainability in institutional settings (e.g., MiFID II model risk management). A well-documented pitfall in financial ML applications is the use of expanding windows: as the model is retrained on progressively longer historical data, earlier data points are consistently included, giving them implicit higher weight. Sliding window retraining (fixed n months of data) is more conservative and often produces more stable signals. In terms of predictive power, logistic regression on technical indicators typically achieves accuracy slightly above 50% for daily direction prediction — low in absolute terms but potentially sufficient for profitable trading given sufficient sample size and good cost management. The Kelly criterion applied to these calibrated probabilities can size positions optimally: f = p - (1-p)/odds.
Formula
p = 1 / (1 + e^(−(β₀ + β₁X₁ + β₂X₂ + ... + βₙXₙ))) Log-odds: log(p / (1-p)) = β₀ + Σ(βᵢXᵢ)
- 1.Prepare feature matrix X: technical indicators (RSI, MACD, ATR, etc.) and binary label y (1=up, 0=down).
- 2.Apply time-series split for cross-validation (never random split).
- 3.Fit logistic regression with L1 or L2 regularization using maximum likelihood estimation.
- 4.Output probability p = sigmoid(β₀ + Σβᵢxᵢ) for each new bar.
- 5.Apply threshold (e.g., p > 0.55 → long, p < 0.45 → short, else flat) to generate signals.
Parameters
| Parameter | Default | Range | Description |
|---|---|---|---|
| Feature Window | 20 | 5–60 | Lookback window for computing input features. |
| Forecast Horizon | 5 | 1–20 | Number of bars ahead for the binary prediction target. |
| Regularization | 1 | 0.01–100 | Inverse regularization strength C (lower = stronger regularization). |
Trading signals
bullish: Model probability > 0.60
High confidence upside prediction — consider long entry with appropriate sizing.
bearish: Model probability < 0.40
High confidence downside prediction — consider short entry or exit long.
neutral: Model probability between 0.45 and 0.55
Low confidence prediction — no trade; wait for higher-probability setup.
Limitations
- •Assumes linear separability between classes — cannot capture non-linear feature interactions.
- •Requires sufficient historical data to train; sparse data leads to poor coefficient estimates.
- •Model must be periodically retrained as market regimes shift; static models degrade over time.
- •Feature engineering and selection significantly impacts performance — arbitrary feature sets can lead to overfitting.
Gilito trains rolling logistic regression models on each asset using a 12-month training window that advances forward monthly. Features include the full suite of technical indicators available in its library. Model predictions are used as one input in the ensemble strategy selection layer alongside gradient boosted trees and LSTM outputs.