Code Library / Martingale

MQL5 Martingale EA

Classic martingale EA doubling lot size after each loss with safety limits.

Language: MQL5 · Category: Martingale · Tags: martingale, MQL5, EA, lot doubling, recovery

Source code

#include <Trade/Trade.mqh>
CTrade trade;
input double BaseLot=0.01; input double Mult=2.0; input int MaxLvl=6;
int curLvl=0;
double GetLot() {
   double lot=BaseLot;
   for(int i=0;i<curLvl;i++) lot*=Mult;
   return NormalizeDouble(MathMin(lot,10),2);
}

How to use this snippet

This is a building block, not a finished trading system. Paste it into your own MQL5 project, compile it, and test it on a demo account with your broker's real spreads before relying on it. If MetaEditor reports errors, the compilation error fixer can help.

Related snippets