Causal Trend-Scanning Features: Incremental Computation and Significance Limits
Summary
This article ports causal trend-scanning features to MQL5 and replaces repeated window summation with three running statistics per horizon. Once each horizon is initialized, its sums update in constant work per bar, reducing the computation described from O(H·L) to O(H). A parity harness executes transformed header text and compares results with a Python reference, reporting close agreement across five parameter sets, with wider tolerance for t-values near perfectly linear windows because the fitted standard error approaches zero.
The port also exposes a sign defect in the reference library’s backward mode: reversing input and then output order leaves slope and t-value signs inverted. The article explains the correction to the prior wrapper and reports that its no-leak conclusion is unaffected. It further cautions that the candidate-window selection rule does not identify the most significant trend and that reported t-values on price data should not be judged by nominal Student-t thresholds. The default zero volatility threshold simplifies masking to a running minimum; nonzero thresholds are outside the implementation’s scope.
Key ideas
- Running sums let each initialized horizon update trend-scanning statistics in constant work per bar.
- Parity checks compare the executed MQL5 engine with a Python reference and identify numerical sensitivity near perfect fits.
- Backward processing in the referenced implementation reverses slope and t-value signs, requiring correction for chronological interpretation.
- The window-selection rule does not choose the most statistically significant trend, and nominal t thresholds may not apply to price data.
- The implementation’s zero-threshold volatility mask can use a running minimum, while nonzero thresholds need a different approach.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.