7 or 14 day indicator to help with minimizing drawdown exposure
Forums › ProRealTime English forum › ProBuilder support › 7 or 14 day indicator to help with minimizing drawdown exposure
- This topic has 5 replies, 2 voices, and was last updated 4 months ago by robertogozzi.
-
-
08/12/2024 at 10:39 AM #236335
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.
08/12/2024 at 12:07 PM #236339The DrawDown is calculated on trades, so indicators need to simulate trades to be able to calculate it.
I’ll code an example later today.
1 user thanked author for this post.
08/12/2024 at 12:11 PM #23634008/12/2024 at 12:23 PM #236341I 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.
08/12/2024 at 4:59 PM #236346No problem Kovit, this is the code of a strategy that you can backtest and it will show you (with GRAPH) the DrawDown:
123456789101112131415161718192021222324252627282930313233343536// DrawDown//ONCE Capital = 10000ONCE MinPoint = CapitalONCE MaxPoint = 0ONCE MaxDD = 0//------------------------------------------// EQUITYEquity = Capital + StrategyProfitTempProfit = PositionPerf * PositionPrice / PipSize * PipValue // / abs(CountOfPosition)TempEquity = Equity + TempProfit//------------------------------------------// DrawDownMaxPoint = max(MaxPoint,TempEquity)DD = MaxPoint - TempEquityMaxDD = max(MaxDD,DD)DDperc = MaxDD * 100 / Capital////------------------------------------------//Sma20 = average[20,0](close)xOver = close CROSSES OVER Sma20xUnder = close CROSSES UNDER Sma20//IF Not OnMarket THENIF xOver THENBUY 1 Contract at MarketELSIF xUnder THENSELLSHORT 1 Contract at MarketENDIFSET TARGET %PROFIT 2SET STOP %LOSS 1ENDIF//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:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586//------------------------------------------//ONCE OnMarketStatus = 0NotOnMarketStatus = Not OnMarketStatusONCE LongStatus = 0ONCE ShortStatus = 0//ONCE SL = 1ONCE TP = SL * 2//IF LongStatus THENmyProfit = close - myPositionPricemyPositionPerf = myProfit / myPositionPriceIF myProfit >= myPositionPrice THENmyStrategyProfit = myStrategyProfit + (myProfit / PipSize * PipValue)LongStatus = 0OnMarketStatus = 0NotOnMarketStatus = Not OnMarketStatusELSIF myProfit < myPositionPrice THENmyStrategyProfit = myStrategyProfit - (myProfit / PipSize * PipValue)LongStatus = 0OnMarketStatus = 0NotOnMarketStatus = Not OnMarketStatusENDIFELSIF ShortStatus THENmyProfit = myPositionPrice - closemyPositionPerf = myProfit / myPositionPriceIF myProfit >= myPositionPrice THENmyStrategyProfit = myStrategyProfit + (myProfit / PipSize * PipValue)ShortStatus = 0OnMarketStatus = 0NotOnMarketStatus = Not OnMarketStatusELSIF myProfit < myPositionPrice THENmyStrategyProfit = myStrategyProfit - (myProfit / PipSize * PipValue)ShortStatus = 0OnMarketStatus = 0NotOnMarketStatus = Not OnMarketStatusENDIFENDIF//------------------------------------------// DrawDown//ONCE Capital = 10000ONCE MinPoint = CapitalONCE MaxPoint = 0ONCE MaxDD = 0//------------------------------------------// EQUITYEquity = Capital + myStrategyProfitTempProfit = myPositionPerf * myPositionPrice / PipSize * PipValue // / abs(CountOfPosition)TempEquity = Equity + TempProfit//------------------------------------------// DrawDownMaxPoint = max(MaxPoint,TempEquity)DD = MaxPoint - TempEquityMaxDD = max(MaxDD,DD)DDperc = MaxDD * 100 / Capital////------------------------------------------//Sma20 = average[20,0](close)xOver = close CROSSES OVER Sma20xUnder = close CROSSES UNDER Sma20//IF NotOnMarketStatus THENLongStatus = 0ShortStatus = 0IF xOver THENEntry = closemyPositionPrice = EntryLongStatus = 1ShortStatus = 0OnMarketStatus = 1ELSIF xUnder THENEntry = closemyPositionPrice = EntryShortStatus = 1OnMarketStatus = 1NotOnMarketStatus = Not OnMarketStatusmyPositionPerf = 0ENDIFNotOnMarketStatus = Not OnMarketStatusmyPositionPerf = 0ENDIF//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.
1 user thanked author for this post.
08/12/2024 at 5:04 PM #236349I am attaching the ITF files for both the Indicator and Strategy.
-
AuthorPosts