Return Over Maximum Draw Down – Code Snippet

Viewing 7 posts - 16 through 22 (of 22 total)
  • Author
    Posts
  • #96678 quote
    Vonasi
    Moderator
    Master

    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.

    GraHal thanked this post
    #96682 quote
    Vonasi
    Moderator
    Master

    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
    #96687 quote
    Vonasi
    Moderator
    Master

    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!

    #96696 quote
    GraHal
    Participant
    Master

    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! 🙂

    #96701 quote
    Vonasi
    Moderator
    Master

    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
    GraHal thanked this post
    #96712 quote
    Vonasi
    Moderator
    Master

    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.

    #96724 quote
    GraHal
    Participant
    Master

    A sort of ‘Ulcer’ index or ‘Don’t panic’ index. Perhaps something for tomorrow.

    Yeah another great idea Vonasi!

Viewing 7 posts - 16 through 22 (of 22 total)
  • You must be logged in to reply to this topic.

Return Over Maximum Draw Down – Code Snippet


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Vonasi @vonasi Moderator
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/16/2019
Status: Active
Attachments: 5 files
Logo Logo
Loading...