Max drawdown calc

Viewing 7 posts - 16 through 22 (of 22 total)
  • #243079

    This code calculates both DrawDown and RunUp and their ratio, butyou have to add it to one of your strategies, not indicators:

    You only have to set your Capital, in place of 10000.

     

    1 user thanked author for this post.
    #243083

    @robertogozzi Isn’t there a mistake on line 24?

    MaxRU         = min(MaxRU,RU)

     

    #243089

    No, as we always have to store the highest value, both for RunUP and DrawDOW, this code matches ProRealTime calculations (on Dax, DailyTF) as shown in the attached pic:

    3 users thanked author for this post.
    #252724

    @Nicolas, tx for that!

    I wonder how they (PRT) calculate their max drawdown %.

    I did some comparisons on different instruments – see attached.

    It looks like my calculations are 85%+ accurate on average – or at least 85%+ the same as theirs.

    Interesting if you look at the 2nd and 4th results – at least we are both consistent which is a good sign.

    Stef

    How do u export dd-data?

    #252725

    Same ast the code above, the do match!

     

    #252730

    Same ast the code above, the do match!

     

    How do I get time-series Drawdown into a ProRealTime CSV export?

    I’ve added your code to my strategy and it displays correctly on the chart in ProRealTime—great!
    But I can’t figure out how to include Drawdown in my CSV export.

    What I’m doing now

    • Export path: Detailed report → Closed positions list → Export CSV

    • That CSV doesn’t include any Drawdown fields.

    What I actually need

    • Not a single fixed “Max DD” value, but a Drawdown time series so I can analyze how DD evolves over time and compute:

      • Max DD between two dates,

      • Max DD for another date range, etc., all based on the export.

    Ideal CSV columns (any equivalent works):

    • Date/Time, Equity (or Balance/NetLiquidation), Running Peak, Drawdown (amount), Drawdown (%).
      With those I can filter any interval and calculate max DD for that window.

    Question

    • Which exact menu/report should I use to export a CSV that contains the equity curve and/or running drawdown (daily or bar-by-bar)?

    • Is there a column/checkbox I’m missing to add Drawdown to the export?

    If PRT can’t export DD directly

    • What’s the best workaround? For example:

      • Export the equity curve and compute DD from equity vs. running peak, or

      • Log strategyprofit / equity and a running peak from code into custom variables so they appear in a CSV.

    Current path used: Detailed report → Closed positions list (CSV).
    Looking for the precise click path (and settings) to get a time-series drawdown out. Thanks!

    #252975

    You may get some data from the backtest:

    • entry price
    • exit price
    • outcome
    • type of trade (long or short)

    then you have to get the OHLC data from the chart (you can find posts on how to get it, which is not as straightforward, though, at https://www.prorealcode.com/topic/exporter-les-donnees-historiques-ohlc/#post-250046).

    Once you have that data I think a spreadsheet app, such as eXcel, might be able to recalculate the drawdown, maybe with the help of Visual Basic for Applications (VBA).

     

     

Viewing 7 posts - 16 through 22 (of 22 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login