Loading…

Martingale Demonstration EA

RISK WARNING: martingale sizing multiplies the lot after every loss. A losing streak of N trades needs InpMultiplier raised to the power of N times the base risk to recover in a single trade - at the default 2.0 multiplier, six straight losses already needs 64 times the base lot, and there is no entry signal with a documented edge reliable enough to rule out a losing streak that long. This EA exists to make that arithmetic visible on a real account's order history, not to be a strategy in the normal sense. Two safety defaults follow directly from that warning and are not meant to be relaxed casually. InpIUnderstandTheRisk defaults to false: while false, the EA runs its signal logic, updates its Comment, and logs everything it would have done, but places no trades at all. It has to be set true by hand after reading this description. InpMaxDoublingSteps hard-stops the whole EA - not just the current streak - the moment the step cap is reached; recovering from that state requires removing and re-attaching the EA, not waiting for a timer or a win to reset it. A demonstration that quietly resets itself would hide the exact moment it was designed to show. The entry signal itself is a plain fast/slow EMA crossover - deliberately unremarkable, because the point of this EA is the money management, not the signal. Consecutive losses are counted from this EA's own closed order history since the chart was attached, and the lot size for the next trade is InpBaseLots multiplied by InpMultiplier raised to that count, normalised to the symbol's lot step. Notes and limitations - Only counts losses from trades this EA itself opened and closed after being attached - history from before that, or from another EA or manual trading, is ignored. - One position at a time. The next sequence trade only opens once the previous one has closed and history has been re-scanned. - The step cap disables the EA outright and requires manual removal and re-attachment to continue - this is intentional, not a limitation to work around. - Requires AutoTrading enabled and automated trading permitted at the terminal, account and Expert Advisor level; if trading is disabled the EA logs it and places nothing. - This is a demonstration of a money-management technique, not a strategy recommendation. The entry signal has no claimed edge.

Expert advisor · MT5 · v1.0 · Free

About Martingale Demonstration EA

Martingale Demonstration EA is an expert advisor (trading robot) for MetaTrader 5 based on Moving Average. It increases the lot size after a losing trade (martingale). It has 12 settings, such as I understand the risk, Base lots and Multiplier. MQL source code included.

Files in the download: MartingaleDemoEa.ex5, MartingaleDemoEa.mq5, MartingaleDemoEa.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
I understand the riskfalseMust be set true by hand before this EA will place any trade
Base lots0.01Lot size for the first trade of a fresh sequence
Multiplier2.0Lot multiplier applied after each loss (1.0 = disabled, fixed lot)
Max doubling steps4Hard cap on consecutive doublings - the EA disables itself at this step
Fast ma period10Fast moving average period for the entry signal
Slow ma period30Slow moving average period for the entry signal
Stop loss pips30Stop loss per trade, in pips
Take profit pips30Take profit per trade, in pips
Magic number20260822Magic number for orders opened by this EA
Slippage pips3Slippage tolerance, in pips
Max retries5Attempts per trade action before giving up
Retry wait ms500Pause between attempts, milliseconds

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Experts.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Martingale · Buy/Sell Arrows · Moving Average · MT5 Expert Advisor · MQL5 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria