Money management discussion

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #201700 quote
    deleted23092025
    Participant
    New

    Hi,

    I have been using static position size for my automatic trading for a while. As I am portfolio focused and I did not want any other system to be outscale another one in positionsize wise. But every system is not equal and performance differently ofcourse. And I want to try some MM strat and if the positionsizes gets to high I can just reset it.

    So I am interested to try this MM code for my automatic trading. I have looked around the forum and this seems to be the most simple and efficient (?) one people seem to use.

    MM = 1 // = 0 for optimization
    if MM = 0 then
    positionsize = 1
    ENDIF
    if MM then
    MinSize = 0.2 // IG minimum position size allowed
    MaxSize = 1150 // IG tier 2 margin limit
    ProfitAccrued = 0 // when restarting strategy, enter profit or loss to date in instrument currency
    DD = 600  //MinSize drawdown in instrument currency
    Multiplier = 2 //drawdown multiplier
    Capital = DD * Multiplier
    Equity = Capital + ProfitAccrued + StrategyProfit
    PositionSize = Max(MinSize, Equity * (MinSize/Capital))
    if positionsize > MaxSize then
    positionsize = MaxSize
    endif
    PositionSize = Round(PositionSize*100)
    PositionSize = PositionSize/100
    endif

    Not all systems are equal as I mentioned and also one system is not equal for both and short. How can I split this code into short and long, is it possible?
    And can the author or someone else explain the Multiplier part?

    #201708 quote
    robertogozzi
    Moderator
    Master

    Dp you mean you want to split STRATEGYPROFIT into two parts, Long and Short ones?

    #201710 quote
    deleted23092025
    Participant
    New

    Yes, and the positionsize should be increased for short if shorts are winning and same way for longs (not together as it is now as I understand).

    #201712 quote
    deleted23092025
    Participant
    New

    As far as I understand the multiplier is how fast the positionsize will increase, but that does not also make sense. Can someone explain that part?

    Because I have some systems that trades far more long than short and viceversa. It would be nice to have a different multiplier (if I understand the correct part of multiplier it increases the positionsize faster with higher multi and viceversa with lower is that correct?)

    As some systems have far more long trades it could be nice to have a higher multiplier for short BUT then the strartegyprofit must be split in two parts if that is possible. If a system is more long bias it should not have the same rules in my opinion.

    #201728 quote
    deleted23092025
    Participant
    New

    Feels like the marketplace totally killed this forum, which is sad.

    #201804 quote
    robertogozzi
    Moderator
    Master

    There you go (tested on NASDAQ, US Tech 100 Cash 1€, 1H):

    // split StrategyProfit into two parts, SHORT and LONG ones
    ONCE LongProfit  = 0
    ONCE ShortProfit = 0
    IF StrategyProfit <> StrategyProfit[1] AND BarIndex > 0 THEN
       Profitto = StrategyProfit - StrategyProfit[1]
       IF LongOnMarket[1] THEN
          LongProfit  = LongProfit  + Profitto
       ELSIF ShortOnMarket[1] THEN
          ShortProfit = ShortProfit + Profitto
       ELSE
          p1 = 1
          p2 = 2
          IF OnMarket THEN
             p1 = 2
             p2 = 3
          ENDIF
          IF TradePrice(p1) > TradePrice(p2) THEN
             IF Profitto > 0 THEN
                LongProfit  = LongProfit  + Profitto
             ELSE
                ShortProfit = ShortProfit + Profitto
             ENDIF
          ELSIF TradePrice(p1) < TradePrice(p2) THEN
             IF Profitto < 0 THEN
                LongProfit  = LongProfit  + Profitto
             ELSE
                ShortProfit = ShortProfit + Profitto
             ENDIF
          ELSE
             LongProfit  = LongProfit  + (Profitto / 2)
             ShortProfit = ShortProfit + (Profitto / 2)
          ENDIF
       ENDIF
    ENDIF
    //-----------------------------------------------------------------------
    ONCE MM                = 1 // = 0 for optimization
    ONCE PositionSizeLong  = 1
    ONCE PositionSizeShort = 1
    ONCE MinSize           = 0.5   // IG minimum position size allowed
    ONCE MaxSize           = 1150  // IG tier 2 margin limit
    ONCE ProfitAccrued     = 0     // when restarting strategy, enter profit or loss to date in instrument currency
    ONCE DDlong            = 2950  //MinSize drawdown in instrument currency
    ONCE DDshort           = 3000  //MinSize drawdown in instrument currency
    ONCE Multiplier        = 2     //drawdown multiplier
    ONCE CapitalLong       = DDlong  * Multiplier
    ONCE CapitalShort      = DDshort * Multiplier
    if MM then
       EquityLong          = CapitalLong  + ProfitAccrued + LongProfit
       EquityShort         = CapitalShort + ProfitAccrued + ShortProfit
       PositionSizeLong    = Max(MinSize, EquityLong * (MinSize/CapitalLong))
       PositionSizeLong    = Round(PositionSizeLong*100)
       PositionSizeLong    = PositionSizeLong/100
       PositionSizeLong    = min(PositionSizeLong,MaxSize)
       PositionSizeShort   = Max(MinSize, EquityShort * (MinSize/CapitalShort))
       PositionSizeShort   = Round(PositionSizeShort*100)
       PositionSizeShort   = PositionSizeShort/100
       PositionSizeShort   = min(PositionSizeShort,MaxSize)
    endif
    //
    Sma = average[50,0](close)
    IF close CROSSES OVER Sma AND Not LongOnMarket THEN
       BUY PositionSizeLong contracts at Market
    ELSIF close CROSSES UNDER Sma AND Not ShortOnMarket THEN
       SELLSHORT PositionSizeShort contracts at Market
    ENDIF
    SET STOP   pLOSS   100
    SET TARGET pPROFIT 400
    // debugging data
    graph LongProfit + ShortProfit AS "Strategy Profit" coloured(0,128,0,155)
    graph strategyprofit
    thanked this post
    #201815 quote
    GraHal
    Participant
    Master

    Link to above saved as Log 338 here …

    Snippet Link Library

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

Money management discussion


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

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

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