7 or 14 day indicator to help with minimizing drawdown exposure

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #236335 quote
    Kovit
    Participant
    Senior

    Hello fellow speculators,

    Can anyone recommend an indicator that helps to reduce market entries when the market takes a big dip into drawdown over a 7 or 14 day period.

    As always any helps or advice appreciated.

    Best of luck in your own trading endeavors.

    #236339 quote
    robertogozzi
    Moderator
    Master

    The DrawDown is calculated on trades, so indicators need to simulate trades to be able to calculate it.

    I’ll code an example later today.

    Kovit thanked this post
    #236340 quote
    Kovit
    Participant
    Senior

    Thank you Roberto.

    #236341 quote
    Kovit
    Participant
    Senior

    I remember reading a year or two ago about overlaying your past trading system history performance over the top of your current system to highlight any potential weaknesses or drawdowns.

    Apologies I’ve just rejoined the forum is this still viable ?

    Many thanks in advance.

    #236346 quote
    robertogozzi
    Moderator
    Master

    No problem Kovit, this is the code of a strategy that you can backtest and it will show you (with GRAPH) the DrawDown:

    // DrawDown
    //
    ONCE Capital  = 10000
    ONCE MinPoint = Capital
    ONCE MaxPoint = 0
    ONCE MaxDD    = 0
    //------------------------------------------
    //       EQUITY
    Equity        = Capital + StrategyProfit
    TempProfit    = PositionPerf * PositionPrice / PipSize * PipValue //   / abs(CountOfPosition)
    TempEquity    = Equity + TempProfit
    //------------------------------------------
    //       DrawDown
    MaxPoint      = max(MaxPoint,TempEquity)
    DD            = MaxPoint - TempEquity
    MaxDD         = max(MaxDD,DD)
    DDperc        = MaxDD * 100 / Capital
    //
    //------------------------------------------
    //
    Sma20  = average[20,0](close)
    xOver  = close CROSSES OVER  Sma20
    xUnder = close CROSSES UNDER Sma20
    //
    IF Not OnMarket THEN
       IF xOver THEN
          BUY 1 Contract at Market
       ELSIF xUnder THEN
          SELLSHORT 1 Contract at Market
       ENDIF
       SET TARGET %PROFIT 2
       SET STOP   %LOSS   1
    ENDIF
    //
    graph MaxDD  AS "DrawDown"   coloured("Red")
    //graph DDperc AS "DrawDown %" coloured("Green")

    in the strategy you can use MaxDD to make decisions on what to do with your trades. The attached pic X shows that the DrawDown is almost equal to that of the backtest (just a few euros, due to rounding, I guess).

    This is the same code (which simulates the same trades) to be used as an indicator:

    //------------------------------------------
    //
    ONCE OnMarketStatus = 0
    NotOnMarketStatus   = Not OnMarketStatus
    ONCE LongStatus     = 0
    ONCE ShortStatus    = 0
    //
    ONCE SL = 1
    ONCE TP = SL * 2
    //
    IF LongStatus THEN
    myProfit       = close - myPositionPrice
    myPositionPerf = myProfit / myPositionPrice
    IF myProfit >= myPositionPrice THEN
    myStrategyProfit  = myStrategyProfit + (myProfit / PipSize * PipValue)
    LongStatus        = 0
    OnMarketStatus    = 0
    NotOnMarketStatus = Not OnMarketStatus
    ELSIF myProfit < myPositionPrice THEN
    myStrategyProfit = myStrategyProfit - (myProfit / PipSize * PipValue)
    LongStatus        = 0
    OnMarketStatus    = 0
    NotOnMarketStatus = Not OnMarketStatus
    ENDIF
    ELSIF ShortStatus THEN
    myProfit       = myPositionPrice - close
    myPositionPerf = myProfit / myPositionPrice
    IF myProfit >= myPositionPrice THEN
    myStrategyProfit  = myStrategyProfit + (myProfit / PipSize * PipValue)
    ShortStatus       = 0
    OnMarketStatus    = 0
    NotOnMarketStatus = Not OnMarketStatus
    ELSIF myProfit < myPositionPrice THEN
    myStrategyProfit  = myStrategyProfit - (myProfit / PipSize * PipValue)
    ShortStatus       = 0
    OnMarketStatus    = 0
    NotOnMarketStatus = Not OnMarketStatus
    ENDIF
    ENDIF
    //------------------------------------------
    // DrawDown
    //
    ONCE Capital  = 10000
    ONCE MinPoint = Capital
    ONCE MaxPoint = 0
    ONCE MaxDD    = 0
    //------------------------------------------
    //       EQUITY
    Equity        = Capital + myStrategyProfit
    TempProfit    = myPositionPerf * myPositionPrice / PipSize * PipValue //   / abs(CountOfPosition)
    TempEquity    = Equity + TempProfit
    //------------------------------------------
    //       DrawDown
    MaxPoint      = max(MaxPoint,TempEquity)
    DD            = MaxPoint - TempEquity
    MaxDD         = max(MaxDD,DD)
    DDperc        = MaxDD * 100 / Capital
    //
    //------------------------------------------
    //
    Sma20   = average[20,0](close)
    xOver   = close CROSSES OVER  Sma20
    xUnder  = close CROSSES UNDER Sma20
    //
    IF NotOnMarketStatus THEN
    LongStatus  = 0
    ShortStatus = 0
    IF xOver THEN
    Entry             = close
    myPositionPrice   = Entry
    LongStatus        = 1
    ShortStatus       = 0
    OnMarketStatus    = 1
    ELSIF xUnder THEN
    Entry             = close
    myPositionPrice   = Entry
    ShortStatus       = 1
    OnMarketStatus    = 1
    NotOnMarketStatus = Not OnMarketStatus
    myPositionPerf    = 0
    ENDIF
    NotOnMarketStatus   = Not OnMarketStatus
    myPositionPerf      = 0
    ENDIF
    //
    RETURN MaxDD AS "DrawDown"//,DDperc AS "DrawDown %"

     

    in this case the DrawDown shows a significant difference (as from attached pic Y), due to slippage and exit at the closing of a bar.

    Iván González thanked this post
    x-1.jpg x-1.jpg y.jpg y.jpg
    #236349 quote
    robertogozzi
    Moderator
    Master

    I am attaching the ITF files for both the Indicator and Strategy.

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

7 or 14 day indicator to help with minimizing drawdown exposure


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Kovit @kovit Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by robertogozzi
1 year, 6 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 08/12/2024
Status: Active
Attachments: 4 files
Logo Logo
Loading...