Martin-gale Strategies

The Martingale Size question of the Misc panel calculates the trading volume relying on the martin-gale mechanics. It is helpful when you want to increase the trading volume after a losing trade. The idea is to increase the trading volume in a new trading action. The Martingale Size question would check whether the last closed trade was a losing one. If it were a losing trade, the answer would be the increased trading volume. Otherwise, the answer would be the default trading volume. This default volume should be specified in the Martingale Size settings.

Martingale Size Settings 

In the following image we see all the setting options available in this question.

 

Type

There are two options: multiplication or addition. This way we determine how the trading volume is increased.

Value

The number by which the volume of the last closed trade will be multiplied or added.

Symbol

Here, we specify the symbol in which the last closed trade will be searched. So, if the last closed trade in this symbol is a losing one, the new trading volume will be calculated based on the two previous settings.

If you leave this setting empty, the chart symbol in which the Expert Advisor runs will be used.

Magic Number

In case we also want to filter by magic number, we provide the number here. This way the last closed trade of the symbol previously specified that also has this magic number will be used to calculate the next trading volume.

Leave it empty and it will use the last trade no matter what magic number has.

Comment

Same logic as Magic Number. When we want to filter by comment.

Limit

In case you want to limit the number of times the trading volume is increased.

For example, if you set the Limit to 5, the last consecutive losing trade at which the trading volume is increased is the 6th one. Trade 1 has the default volume and the next 5 consecutive trades will be increased. After these 5 increments, the next trade will use the default trading volume and the process starts again.

If you leave this setting empty, trading volume will increase infinitely while losing trades occur consecutively.

Default Size 

You need to provide the default trading volume we get from this question when the last trade is a winning one or after the limit trade has been reached.

You shouldn’t leave this setting empty. Otherwise, no trading volume will be provided to the trading action and thus the trading action will fail.

 

Example: MA Crossovers System With Martingale

In order to see this mechanics in action, we show you in the next video how to implement the martin-gale logic in the MA Crossovers system we developed in the Getting Started tutorial of this documentation.

 

Now, if you run this Expert Advisor in the Strategy Tester, you will see that the trading volume is doubled when the previous trade was a losing one. Because we set the limit to 3 consecutive trades, after 4 losing trades in a row the next trade opens with the default volume.

 

Martingale Immediately After Closing

Many traders want to start the martin-gale logic right after a losing trade closes. They do not wait till a new trading signal takes place. For this type of trading logic, we can use the Order Closed Losing question of the Misc panel.

This question detects when a losing trade just closes. The question has the next setting options:

Symbol

Here, we specify the symbol of the trade that just closes. If the trade that closes is not of this symbol, then the closing won’t be detected.

Leave this setting empty if you want to use the chart symbol in which the Expert Advisor runs.

Magic Number

If you also want to specify the magic number of the trade. Leave it empty if the magic number doesn’t matter.

Comment

If you also want to specify the magic comment of the trade. Leave it empty if the comment doesn’t matter.

 

Example: MA Crossovers System With Martingale After Closing 

Let’s modify the MA Crossovers system to trade in the opposite direction when a losing trade just closes. We limit the number of trading volume increments to 3.