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.
Here 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.
if longonmarket then
maxdd = max(maxdd, (positionprice - low) * countofposition)
endif
if shortonmarket then
maxdd = max(maxdd, (high - positionprice) * abs(countofposition))
endif
if strategyprofit <> strategyprofit[1] then
ddtotal = ddtotal + maxdd[1]
ddcount = ddcount + 1
maxdd = 0
endif
averagedd = ddtotal / ddcount
RoAvD = strategyprofit / averagedd
graph RoAvD
I 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!
There 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! 🙂
Right – 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!
//RoAvD
if longonmarket then
maxdd = max(maxdd, (positionprice - low) * countofposition)
endif
if shortonmarket then
maxdd = max(maxdd, (high - positionprice) * abs(countofposition))
endif
if strategyprofit <> strategyprofit[1] then
ddtotal = ddtotal + maxdd[1]
ddcount = ddcount + 1
maxdd = 0
endif
averagedd = ddtotal / ddcount
RoAvD = strategyprofit / averagedd
//RoBaHAvD
buyholdpositionsize = 1
once firstprice = low
buyandholdequity = ((high - firstprice) * buyholdpositionsize)
if low < high[1] and not bhflag then
bhindex = barindex - 1
bhflag = 1
endif
if bhflag then
bhmdd = max(bhmdd, (high[barindex - bhindex] - low) * buyholdpositionsize)
endif
if buyandholdequity > buyandholdequity[barindex - bhindex] then
bhflag = 0
bhcount = bhcount + 1
bhtotal = bhtotal + bhmdd
bhmdd = 0
endif
bhaveragedd = bhtotal / bhcount
BuyHoldRoAvD = buyandholdequity / bhaveragedd
RoAvDoBaHRoAvD = RoAvD / BuyHoldRoAvD
graph RoAvD
graph BuyHoldRoAvD
graph RoAvDoBaHRoAvD
I’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.
A sort of ‘Ulcer’ index or ‘Don’t panic’ index. Perhaps something for tomorrow.
Yeah another great idea Vonasi!