Skip to content
All library documents

Volatility-Based Pending Orders with Reversal and Martingale Options

Article MQL5 code base

Summary

This expert advisor strategy places pending orders at a scheduled terminal time, with distances based on average volatility over a selected number of past days. Stop-loss and take-profit levels are expressed as percentages of that volatility measure rather than fixed point values. If neither pending order is triggered by a later scheduled time, the advisor deletes both. The stop for one direction sits at the opposing order’s level, linking the stop distance to the gap between entries.

The system can retain the opposite order after an entry, allowing a position reversal if the first trade is stopped out. It can also increase the lot size on the second order using a martingale multiplier. The document describes configuration choices and recommends optimizing over periods no longer than a year, with possible reoptimization every three months. It provides no performance evidence, so these are implementation and tuning suggestions rather than validated results. The martingale feature can increase exposure after losses, and the stated optimization schedule may not ensure robustness across changing market conditions.

Key ideas

  • Pending entry levels are set using recent average volatility and a scheduled terminal time.
  • Stop-loss and take-profit distances scale with volatility, while the opposing order determines the stop location.
  • Untriggered orders are removed at a configured time.
  • Retaining the opposing order enables reversal, and a multiplier can increase the follow-up trade size.
  • The document gives optimization suggestions but reports no strategy performance or evidence of robustness.

Tags

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