Reversing Strategy With Martingale

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #85848 quote
    Vonasi
    Moderator
    Master

    I read this article today:

    https://www.mql5.com/en/articles/5008

    and as it is raining here in Greece I thought it would be an interesting way to pass the time trying to code something around the idea.

    Basically in the article it analyses strategies based on reversing your trading direction after every losing trade and doubling your stake after every losing trade. If your trade wins then stake size returns to minimum.

    Note: Doubling your stake after a losing trade is the classic and very dangerous martingale system – I do not advocate trading this way unless you have a very,very,very big starting capital and are keen to lose it!

    This is the code I came up with:

    once positionsize = 1
    martingale = 2
    
    if longonmarket then
    sell at market
    if close > positionprice then
    positionsize = 1
    endif
    if close < positionprice then
    positionsize = positionsize * martingale
    longshort = 0
    endif
    endif
    
    if shortonmarket then
    exitshort at market
    if close < positionprice then
    positionsize = 1
    endif
    if close > positionprice then
    positionsize = positionsize * martingale
    longshort = 1
    endif
    endif
    
    if (not onmarket and longshort = 1 and (long entry conditions)) or (not onmarket and positionsize = 1 and (long entry conditions)) then
    buy positionsize shares at market
    endif
    
    if (not onmarket and longshort = 0 and (short entry conditions)) or (not onmarket and positionsize = 1 (short entry conditions)) then
    sellshort positionsize shares at market
    endif
    
    

    My version was intended for the daily chart. If either long or short entry conditions are met then a trade is opened at minimum size in that direction. The position is held for one bar and closed. If it is a loser then the the next trade can only be opened in the opposite direction and stake size is doubled. If it is a winner then trades can be opened in either direction and stake size is returned to minimum stake size.

    You will note that I have not included my entry conditions just in case anyone was tempted to run it live!

    I tested it with very basic entry conditions based on a single very popular indicator. I decided to test it on forex as it is in my mind a casino style strategy which suits the casino that is the forex markets. I was surprised by the results.

    Here is the results for the strategy on EURUSD daily with the martingale position sizing turned off so level stakes. Spread = 2

    [attachment file=85849]

    …and this is with the martingale doubling the position size after losing trades:

    [attachment file=85850]

    Most people would have a heart attack placing a £256 bet after a run of 8 losers so I decided to see what happened if you didn’t double up but multiplied by a lesser number. Here are the results:

    [attachment file=85851]

    ….and the results for a multiple of 1.5:

    [attachment file=85852]

    The biggest all time stake size with a 1.5 multiple is now just £25.62 and that is with a starting stake of 1.0. At the minimum stake size for EURUSD of 0.5 this would be even less at just £12.81.

    So it seems that some form of martingale can be used with smaller starting capital but I could not get similar results on other forex pairs so I may have just hit on something that works on EURUSD. Perhaps I just got lucky with my simple entry conditions and the trade direction reversing. Maybe if this rain continues I will investigate further.

    Remember this was just for fun and not a strategy idea that I’d recommend putting anywhere near a live account!

    GraHal, Mags67 and Oliviertrader2020 thanked this post
    Screenshot_5-2.png Screenshot_5-2.png Screenshot_4-3.png Screenshot_4-3.png Screenshot_6-5.png Screenshot_6-5.png Screenshot_7-4.png Screenshot_7-4.png
    #85904 quote
    Nicolas
    Keymaster
    Master

    I know some people making a living out of martingale (or grid, surefire hedging.. which are all kind of martingale if you think of it).

    The conclusion I drawn from using martingale, is that this kind of money management better suits the good strategies:

    Practical use of martingale code in automated trading

    People should be aware that martingale will always fail, because time and account capital is not infinite.

    But yeah! what sexy equity curves you made! 😆

    Nobody thanked this post
    #85906 quote
    Vonasi
    Moderator
    Master

    People should be aware that martingale will always fail, because time and account capital is not infinite. But yeah! what sexy equity curves you made!

    Exactly! I tried some other ideas also with martingale and the equity curves were more like a murder scene than a sexy scene! It really seems that I just lucked out that the reversing trade direction idea and chosen market and chosen entry criteria just happened to have worked for decades without a major losing run. Sods law says that if I went live tomorrow with it I would have a run of 10 losers and go broke very quickly. Oh – the fun of curve fitting to historical data! If I had Warren Buffets bank balance then I might be tempted just for the fun of the gamble but until then…..

    #85916 quote
    Nobody
    Participant
    Veteran

    3000 trades with only 8 consecutive losers at 51% WR , not sure what sort of voodoo that is but any probability matrix says thats impossible but hey its all about the #figjam   so congrats you appear amazing

    #85922 quote
    Vonasi
    Moderator
    Master

    so congrats you appear amazing

    …and that is because I am. Thanks for noticing.

    Yes you are right they are amazing results and they must surely add to my own personal amazingness.

    I post topics such as this so as to engage others in conversation on different aspects of trading and different theories regarding trading or even just to get others thinking about various theories and ideas – not to say ‘hey look I found the holy grail’.

    As I said in the first post ‘I was surprised by the results‘ and as I also said in the post ‘I may have just hit on something that works on EURUSD. Perhaps I just got lucky with my simple entry conditions and the trade direction reversing‘. If it seems too good to be true it probably is. I also said that I would never trade it. So I amazingly posted a useless code.

    Thank you for your thoughts on the topic but I believe that PRT does not have a voodoo filter to apply to strategies so we will just have to assume that the strategy results are down to luck or skill. The complete code is there bar the two entry conditions. One long and one short. Just add any entry condition of your choice and you too could look amazing if you pick the right one. I would still suggest not trading it.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

Reversing Strategy With Martingale


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Vonasi @vonasi Moderator
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Vonasi
7 years, 3 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/27/2018
Status: Active
Attachments: 4 files
Logo Logo
Loading...