Martingale EA overview
Martingale is a popular strategy used in trading, especially in the foreign exchange market.
The Martingale method is highly compatible with system trading and is used by many EAs (Expert Advisors).
The martingale method increases the size of trades after a loss, with the aim of recovering previous losses and making a profit.
Although the Martingale EA is attractive because of the potential for quick profits, it also comes with significant risks that traders should be aware of.
This site also distributes a free Martingale EA.
Free martingale EA example:LIVE_MATRIX_FX , Euro_Magic_FX , etc.
Also, many of the EAs on sale use the martingale method.
Sales martingale EA example:FXSTABILIZER , Forex Truck EA, GPS Forex Robot , etc.
What is martingale trading?
The martingale method is based on the principle of doubling the trade size after a loss.
The idea behind this strategy is that eventually a winning trade will occur and the profit from that trade will be enough to cover previous losses and generate a profit.
Martingale method recovers past losses.
For example, suppose a trader starts with 1.0 lot trade and experiences a loss. Using the Martingale method, the trader doubles trade size on next trade to 2.0 lot.
If a loss occurs on that trade as well, the trader increases trade size again to 4.0 lots on the next trade.
If trader win a trade by doubling the lot size after a loss occurs, trader can earn a profit that exceeds previous losses.
Martingale trading example
For example, on the first trade, a 1.0 lot trade hits a 10 pip stop loss, resulting in a loss of 10 USD.
Next, trade 2.0 lots and take profit at 10 pips, resulting in a profit of 20 USD.
In this example, the past two trades have generated a total profit of 10 pips.
In this way, with the martingale method, if a trade ends up winning even once, it will generate a profit that exceeds the past losses.
The following is an example of a loss in 6 consecutive trades and a win on the 7th trade.
In the end, the series of trades earns a profit of $10.
Trade No. | Lot Size | Trade Reslt | Profit / Loss |
1 | 1.0 lot | -10pips | -10USD |
2 | 2.0 lot | -10pips | -20USD |
3 | 4.0 lot | -10pips | -40USD |
4 | 8.0 lot | -10pips | -80USD |
5 | 16.0 lot | -10pips | -160USD |
6 | 32.0 lot | -10pips | -320USD |
7 | 64.0 lot | -10pips | -640USD |
Total Profit/Loss | +10USD |
Assuming that the market moves randomly, if the stop loss and take profit are the same 10 pips, the probability of winning the trade is 1/2.
In this case, the probability of consecutive stop losses occurring is shown below.
number of consecutive loss | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
Lot size | 1 lot | 2 lot | 4 lot | 8 lot | 16 lot | 32 lot | 64 lot | 128 lot | 256 lot | 512 lot |
Probability of consecutive loss | 1/2 | 1/4 | 1/8 | 1/16 | 1/32 | 1/64 | 1/128 | 1/256 | 1/512 | 1/1024 |
The probability of losing 10 times in a row is 1 in 1024, which is extremely low.
However, on the 10th trade, the lot size is 512x. It’s a very large lot size.
If the 10th trade fails, the loss in the account will increase to -$10,230.
Trade No. | Lot Size | Trade Reslt | Profit / Loss | Accumulation of Profit/Loss |
1 | 1 lot | -10pips | -10 USD | -10 USD |
2 | 2 lot | -10pips | -20 USD | -30 USD |
3 | 4 lot | -10pips | -40 USD | -70 USD |
4 | 8 lot | -10pips | -80 USD | -150 USD |
5 | 16 lot | -10pips | -160 USD | -310 USD |
6 | 32 lot | -10pips | -320 USD | -630 USD |
7 | 64 lot | -10pips | -640 USD | -1,270 USD |
8 | 128 lot | -10pips | -1,280 USD | -2,550 USD |
9 | 256 lot | -10pips | -2,560 USD | -5,110 USD |
10 | 512 lot | -10pips | -5,120 USD | -10,230 USD |
11 | 1,024 lot | -10pips | -10,240 USD | -20,470 USD |
12 | 2,048 lot | -10pips | +20,480 USD | 10 USD |
Total Profit/Loss | +10USD |
Without a very high account balance, the account will fail.
Specifically, in addition to the balance of 10,230 USD in your account, you need a balance to open the next 1024 lot position.
Even if these trades start with a high balance of 10,000 USD, as soon as the 10th trade fails, the account balance will suddenly drop to 0 USD. It’s called game over.
The account balance will suddenly drop to 0. This is the risk of Martingale EA.. This is the risk of Martingale EA.
Without a very large account balance, the account is gone.
Specifically, the account must have a balance of 10,230 USD, plus the balance needed to open a position for the next 1,024 lots.
Even if these trades start with a high balance of 10,000 USD, as soon as the 10th trade results in a loss, the account balance will instantly drop to 0. It’s called game over.
The account balance suddenly becomes 0. This is the risk of Martingale EA.
Probability of success of martingale method
Let’s say there was a game of flipping a coin.
You wouldn’t imagine tossing a coin and getting tails ten times in a row.
But what if you toss a coin 10,000 times? Don’t you think it turns out to be getting tails about once?
To be successful in the world of trading, you need to repeat a huge number of trades. If you make a huge number of trades, it is very common to lose 10 trades in a row.
If this game had the following rules, you would definitely participate.
“If you toss a coin 10 times and it lands on heads even once, you get $10.”
“If you get tails 10 times in a row, you lose $10.”
However, trading is different.
“If you toss a coin 10 times and it comes up heads even once, you get $10.”
“If you get tails 10 times in a row, you lose $10,230.”
The probability that the coin will be tails 10 times in a row is 1023/1024.
If you accumulate profits of 10 pips 1023 times, the profit will be $10,230.
The probability of ultimately gaining $10,230 and losing $10,230 are both 1/2.
A coin flip game like this is gambling.
If market price movements are completely random, trading is also gambling.
However, because we believe that there are certain trends and regularities in market price movements, we face the market and trade.
What is certain is that although the foreign exchange market basically moves randomly, prices always move up and down, like waves.
Prices do not continue to rise or fall indefinitely; at some point, prices will move in the opposite direction.
There is a trading method that takes advantage of the market’s tendency to move up and down in waves and combines the martingale method.
Below, we will provide a detailed example of the martingale EA trading method.
Martingale EA trading strategy
When the martingale method is incorporated into an EA, there are mainly two patterns below.
- EA that trades by increasing the lot size after the stop loss.
- EA that performs grid trading while increasing lot size.
EA that trades by increasing the lot size after the stop loss
As the simplest example, let’s backtest an EA that sets the stop loss and take profit to the same 50 pips and doubles the lot size after the stop loss.
Back test conditions ①_simple martingale EA
Take profit | 50 pips |
Stop loss | 50 pips |
Initial lot size | 0.01 lot |
Initial balance | 10,000USD |
Leverage | 1:500 |
Direction of trade | Trade Buy and Sell alternately. If the previous trade was Buy, the next trade is Sell. If the previous trade was a Sell, the next trade is a Buy. |
Entry condition | If the previous position was closed, enter immediately. |
Test start | 2015/01/05~ |
This example started with an initial balance of 10,000 USD and generated a profit of 6,000 USD in 10 months.
However, in the 11th month, the account went bankrupt.
The number of consecutive losses is 11.
In this way, when Martingale EA loses, the account loses its balance all at once.
Next, let’s test by increasing the account balance from 10,000 USD to 100,000 USD.
Back test conditions ②_10x Deposit
Take profit | 50 pips |
Stop loss | 50 pips |
Initial lot size | 0.01 lot |
Initial balance | 100,000USD |
Leverage | 1:500 |
Direction of trade | Trade Buy and Sell alternately. If the previous trade was Buy, the next trade is Sell. If the previous trade was a Sell, the next trade is a Buy. |
Entry condition | If the previous position was closed, enter immediately. |
Test start | 2015/01/05~ |
This time, the account survived without going bankrupt.
Let’s take a look at the details of the results.
Over the nine years from January 2015 to February 2024, it generated a profit of 35,174 USD.
The number of consecutive losing trades is 11.
The maximum equity drawdown is 30,676 USD.
According to simple calculations, this test account would have failed if the initial balance was less than 30,676 USD.
From this example, you can see that account balance is very important for Martingale EA.
The larger your account balance, the less risk your account will go bankrupt.
Conversely, the smaller the account balance, the higher the risk of the account going bankrupt.
Next, let’s test by lowering the leverage from 500x to 100x.
The account balance is 100,000 USD, same as “Back test conditions ②”.
Will the account survive?
Back test conditions ③_lowered leverage
Take profit | 50 pips |
Stop loss | 50 pips |
Initial lot size | 0.01 lot |
Initial balance | 100,000USD |
Leverage | 1:100 |
Direction of trade | Trade Buy and Sell alternately. If the previous trade was Buy, the next trade is Sell. If the previous trade was a Sell, the next trade is a Buy. |
Entry condition | If the previous position was closed, enter immediately. |
Test start | 2015/01/05~ |
No trades were made after a large drawdown three years later.
After 9 consecutive losses and a maximum of 25.6 lots, EA no longer has a position.
This is due to the margin mechanism.
In foreign exchange trading, leverage determines the tradeable lot size.
For example, the margin required to hold 1 standard lot (100,000 units) with leverage of 1:1 is $100,000.
If the leverage is 1:100, the required margin will be $1,000. (100,000/100)
If the leverage is 1:500, the required margin will be $200. (100,000/500)
Conversely, let’s calculate how much lot size an account with a balance of $1000 can hold.
If the leverage is 1:100, the maximum number of lots that can be held is 1 lot.
(Balance $1000 * Leverage 100) / 100,000 units)
If the leverage is 1:500, the maximum number of lots that can be held is 5 lots.
(Balance $1000 * Leverage 500) / 100,000 units)
In this way, the higher the leverage, the larger the lot size can be held.
In the example of backtest ③, the trade was stopped because there was not enough balance in the account to open the next lot size of 51.2 lots after the 9th consecutive loss of 25.6 lots.
When looking at the MT5 tester log, a No Money error is displayed.
In the example of backtest ③, the final account loss is -7,482USD, and the account is not bankrupt.
However, a large drawdown occurred and the trade ended.
Even if a trade is made with the same trading method and initial balance, a leverage of 1:500 is profitable, but a leverage of 1:100 is a loss.
As you can see, account leverage is also a very important element for Martingale EA.
Add entry filter to martingale EA
In the examples of backtests ① to ③, the EA always traded without selecting an entry point.
What will be the result if the EA has an entry point filter?
The next backtest ④ uses the Bollinger Bands indicator as a filter.
Other than this, the conditions are the same as backtest ①, which resulted in bankruptcy. (Initial balance 10,000 USD, leverage 1:100)
Will the account survive?
Back test conditions ④
Take profit | 50 pips |
Stop loss | 50 pips |
Initial lot size | 0.01 lot |
Initial balance | 10,000USD |
Leverage | 1:100 |
Direction of trade | Trade Buy and Sell alternately. If the previous trade was Buy, the next trade is Sell. If the previous trade was a Sell, the next trade is a Buy. |
Entry condition | Buy entry when a candlestick crosses the Bollinger Bands underline from below to above. A sell entry when a candlestick crosses the upper line from above to below. |
The account did not go bankrupt, and the profit curve continued to rise upwards until the end.
The final profit was 1,734 USD and the maximum drawdown was 378 USD.
The entry filter worked well.
However, it should be noted that the number of trades is 107, which is a very small number due to the filter.
If the number of trades is small, the possibility of losing consecutively is low.
Rather than the entry filter working well, it is possible that the number of trades was small, so the consecutive losing streaks happened to be small.
If Martingale EA can find an entry point where it is difficult to lose consecutively, it may work beneficially.
Martingale EA combined with grid trading
Martingale EA is generally used in combination with grid trading and position trading.
What is grid trading strategy?
The grid trading strategy is as follows.
- Open first position.
- Adds a position in the same direction as the first position if the price moves in the opposite direction to the first position.
- If the price further moves against the direction of the position, open an additional position. Repeat this.
- Wait until the total position makes a profit, and in the end, close all positions at once with a profit.
Please note that no take profit or stop loss is set for each position. The criterion for closing a position is the profit/loss of the total position, including all additional positions.
I created a sample EA that executes grid trades at intervals of 50 pips.
The test results of this sample EA are as follows.
Back test conditions ⑤_simple grid trading strategy
Take profit | Take profit if the total position makes a profit of 10 pips |
Stop loss | none |
Initial lot size | 0.01 lot |
Initial balance | 10,000USD |
Leverage | 1:100 |
Entry condition | Buy entry when the candlestick crosses the Bollinger Bands underline. A sell entry when a candlestick crosses above the upper line. |
Additional entry conditions | If the price moves 50 pips from the previous position, open an additional position. |
Below is the trading history of this sample Grid EA plotted on an MT5 chart.
▼Blue=Buy Red=Sell (range market price)
You can see that the position is closed after making an additional entry and making a profit on the total position.
If there is a large trending market, a large number of additional entries will be made.
The following shows a downtrend and a large number of long positions.
▼Blue=Buy Red=Sell (downtrend)
Let’s take a look at the trading results.
In the end the account earned a profit of 1546 USD.
However, the maximum equity drawdown is 5691 USD, which means a large equity drawdown has occurred.
If the initial balance of the account is 1000 USD, this account will be bankrupt.
Combines grid and martingale
What would happen if the lot size of the additional position was doubled under the conditions of backtest ⑤?
The account went bankrupt right after the test started.
Since the lot size is doubled and entered, the risk is naturally higher.
Advantages of EA that combines grid and martingale
An EA that combines grid trading and martingale is naturally high risk.
However, there are also benefits.
This means that even a small market rebound will result in a profit, making it extremely profitable.
Backtests ⑥ and ⑦ below were traded under the same conditions except for doubling the lot size.
Back test conditions ⑥_No martingale, Simple Grid Trading
Take profit | Take profit if the total position makes a profit of 5 pips |
Stop loss | none |
Initial lot size | 0.01 lot |
Initial balance | 100,000USD |
Leverage | 1:500 |
Entry condition | Buy entry when the candlestick crosses the Bollinger Bands underline. A sell entry when a candlestick crosses above the upper line. |
Additional entry conditions | If the price moves 100 pips from the previous position, make an additional entry. The lot size for additional entries is 0.01 lot, which is the same as the initial lot. |
The total profit was 1469 USD, and the maximum equity drawdown was 502 USD.
In the next backtest ⑦, try setting the lot size to double the additional entry.
In other words, adopt the martingale method.
Back test conditions ⑦_Combines grid and martingale
Take profit | Take profit if the total position makes a profit of 5 pips |
Stop loss | none |
Initial lot size | 0.01 lot |
Initial balance | 100,000USD |
Leverage | 1:500 |
Entry condition | Buy entry when the candlestick crosses the Bollinger Bands underline. A sell entry when a candlestick crosses above the upper line. |
Additional entry conditions | If the price moves 100 pips from the previous position, make an additional entry. The lot size for additional entries is double the previous one. |
The total profit was 3,270 USD, and the maximum equity drawdown was 5,372 USD.
Although the profit was nearly 2x, the equity drawdown was nearly 10x.
Incorporating the martingale method has higher risk, but also higher rate of return.
Below is an MT5 chart diagram comparing the trading of “⑥Simple grid trading EA” and “⑦EA that combines grid and martingale” on EURGBP.
The dates and times on the upper and lower chart screens match.
After holding a buy position on the left side of the chart screen, the market price fell.
“⑦Grid and Martingale Combination EA” gained early profits and closed a series of positions.
On the other hand, “⑥ Only Grid Trade EA” holds additional positions for a long period of time.
By incorporating the martingale method into grid trading, the EA can profit from small market rebounds.
By doubling the lot size of additional entries, the EA can make a profit on the total position even if the market rebound is small.
This method accumulates profits quickly. The account will then be able to execute the next trade.
Therefore, the profitability will be higher if the martingale method is adopted.
Balance is important for Martingale EA combined with grid trading
Of course, if the EA in backtest ⑥ is operated with an account with a balance of 3000 USD, it will fail.
Back test ⑧_Initial balance 3,000USD
When I tested it with a slightly larger balance of 5000 USD, the account survived and made a profit.
Back test ⑨_Initial balance 5,000USD
In this way, whether or not the grid and martingale combination EA will make a profit depends largely on the account balance.
Weaknesses of martingale EA combined with grid trading
Weak against strong trends
The weakness of the grid and martingale combination EA is the large trend market.
When a major trend occurs, existing positions are left behind and equity drawdowns increase.
Below is the MT5 transaction history chart screen when the EA in backtest ⑥ blew up an account with an initial balance of 3,000 USD.
A strong uptrend occurred and the EA made multiple sell entries with increased lot sizes.
But the trend continued, the balance went to 0, and the trade stopped out.
To avoid this, it is necessary to incorporate entry logic into the EA that prevents excessive positions in strong trending markets.
Strengths of Martingale EA combining grids
Take advantage of market characteristics
It is difficult to find regularities in market movements and make profits from trading.
However, one thing is certain: prices move up and down like waves.
The market does not continue to move in one direction forever; it will always move in the opposite direction at some point.
The grid and martingale combination EA earns profits through this mechanism in which the market moves up and down.
This is reasonable.
If you can prepare an unlimited balance, even if your account has a temporary equity drawdown, the market will eventually reverse and the EA will make a profit. This is a very effective trading method.
However, there is no standard for how much balance you should have in the account to be safe.
It is also not realistic for ordinary traders to prepare large balances.
In order for a martingale EA to be profitable, it requires an entry logic that will not bankrupt the account even if a big trend occurs.
Or, even if the account balance is small at first, profits will definitely accumulate as the EA repeats trades.
As profits accumulate, the balance increases.
The larger the balance, the more likely the account will survive a trending market.
For Martingale EA, when it starts operation is also very important.
Even if you start trading in a gambling-like risky state at first, if a trend does not occur in the early stages of operation and account balance increases, the risk will gradually decrease.
Profit quickly
The grid and martingale combination EA will definitely bring profits as long as the account does not go bankrupt.
Therefore, profits accumulate quickly.
Conclusion About Martingale EA
Even if Martingale EA is making stable profits, there is a risk that the account balance will suddenly drop to 0.
However, as long as the account balance is not depleted, it will definitely generate profits.
The following three points are very important for Martingale EA.
- The larger the account balance, the more stable the income will continue to be. Conversely, if your account balance is small, the risk of your account going bankrupt increases.
- Account leverage is important as large lot sizes are required. The higher the leverage, the better the results
- Entry logic is very important.
For a simple martingale EA, an entry logic that does not cause consecutive losses is required.
For grid and martingale combination EA, entry logic is required that does not hold excessive positions in trending markets.
If these logics can be installed in an EA, the martingale EA will become a very powerful tool.
Recommended Forex Broker for Martingale EA
As already explained, account balance and leverage are important for Martingale EA.
The “XM (XMTrading) Standard Account” offers a 100% deposit bonus that doubles the deposit amount.
For example, if you deposit $500, you will be able to trade twice as much as $1,000.
Also, the maximum leverage of XM is 1:888
This is the most advantageous environment for Martingale EA.
In particular, XM’s 100% bonus covers equity drawdowns even if your deposited balance reaches 0. (Other brokers only have the advantage of being able to open large positions, and the bonus will disappear if a drawdown occurs that exceeds the deposit amount)
In addition to the double deposit bonus, you can also get an account opening bonus at XM.
*However, depending on your country of residence, you may not be able to receive various bonuses.
*To receive 100% deposit bonus + account opening bonus, please select “Standard account (1 lot = 100,000)”. Zero accounts cannot receive bonuses.