Reverse martingale

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #138889 quote
    Oliviertrader2020
    Participant
    Average

    I am against all the tricks that hide the bad results of certain trading strategies.
    Conversely, strategies that have a high % of winning trades can be improved (as long as there are no big losers).
    Can someone help me to code a reverse martingale (a way to reinvest one’s winnings):

    – On the first trade I invest : 1000€ (1% of my capital)
    – If the 1st trade is winning I invest 2000€ on the 2nd trade.
    – If the 2nd trade is winning I invest 4000€ on the 3rd trade.
    – If the 3rd trade is winning I invest 8000€ on the 4th trade.
    – If the 4th trade is winning I invest 16 000€ on the 5th trade.
    … and so on.

    As soon as a trade loses, we start the series again at 1000€ (1%) invested …

    The criteria of losing exit (for example: high >= average [20]) will allow to know the distance in points of the stoploss, and thus to calculate the number of contracts to invest 1000, 2000, 40000€.
    Thank you 🙂

    #138899 quote
    zilliq
    Participant
    Master

    Remember that “Faster you can win, faster you can loose”

    Have a nice day

    Oliviertrader2020 thanked this post
    #138911 quote
    robertogozzi
    Moderator
    Master

    I was wondering about the math you have done.

    You invest twice as much each time until you loose, 1000-2000-4000-8000…… say you lose 16000 and you have previously gained 15000.

    Since you will sooner or later lose, well you will ALWAYS lose 1000 (starting capital) more than you earned!

    To me it makes no sense to start it all over after a loss… you will end up losing another 1000!

    Oliviertrader2020 thanked this post
    #138974 quote
    Oliviertrader2020
    Participant
    Average

    Apologies. I should have announced the goal to make it more understandable: aim for a series of 5/7/10 consecutive winning trades.

    With an R/R ratio of 1, a series of 5 consecutive winning trades allows you to multiply your investment by 32 (2, 4, 8, 16, 32)
    With an R/R ratio of 1, a series of 7 consecutive winning trades allows you to multiply your investment by 128 (… 64, 128)
    With an R/R ratio of 1, a series of 10 consecutive winning trades allows you to multiply your investment by 1024 (… 256, 512, 1024)

    Of course it is rare that the ratio is exactly 1, but some strategies allow to get close to it while having probabilities high enough to reach at least 5 winning trades.
    For this to be profitable you must succeed in making at least one series of 5 winning trades every 30 series, or a series of 10 winning trades every 1000 series (roughly because you have to count the spreads).
    The goal is to make backtests with different strategies, on different assets, on different TF, then to launch (first in demo) those with the best potential, and then to analyze if it’s more profitable to target series of 3, 5, 7, 10 … winning trades in a row.

    In trading, we can be profitable in 3 ways:
    – With small gains and a high success rate.
    – With big wins and a lower success rate.
    – With big profits and a high success rate (rarer but possible for patient traders).
    It doesn’t matter which way, as long as the “strategy+moneymanagement” mix gives a positive expected value, it’s worth a try. 😉
    It may be worth trying this type of moneymanagement with strategies that have high success rates.

    So it would be great if someone ( @nicolas can be 🙂 ) can help me code:

    On the first trade I invest: 100 € (I voluntarily changed the amount to show that what’s important is the process)
    – If the 1st trade is winning, invest 200 € on the 2nd trade.
    – If the 2nd trade wins, invest 400 € on the 3rd trade.
    – If the 3rd trade wins, invest 800 € on the 4th trade.
    – If the 4th trade wins, invest 1600 € on the 5th trade.

    – If the 5th trade wins, start again at 100€ (and I transfer the 3100€ gain of the series to my account).

    – As soon as a trade loses, we restart the series at 1000 € (1%) invested .
    – The distance in stoploss points (determined by the exit criterion, e.g. if high > average [20]) should make it possible to calculate the number of contracts to be invested in order to invest the 100, 200, 400, 800 or 1600€.

    Thanks to those who will help me in this experiment. 🙂

    #138978 quote
    robertogozzi
    Moderator
    Master

    € 100 or €1000 depends of which instrument you want to trade, so this example deals with LOTS, starting with 1 and doubling each trade, after 5 gains I multiply by 10  the starting lotsize and after 1 loss I will restart from the original lotsize (I will multiply it by 10, because you have earned 31 lots, 1+2+4+8+16, but 10 is way high, you may want just double or treble it):

    ONCE LotSize     = 1
    ONCE CurrentLots = LotSize
    ONCE Count       = 0
    IF StrategyProfit < StrategyProfit[1] THEN
       Count         = 0
       CurrentLots   = LotSize
    ELSIF StrategyProfit > StrategyProfit[1] THEN
       Count = Count + 1
       IF Count <= 5 THEN
          CurrentLots  = CurrentLots * 2  //double each any profitable trade, till 5 is reached
       ELSE
          Count       = 0
          LotSize     = LotSize * 10      //after 5 profitable trades multioly the starting lot size by 10  (1, 10, 100, 1000,....)
          CurrentLots = LotSize
       ENDIF
    ENDIF
    IF MyConditions AND Not OnMarket THEN
       BUY CurrentLots CONTRACTS AT MARKET
    ENDIF
    SET TARGET pPROFIT 100
    SET STOP   pLOSS   100
    Oliviertrader2020 thanked this post
    #138990 quote
    Dow Jones
    Participant
    Veteran

    I use this in some of my strategies, you can put the configuration into optimization to see the effective of each other

    From my experience (noob level of course),

    1/ Such mechanism is ‘usually’ more applicable to high win rate strategy (at least high consecutive wins)

    2/ Reset the lot to initial when loss can be less profitable. After consecutive win, you loss on the biggest lot, then reset, so the next win is the smallest lot. So if win rate is high, could consider to reduce by the step size rather than reset it.

    3/ Can consider also to reset after n consecutive win, anticipating possible loss is incoming. (well, I know it is negative thought). More to manage the risk considering in case the trend is going to reverse soon and your strategy may not handle well the first entry the moment when trend change.

    //Money Management
    MM = 0 // 0 - disable, 1 - enable
    if MM = 0 then
    positionsize = 1
    ENDIF
    if MM = 1 then
    //Configuration ----
    once maxSize = 2 //maximum lot size
    once minSize = 1 //maximum lot size
    once startingsize = 1 //starting lot size
    once stepsize = 0.5 //lot step size to increase/decrease
    once resetafterlost = 0 //reset to starting lot size when loss. 0 - disable, 1 - enable
    once doublestepdown = 0 //double the stepsize for decrease when loss. 0 - disable, 1 - enable
    once resetafterstrikewin = 2 //reset the lot size to starting size after n wins
    //Configuration ----
    
    once positionsize = startingsize
    once wincount = 0
    if strategyprofit <> strategyprofit[1] then
    if positionperf(1)>0 then
    if positionsize < maxSize then
    positionsize = positionsize + stepsize
    endif
    wincount = wincount + 1
    if wincount >= resetafterstrikewin then
    positionsize = startingsize
    wincount = 0
    endif
    else
    if resetafterlost then
    positionsize = startingsize
    elsif doublestepdown then
    positionsize = positionsize - stepsize * 2
    else
    positionsize = positionsize - stepsize
    endif
    wincount = 0
    endif
    endif
    
    if positionsize < minSize then
    positionsize = minSize
    endif
    ENDIF
    Oliviertrader2020 and Monobrow thanked this post
    #139100 quote
    Oliviertrader2020
    Participant
    Average

    Thank you very much @dowJones and @robertogozzi !

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

Reverse martingale


ProOrder: Automated Strategies & Backtesting

New Reply
Summary

This topic contains 6 replies,
has 4 voices, and was last updated by Oliviertrader2020
5 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 07/09/2020
Status: Active
Attachments: No files
Logo Logo
Loading...