Skip to content
All library documents

Causal Trend-Scanning Features and Leakage Risks in Machine Learning

Article MQL5 articles

Summary

The article adapts a trend-scanning label method into a feature interface for machine-learning models. For each bar, it fits price against time across candidate window lengths and retains the window with the largest absolute slope t-statistic, along with slope and R-squared. A causal feature wrapper fixes the backward-looking mode and returns only window, slope, t-value, and R-squared, preventing callers from accidentally using future data or label-related outputs as inputs.

It checks the backward indexing by comparing matching spans from forward and backward runs, and reports that the statistics agree at floating-point precision on synthetic data. The article also identifies a signed-input problem: the default log transform clips values below a small positive floor, collapsing negative observations. Simulations are used to study leakage and this transformation defect. The article further cautions that maximizing raw absolute t-values across window lengths does not select the most statistically significant trend, and that conventional Student-t thresholds are not directly applicable to price data. These findings concern implementation and statistical interpretation; the text does not establish predictive profitability.

Key ideas

  • Trend-scanning fits linear trends across candidate window lengths and keeps the fit with the largest absolute slope t-value.
  • A feature must use a backward-looking window ending at the current bar to avoid future information.
  • A dedicated wrapper can prevent accidental use of the forward-looking labeling mode and remove outcome columns.
  • The default log transform can distort signed input series by clipping negative values to a positive floor.
  • Selecting the largest absolute t-value across window lengths does not identify the most significant trend under nominal Student-t thresholds.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.