Quick Martingale Help

 

Hello, I just had a quick question. I have this one EA that I use that has many lines of coding. I wanted to input a small martingale parameter in the code to make the EA better. I was wondering if it's possible just to input a few lines of coding right after the "ordersend" function of the code to make it a semi martingale.


For example, right after the part where the code places an order, I would like there to be a martingale function that says:

IF order reaches stop/loss, THEN place new order in opposite direction with a specific multiplier......do this up to a certain amount of levels.


I was wondering if this was possible or if it's a lot more complicated than that. If it's this simple, can you please guide me in the right direction.


THANKS!

 
jamesmean:

[...] I wanted to input a small martingale parameter in the code to make the EA better. [...]

"Better" in what sense?

https://www.mql5.com/en/articles/1446, https://www.mql5.com/en/articles/1481.

 

I guess to me it would be better because the strategy wins most of the time. It can win hundreds of trades, but then have one that loses. The one that loses doesn't wipe out the account or anything, but it is definitely a lot more than what was won over time.


For instance, for a particular strategy, each win would yields about 30 cents. Most of the time, the 30 cent mark is hit (lets say 300 trades in a row). Then, as expected, there will be a loss of about 10 dollars. This isn't too bad on a 5k account, but if you're looking at percentages, it's not all that great. Anyway, this happens a few times a quarter, but the next trade seems to always fix this problem on the next level (or maybe the one after that).


I just want to check how the strategy does over the past 11 years to see if it generally works on all market conditions. I was even thinking about doing an anti martingale strategy since many trades win in a row.

 

The majority of martingale type strategies win most of the time, but of course lose on average. Good luck anyway.

 
gordon:

The majority of martingale type strategies win most of the time, but of course lose on average. Good luck anyway.


Yeah, I realize that most martingale type strategies end up blowing the account most of the time. However, each time when I manually input a martingale order on a loss trade, it tends to work out on the second trade. If, in history, it does not go more than three levels, then it should be a pretty safe-ish money management tool to add on to my strategy.


Any suggestions on which functions to add to make this work?

 
jamesmean:

Yeah, I realize that most martingale type strategies end up blowing the account most of the time. [...]

ALL.

As to your question - there are examples in these articles: https://www.mql5.com/en/articles/1526, https://www.mql5.com/en/articles/1413.

 
gordon:

ALL.

As to your question - there are examples in these articles: https://www.mql5.com/en/articles/1526, https://www.mql5.com/en/articles/1413.


I'll take a look at them...but I would still say MOST because I've seen quite a few systems that don't blow the account. True, they have major drawdowns, larger recovery times and take big hits; but even after seven years of testing no margin call was made (or even close to). However, I still wouldn't trade them because they were not profitable anyway.
 
jamesmean:

I'll take a look at them...but I would still say MOST because I've seen quite a few systems that don't blow the account. True, they have major drawdowns, larger recovery times and take big hits; but even after seven years of testing no margin call was made (or even close to). However, I still wouldn't trade them because they were not profitable anyway.
All martingale systems are profitable until that one time that fails. This is the nature of it. I think setting a maximum 'iteration' on the martingale is key. I would never let it add more than 3 times the original orders size lots; which isn't a lot, but its safer.
 
jamesmean:

For example, right after the part where the code places an order, I would like there to be a martingale function that says:

IF order reaches stop/loss, THEN place new order in opposite direction with a specific multiplier......do this up to a certain amount of levels.

Won't work there. The order has been opened but it takes time (many start() calls) before the order will close (at TP or SL)

At the beginning of start, check for no open orders, then look at the last history. If it was a loss set the new direction opposite that.

 
WHRoeder:

Won't work there. The order has been opened but it takes time (many start() calls) before the order will close (at TP or SL)

At the beginning of start, check for no open orders, then look at the last history. If it was a loss set the new direction opposite that.


Oh ok, I see what you mean. It is actually much more complicated than I thought. No wonder why it wasn't working. Thanks for the input; I'll try and see if I can figure this out.
 
jamesmean:
Most of the time, the 30 cent mark is hit (lets say 300 trades in a row). Then, as expected, there will be a loss of about 10 dollars.

If this is true then you have found the holy grail. No need to endanger it with Martingale:

win: 300 * .30 = 90$

los: 1 * 10$ = 10$


A loss of only 10$ after an average win of 90$ is the holy grail by every definition of "holy grail" I have ever seen.

Since I simply don't believe the above numbers I also doubt that you have thoroughly analyzed your win/loss ratio, the distribution of winers and losers, etc. You are basing your plans on vague and completely unrealistic (and wrong) guesses, this is doomed to fail!

Reason: