Skip to content
All library documents

Higher-Timeframe Swing Structure for Contextual Chart Pattern Detection

Article MQL5 articles

Summary

The article presents a reusable MQL5 swing engine designed to provide higher-timeframe context for chart pattern detection. It identifies swing highs and lows on H4 using a configurable symmetric lookback, then labels highs as higher or lower and lows as higher or lower relative to the previous confirmed swing of the same type. The latest labels classify structure as an uptrend, downtrend, or range; later pattern detectors can use that state as a prerequisite before evaluating shapes on a lower trading timeframe.

The engine stores swing times and prices so its markers can be drawn on lower-timeframe charts without separate time-coordinate conversion. The article explains why same-timeframe swing analysis can be noisy and describes limitations: swings are confirmed only after the right-side lookback has elapsed, rebuilds occur on H4 bar closes, and detection relies on bar extremes rather than intrabar data. The engine supplies context and visualization; it does not generate signals or place trades, and no predictive or profitability evidence is offered.

Key ideas

  • The engine calculates market structure on H4 independently of the chart timeframe used for trading.
  • A swing high or low is confirmed by comparing its bar with a symmetric window of neighboring bars.
  • Swing labels classify the latest structure as an uptrend, downtrend, or range.
  • Pattern evaluation can require a compatible higher-timeframe trend or impulse before checking the lower-timeframe shape.
  • The engine provides structure information rather than trading signals, and swing confirmation is delayed by the lookback window.

Tags

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