Author of the idea: Vladimir Pastushak, Code Author: barabashkakvn.
Many traders have dabbled in the world of Expert Advisors (EAs), particularly those built on the martingale strategy. The VR Overturn EA is designed to let you explore classic martingale principles alongside the intriguing anti-martingale technique.
What sets this EA apart is its straightforward code, which is well-commented, making it easy for traders to understand and tweak as needed.
Trading with Martingale
- If a trade closes with Take Profit → open a new position with the starting lot in the same direction;
- If a trade closes with Stop Loss → open a new position with an increased lot in the opposite direction.
Trading with Anti-Martingale
- If a trade closes with Take Profit → open a new position with an increased lot in the same direction;
- If a trade closes with Stop Loss → revert to opening a new position with the starting lot in the opposite direction.
Understanding the Martingale System
With this strategy, you begin trading with a set minimum lot size. If a trade hits a stop loss, you'll increase the lot size for the next trade, aiming to recover previous losses with a profit when the next trade hits take profit. For instance, you might follow a progression like: 0.01, 0.02, 0.04, 0.08, 0.16, 0.32, 0.64, and so forth.
If you maintain this sequence, your total profit could match what you'd earn from a single trade with the minimum lot. Once a trade closes in the green, you reset to the minimum lot.
While the martingale strategy doesn’t inherently give you an edge, it can help redistribute profits. You may frequently see small gains, but watch out—losses can stack up quickly.
Understanding the Anti-Martingale System
In contrast to martingale, the anti-martingale approach focuses on increasing lot sizes when you're in profit. You start with the minimum lot size and, if a trade closes profitably, you ramp up the lot size by two or more times. If you hit a stop loss, though, it’s back to the starting lot.
Establish clear limits on how much you can increase your lot size, and know when to revert to the initial lot. For example, you might decide on a maximum of three successive lot size increases: 0.01, 0.02, 0.05.
Input Parameters
- Start Position: Buy or Sell - determines the direction of your first trade;
- Type of Trade: Martingale or Anti-Martingale - choose your trading methodology;
- Base Lot: Initial position volume;
- Stop Loss Value: Set your stop loss;
- Take Profit Value: Set your take profit;
- Multiplier for Lots: Defines the position volume multiplier;
- Magic Number: Assign an ID for your EA;
- All Magic: true → manage all Magic Numbers; false → only manage the specified Magic Number.
Be cautious when using this EA. Here’s a typical scenario:


And here’s an unexpected mishap:

Related Posts
- Harnessing MQL5 Wizard for Trading Signals: 3 Black Crows & 3 White Soldiers with MFI
- Mastering Trading Signals with MQL5 Wizard: Bullish and Bearish Engulfing Strategies
- Creating a Stochastic-Based EA for Hammer and Hanging Man Patterns in MetaTrader 5
- Creating an Expert Advisor for Dark Cloud Cover and Piercing Line Patterns with CCI Confirmation
- Creating Powerful Trade Signals with MQL5 Wizard: Bullish and Bearish Engulfing Patterns + RSI