Skip to content
All library documents

Automating the Oops Gap Reversal with Risk-Based Position Sizing

Article MQL5 articles

Summary

The article turns the Oops gap reversal pattern into an MQL5 Expert Advisor. A bullish setup begins when a bar opens below the prior bar’s low by at least a configured gap threshold; a bearish setup mirrors this above the prior high. The EA stores the gap references, waits for a completed bar to close back through the prior range boundary within a defined validity period, and then prepares a trade in the reversal direction.

The gap bar’s low or high supplies the stop reference, while a configurable risk-to-reward ratio determines the target. The EA can use fixed volume or size positions from a selected percentage of account balance, restrict trade direction, and avoid opening another strategy position while one is active. It also includes checks for market data and order responses. This is an implementation framework, not evidence of a durable edge: the article recommends broader and out-of-sample validation, and deterministic rules alone do not establish profitability.

Key ideas

  • The setup treats a sufficiently large opening gap beyond the previous bar’s range as a potential reversal signal.
  • A later completed bar must close back across the prior range boundary before the setup is confirmed.
  • The gap bar defines the stop reference, and the target is projected using a configured risk-to-reward ratio.
  • Position size can be fixed or calculated from a specified fraction of account balance.
  • The EA tracks setup expiry and existing positions, but its implementation does not demonstrate future profitability.

Tags

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