Return Over Maximum Draw Down – Code Snippet
Forums › ProRealTime English forum › ProOrder support › Return Over Maximum Draw Down – Code Snippet
- This topic has 21 replies, 3 voices, and was last updated 6 years ago by
GraHal.
-
-
04/17/2019 at 10:56 AM #96678
STOP PRESS!!! I just spotted an error in my RoMaD codes in the above posts. When short I needed to use ABS(COUNTOFPOSITION) instead of COUNTOFPOSITION to make it a positive value. I was testing on a long only strategy so missed this important point! I have edited the code in the previous posts so it is now correct.
1 user thanked author for this post.
04/17/2019 at 11:19 AM #96682Here is another way of scoring a strategy. This is Return over Average Draw Down – RoAvD. This calculates the average of all draw downs and then divides the strategy profit by that average.
This code only really works accurately on strategies that only open and close trades at the open of a new bar as without using tick by tick it is not possible to know whether a low or high happened before or after a trade that is opened mid bar.
Once again it works on strategies that trade both long and short or both. A high score is a good score.
All these strategy rating codes have just been coded and posted and not thoroughly road tested at all so please bear this in mind when using them. If you spot any errors or possible improvements then please do let me know.
123456789101112131415161718if longonmarket thenmaxdd = max(maxdd, (positionprice - low) * countofposition)endifif shortonmarket thenmaxdd = max(maxdd, (high - positionprice) * abs(countofposition))endifif strategyprofit <> strategyprofit[1] thenddtotal = ddtotal + maxdd[1]ddcount = ddcount + 1maxdd = 0endifaveragedd = ddtotal / ddcountRoAvD = strategyprofit / averageddgraph RoAvD04/17/2019 at 12:03 PM #96687I was just in the middle of coding something that calculated return on average draw down for buy and hold but my PRT platform just crash closed and I’m guessing I have lost everything just as I had finished it. There may be a short delay while I thump the living day lights out of something!
04/17/2019 at 12:51 PM #96696There may be a short delay while I thump the living day lights out of something!
Damn that’s so flippin annoying!
Good job her indoors is out of doors > 1000 miles away! 🙂
04/17/2019 at 1:22 PM #96701Right – second time lucky – here is RoAvDoBaHRoAvD! A catchy little title I think you will all agree. RoAvDoBaHRoAvD = Return over Average Draw Down OVER Buy and Hold Return over Average Draw Down. (RoAvD OVER BaHRoAvD)
Basically we calculate our strategy profit and divide this by the all time average draw down for the strategy and then we do the same calculation for buy and hold. Our ratio is achieved by then dividing the strategy result by the buy and hold result.
Once again high results are good and over 1 is better than buy and hold.
Once again – not fully road tested!
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253//RoAvDif longonmarket thenmaxdd = max(maxdd, (positionprice - low) * countofposition)endifif shortonmarket thenmaxdd = max(maxdd, (high - positionprice) * abs(countofposition))endifif strategyprofit <> strategyprofit[1] thenddtotal = ddtotal + maxdd[1]ddcount = ddcount + 1maxdd = 0endifaveragedd = ddtotal / ddcountRoAvD = strategyprofit / averagedd//RoBaHAvDbuyholdpositionsize = 1once firstprice = lowbuyandholdequity = ((high - firstprice) * buyholdpositionsize)if low < high[1] and not bhflag thenbhindex = barindex - 1bhflag = 1endifif bhflag thenbhmdd = max(bhmdd, (high[barindex - bhindex] - low) * buyholdpositionsize)endifif buyandholdequity > buyandholdequity[barindex - bhindex] thenbhflag = 0bhcount = bhcount + 1bhtotal = bhtotal + bhmddbhmdd = 0endifbhaveragedd = bhtotal / bhcountBuyHoldRoAvD = buyandholdequity / bhaverageddRoAvDoBaHRoAvD = RoAvD / BuyHoldRoAvDgraph RoAvDgraph BuyHoldRoAvDgraph RoAvDoBaHRoAvD1 user thanked author for this post.
04/17/2019 at 3:02 PM #96712I’ve had a further idea for a strategy quality score. I’d like to multiply the total (or maybe average) draw down during the life of a strategy by the number of bars it is in draw down and then divide this by the return multiplied by the total number of bars. A sort of ‘Ulcer’ index or ‘Don’t panic’ index. Perhaps something for tomorrow.
04/17/2019 at 4:25 PM #96724A sort of ‘Ulcer’ index or ‘Don’t panic’ index. Perhaps something for tomorrow.
Yeah another great idea Vonasi!
-
AuthorPosts
Find exclusive trading pro-tools on