Tutorial: Custom Martingale 1
-
important note: this is not about profitable EA, it is about custom martingale principle, do all tests only in tester or demo ...
People are repeating question how to create martingale system.
In this tutorial I will describe how to create simple, but less stable martingale. This is one method is ugly but is simple and is working in tester.
Criteria:- separate buy and sell
- buy trade is opened when fast MA crossed slow MA in up direction, opposite for sell
- trade closed on fixed SL/TP
- when trade is closed on SL, multiply volume for next trade by custom multiplier
- perform lots reset when calculated lots value is more than some reset limit (skip reset when value is 0)
- also reset lots on TP
Lets start:
Open new empty project:

Create few input parameters:

Create few variables:

In on Init section reset variables by lotsStart value:

In on Tick section add few blocks based on condition, if there is no trade (separate for Buy/Sell) than open trade with variable lots:

Opposite for sell:

Continue in on Trade section:
Learn basic math and use custom code block in simpliest way for your math and add custom code ... for our example the logic criteria are:- when trade is closed on SL, multiply volume for next trade by custom multiplier
- perform lots reset when calculated lots value is more than some reset limit (skip reset when value is 0)

Do few changes for sell:

And rest of blocks for TP reset:

Run your EA in tester and you can see, that buy and sell are mixed and hard to find if martingale is working:

Think about input parameter for selecting trade type (only buy, only sell, or both), name this parameter tradeType and value 1 can be buy, value 2 can be sell, and 0 will representing both ... and add condition blocks into your logic:

Now test it. In EA settings (in metatrader tester) set tradeType = 1 (for only Buy trades) :

Results are now much better to read:

Graph shows that we should consider to lower lotsReset value,

try lotsReset 0.17 .... see, slightly better, but still in loss, just martingale


try combined with sell, .... not much changed


anyway, this was not about profitable EA but about simple custom martingale ...
shared link:
https://fxdreema.com/shared/29RWlV12d -
@miro1360 nice share,thanks............
-
nice this i will use this
-
@miro1360 thanks miro
-
Thanks miro, this tutorial I am looking for