Skip to content
All library documents

Estimating Bid and Ask Motion with Event-Weighted Local Fits

Article MQL5 code base

Summary

This research tool estimates the bid and ask as separate time series, fitting local quadratic curves to each side of the quote. It reports position, velocity, acceleration, standard errors, z-scores, and an estimated turning time across three event-count windows. A separate spread channel tracks spread movement. Windows are weighted by recency and counted in quote updates rather than seconds, so their effective sample size is designed to remain comparable as tick arrival rates change.

The document addresses two measurement issues: a repeated unchanged quote is not treated as a new observation for that side, and ordinary least-squares uncertainty can understate error when price residuals are correlated. It applies a random-walk error floor and scores non-overlapping forecasts out of sample, separating higher-confidence readings for inspection. The slowest window drives a persistent phase classification, with no reversal state because the available inputs are insufficient for reliable tick-scale reversal detection. The included Expert Advisor demonstrates signals and entry-price projections but places no orders and is not a tested strategy. Results depend on broker tick quality and timestamp resolution.

Key ideas

  • Bid and ask are modeled as separate quote trajectories, with local fits used to estimate motion and uncertainty.
  • Recency-weighted windows count updates, allowing the observation window to expand or contract with tick activity.
  • A random-walk error floor addresses uncertainty estimates that may be too narrow under correlated price residuals.
  • Out-of-sample forecast scores distinguish estimation confidence from demonstrated predictive skill.
  • The example entry logic is illustrative and depends on the quality and timing of broker data.

Tags

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