Skip to content
All library documents

MQL5 Macros for Candle Features, Fractals, Gaps, and Price Measures

Article MQL5 code base

Summary

This reference describes MQL5 preprocessor macros that make Expert Advisor code more concise. It maps indexed rate data to candle prices and times, exposes bid and ask values, and provides access to moving averages and ATR arrays. The author assumes indicator and rate arrays are configured as series, so index zero refers to the newest element; correct array orientation is necessary for the examples to work as intended.

The macros derive candle body, range, shadows, typical prices, direction, and movement relative to ATR. Boolean helpers identify directional candles, strict and non-strict fractals, three-candle gaps, and dojis using either point or range thresholds. Additional formulas clamp values, interpolate or normalize variables, evaluate simple curves, and calculate price or moving-average differences across bars. The document is a programming aid rather than a trading strategy: it explains how to express common price-action features but supplies no tests, signal validation, or evidence that any feature predicts returns. Users need to check indexing, thresholds, and formula behavior in their own EA.

Key ideas

  • The macros provide short names for indexed candle, quote, moving-average, and ATR data.
  • Array series orientation determines how candle indices map to time.
  • Candle helpers calculate body, shadow, range, direction, and ATR-relative size.
  • Boolean macros identify fractals, gaps, dojis, and other candle patterns.
  • Interpolation, clamping, normalization, and difference macros support EA calculations.

Tags

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