Skip to content
All library documents

Microstructure Features from OHLCV Bars and Tick Data

Article MQL5 articles

Summary

This article surveys and implements market microstructure features for machine learning. Its OHLCV path estimates spreads and price impact using measures such as Roll, Corwin–Schultz, Amihud, and Hasbrouck. A separate path uses raw ticks to calculate per-bar order-flow imbalance and VPIN from equal-volume buckets. The measures reflect different ideas: serial price-change covariance can proxy for spread, signed flow can characterize price impact, and buy–sell volume imbalance can indicate concentrated trading activity.

The implementation organizes features into a common bar-indexed output and uses Numba kernels for computation. The article explains that tick data is necessary for the richer imbalance and VPIN features, while OHLCV alone supports the spread and impact suite. It also describes caveats: Roll estimates are invalid when covariance is positive, Corwin–Schultz can return missing values when its assumptions fail, and VPIN depends on imperfect trade-side classification. These are candidate features, not proof of predictive power; their usefulness depends on data quality, instrument, and modeling context.

Key ideas

  • Roll estimates effective spread from negative serial covariance in price changes.
  • Corwin–Schultz uses high-low ranges to estimate spread and volatility.
  • Price-impact measures relate returns to volume, with some requiring signed order flow.
  • VPIN measures buy–sell imbalance in equal-volume buckets and requires tick data.
  • Assumption failures and trade-direction classification can make microstructure estimates unreliable.

Tags

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