Code Library / Martingale
MQL4 Anti-Martingale Strategy
Anti-martingale: increases lot after wins, resets after losses.
Language: MQL4 · Category: Martingale · Tags: anti-martingale, reverse martingale, MQL4, position sizing, strategy
Source code
input double BaseLot=0.01; input double WinMult=1.5; input int MaxWinLvl=4;
int winStreak=0;
double GetAntiMartLot() {
double lot=BaseLot; int lvl=MathMin(winStreak,MaxWinLvl);
for(int i=0;i<lvl;i++) lot*=WinMult;
return NormalizeDouble(lot,2);
}How to use this snippet
This is a building block, not a finished trading system. Paste it into your own MQL4 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.