You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Check out the new article: Feature Engineering for ML (Part 6): Microstructural Features in MQL5.
The article introduces CMicrostructureFeatures, an MQL5 class for bar‑level microstructure features: Roll spread/impact, Corwin‑Schultz spread and sigma, Kyle's Lambda, Amihud's ILLIQ, and Hasbrouck's Lambda. Calculations rely solely on OHLCV using rolling windows. It clarifies the implications of MT5 tick volume for lambda estimators and keeps spread estimators volume‑independent. A validation script asserts sizing and basic bounds on outputs.
The Python implementation in Part 5 assumes access to a true tick feed: individual trades with price, volume, and timestamp. For the lambda estimators, signed volume is computed from the tick rule applied to individual ticks, not to bar closes. CopyTickVolume() in MQL5 does not provide this. It returns a count of price changes within the bar, not a count of individual trades. For a broker that aggregates incoming orders before publishing price updates, a single large trade may register as one tick, and a flurry of small trades may register as many ticks. The relationship between tick volume and true trade count is broker-dependent and not disclosed.
This matters for the lambda estimators in a specific way. Kyle's Lambda and Hasbrouck's Lambda both regress price changes on signed volume, where signed volume is the product of trade direction and trade size. In the MQL5 bar-level implementation, trade direction is the bar-close tick rule (bt = +1 if closet > closet-1, −1 if closet < closet-1, 0 otherwise), and volume is tick volume. Both are approximations.
The practical consequence is that the lambda values produced by the MQL5 implementation should be treated as ordinal regime signals rather than cardinal price-impact estimates. A rising Kyle's Lambda during a trend still indicates increasing price impact per unit of order flow, even if the absolute level is not comparable across brokers. The Roll spread and Corwin-Schultz spread do not use volume at all; their values are broker-independent and directly comparable with the Python output.
Author: Patrick Murimi Njoroge