Logistic Regression from Scratch with Leakage-Aware Evaluation
Summary
The article builds a binary logistic regression classifier in native MQL5 using a sigmoid probability, binary cross-entropy, and stochastic gradient descent. Its example predicts whether the next bar will close higher, using five features derived from indicators and price changes. Features are standardized, and the scaler is fitted only on training rows before being applied to held-out data, reducing look-ahead leakage. The walkthrough also describes shuffling examples by epoch and reporting accuracy, a baseline, a confusion matrix, and row-level predictions.
The article reports only a faint edge on euro data and worse-than-baseline performance on gold. These results come from one broker’s history over one period per symbol, so they need reproduction on other data. The author stresses that directional accuracy does not measure profitability, since it says nothing about the relative size of winning and losing moves. The model is linear in its inputs and uses deliberately basic features; the article is primarily an educational implementation and evaluation example, not a trading system or profit claim.
Key ideas
- Logistic regression maps a weighted sum of standardized inputs to a probability with the sigmoid function.
- Stochastic gradient descent updates weights using the prediction error and each feature value.
- Fit the scaler on training data only, then apply its fixed statistics to held-out observations.
- The example predicts next-bar direction using five basic indicator and price-derived features.
- Reported results vary by instrument and period, and accuracy alone does not establish profitability.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.