Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Drawdown calculation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Drawdown calculation

    How can I calculate the drawdown after entering a trade in a strategy?
    Thanks!

    #2
    Try the TradesPerformance property.
    Performance.RealtimeTrades.TradesPerformance.Curre ncy.DrawDown
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Am i correct to assume that line of code works teh same as the previous profit code. As in if i wanted the strategy to run until max drawdown of 3 points was met. IE it reaches 10 points profit and the loses 3 points. it would then stop trading. Or is that line just dependent upon the current trade?

      thanks again

      Tim

      Comment


        #4
        It depends on what you want to do. If you want all trades use the AllTrades instead of RealtimeTrades.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          But using the alltrades with the drawdown code would make it be a daily profit to a certain drawdown correct?

          Thanks again Josh, the team here is unbeleivable. Even by using your time wisely all of you have helped an enormous amount of people. I notice you are on quite often and i suppose this is one of you many jobs. I am curious to know if you are an active trader. One other question i have is obvioulsy you are a expert at C sharp, I for one am not but am curious if you have any reference for one to learn. If you were not school taught I am curious of any sources you used to learn. I hope to give back to this forumn the best i can.

          Thanks again

          Tim

          Comment


            #6
            If you use AllTrades it will give you the final drawdown up to that point in the strategy. If you are trying to get the drawdown for the latest trade you will need to create your own variables and track them to determine the drawdown. Have a variable that sets itself to as low as your trade goes and one that sets itself to as high as the trade goes. Then after you exit the trade compare the two and determine the drawdown manually.

            Thank you for your kind words. Unfortunately I am currently not an active trader, but would love to be . I learned C# mostly from just looking at what others do. Try small things here and there and then eventually move up to making my own things. Google was a great resource that contains many useful links to various coding techniques and things. MSDN is also extremely useful for finding all the syntax you need on various properties and methods.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              When calculating the drawdawn, does it return a negative number if going against the trade or just a number? How does it work? Also, what is the difference between using RealTime trades and Performance.LongTrades or Performance.ShortTrades? I see a lot of potential with this application, do you guys have a training sessions for developers? or a book for sale on how to program it?
              Thanks!
              Last edited by lgarcia3; 04-11-2008, 03:38 PM.

              Comment


                #8
                Off the top of my head I believe the drawdown does show negative numbers when appropriate, but don't quote me on that. When you limit it to RealTime trades only on the performance object you essentially are only calculating your statistic based on trades you did in real time. The filter essentially removes all the simulated trades your strategy would have done while cycling through historical data when you start up the strategy.

                We do not have a programming class as of currently, but we do have a class for development with the NinjaScript Strategy Wizard. Please see the link in my signature.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  "Runup &Drawdown of Each Trade"

                  Hello,

                  I just wanted to make a suggestion. I have seen this "Runup & Drawdown of Each Trade" visualization on the chart.

                  I've got it from this link: http://www.meyersanalytics.com/parabcht.php

                  Like for instance when you click on the trades in the execution list to show it on the chart where one can already see the connected lines between the trades this could help for making a better visualization of the "Runup & Drawdown" statistics.

                  Thanks!

                  Comment


                    #10
                    Hello SerNinja,

                    Thank you for sharing this link and offering the suggestion. I will forward on to our development team.
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #11
                      Ok next line is the Max DD

                      Performance.RealtimeTrades.TradesPerformance.Curre ncy.DrawDown


                      Could I calculate the average DrawDown as the blue line in the NT Strategy Performance DD tab ?




                      Thank you
                      Attached Files
                      Last edited by ninjo; 04-27-2016, 06:30 AM.

                      Comment


                        #12
                        Hello ninjo,

                        According to the NinjaTrader 7 Help Guide,

                        Originally posted by http://ninjatrader.com/support/helpGuides/nt7/drawdown.htm
                        Definition
                        Returns the draw down of the collection.

                        Property Value
                        A double value that represents the average ETD of the collection.

                        Syntax
                        <TradeCollection>.TradesPerformance.<TradesPerfo rm anceValues>.DrawDown


                        Examples
                        protected override void OnBarUpdate()
                        {
                        // Print out the draw down of all trades in currency
                        Print("Draw down of all trades is: " + Performance.AllTrades.TradesPerformance.Currency.D rawDown);
                        }
                        To see what is meant by "ETD" we can turn to this page of the NinjaTrader 7 Help Guide,

                        Originally posted by https://ninjatrader.com/support/helpGuides/nt7/?statistics_definitions.htm
                        Average ETD
                        This statistic returns a value that is useful in giving you a measure of how effective your exit conditions capture the price movements after your strategy enters a position. It shows you how much you give back from the best price reached before you exit the trade. A small number here is generally desirable since it would imply highly optimized exit conditions that capture most of the price movement you were after.

                        Currency
                        Average MFE – Average Trade
                        Percent
                        Average MFE – Average Trade
                        Points
                        Average MFE – Average Trade
                        This means that Performance.RealtimeTrades.TradesPerformance.Curre ncy.DrawDown should already be providing you with an average. If you need a value other than what is provided by this property, you will need to make custom data series as explained in post #6, and you will want to use the information in the second quote as far as how ETD is calculated.

                        Please let us know if we can be of further assistance.
                        Last edited by NinjaTrader_JessicaP; 04-27-2016, 07:20 AM.
                        Jessica P.NinjaTrader Customer Service

                        Comment


                          #13
                          All right Jessica.
                          Could you help me to find the code to calculate the DD Average ??

                          Attached Files

                          Comment


                            #14
                            The following should provide you with a running average of average drawdowns. In tests, the value decreased over time as drawdown decreased, which is evidence that the value returned by that property is the current average, and not maximum, drawdown.

                            Code:
                            [FONT=Courier New]        private double averageDrawDown = 0;
                            
                                    /// <summary>
                                    /// Called on each bar update event (incoming tick)
                                    /// </summary>
                                    protected override void OnBarUpdate()
                                    {
                                        //if (! Historical)
                                        //{
                                            averageDrawDown =
                                            0 == averageDrawDown
                                            ? Performance.AllTrades.TradesPerformance.Currency.DrawDown
                                            : (Performance.AllTrades.TradesPerformance.Currency.DrawDown + averageDrawDown) / 2
                                            ;
                                            Print("average drawdown: " + averageDrawDown);
                                            DrawHorizontalLine("AverageDrawDown", averageDrawDown, Color.RoyalBlue);
                                        //}
                                        // your code here
                                    }[/FONT]
                            Jessica P.NinjaTrader Customer Service

                            Comment


                              #15
                              Thank you for the message but the result of this code is the same. The Maximun DrawDrown

                              Performance.AllTrades.TradesPerformance.Currency.D rawDown


                              Some programmer of NT could help me to get the value of the DD average drawed as a blue line in the graphic of the DD Historical Performance?

                              Thank you

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Aviram Y, Today, 05:29 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post Aviram Y  
                              Started by quantismo, 04-17-2024, 05:13 PM
                              3 responses
                              25 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by ScottWalsh, 04-16-2024, 04:29 PM
                              7 responses
                              34 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by cls71, Today, 04:45 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post cls71
                              by cls71
                               
                              Started by mjairg, 07-20-2023, 11:57 PM
                              3 responses
                              216 views
                              1 like
                              Last Post PaulMohn  
                              Working...
                              X