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

Strategy Analyzer optimize to minimum MaxTimeToRecover

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

    Strategy Analyzer optimize to minimum MaxTimeToRecover

    Hello
    How can I optimize in Strategy Analyzer to the minimum of MaxTimeToRecover (like min drawdown)?
    Sincerely
    Martin

    #2
    Hello martini,

    Thank you for your post.

    Unfortunately, minimum time to recover is not available to optimize on in the Strategy Builder.

    If you would like, I can inquire if this could be submitted as feature request.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Hello
      In NinjaScript under topic OptimzationFitness are all available optimization modes. Is it possible to add a new mode for minimum MaxTimeToRecover, and how?

      Comment


        #4
        Hello martini,

        Thank you for your response.

        You could create a custom OptimizationFitness based on the Max time to recover value.





        For examples of OptimizationFitness scripts, take a look at the scripts in the OptimizationFitnesses section of the NinjaScript Editor.

        Please let us know if you have any further questions.
        Gaby V.NinjaTrader Customer Service

        Comment


          #5
          Thanks for the advice. I think this works:

          namespace NinjaTrader.NinjaScript.OptimizationFitnesses
          {
          public class MinTimeToRecover : OptimizationFitness
          {
          private TimeSpan time;

          protected override void OnCalculatePerformanceValue(StrategyBase strategy)
          {
          time = strategy.SystemPerformance.AllTrades.TradesPerform ance.MaxTimeToRecover;
          Value = 99999999 - time.TotalMinutes;
          }

          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          Name = "Min. time to recover";
          }
          }
          }

          I think it's a good optimization method to work with. Please give them to the developers to implement in further version.​

          Comment


            #6
            Hello
            I want to make another optimization method. Total net Profit divided by Max Drawdown. How can I calculate the max. drawdown as value (currency)?

            Comment


              #7
              If you want to cut down on the time it takes to bounce back from losses in Strategy Analyzer, kinda like reducing drawdowns, here's what I think you should do: tinker around with your trading strategy settings. Try playing with stuff like how much risk you're willing to take, how big your positions are, and when you decide to buy or sell. The goal is to find a setup that gets you back on track faster after a loss, without sacrificing too much profit. Give different setups a shot, test them out thoroughly, and see what works best for you.

              Comment


                #8
                Hello Gaby
                For my calculation I need to get the cummulative max drawdown, Where can I find the value of the cummulative max drawdown in Ninjascript?

                Comment


                  #9
                  Hello martini,

                  Thank you for your response.

                  I am not aware of a way to access this value directly via NinjaScript, you would likely need to calculate this value yourself.

                  From the Help Guide:

                  "Drawdown = local maximum realized profit – local minimum realized loss
                  Max Drawdown = single largest Drawdown​"

                  https://ninjatrader.com/support/helpGuides/nt8/index.html?statistics_definitions.htm#Understandin gMaxDrawdown

                  Please let us know if you have any further questions.
                  Gaby V.NinjaTrader Customer Service

                  Comment


                    #10
                    Click image for larger version

Name:	MaxDrawdown.jpg
Views:	25
Size:	47.1 KB
ID:	1297967 Hello Gabi
                    As you can see in the attached picture the Strategy Analyzer shows the column max. drawdown. I want to cover exactly this value. If max. drawdown is not available please tell me how I can get "local maximum realized profit", "local minimum realized loss" and "single largest Drawdown​" in the context of custom OptimizationFitness. Thanks.
                    Last edited by martini; 04-01-2024, 04:13 PM.

                    Comment


                      #11
                      Hello martini,

                      Thank you for your response.

                      My apologies, I misunderstood your question.

                      You can take a look at the MaxDrawDown script in the NinjaScript Editor under the "OptimizationFitness" scripts to see how this value is calculated which you can then use in your own script.

                      Please let us know if you have any further questions.
                      Gaby V.NinjaTrader Customer Service

                      Comment


                        #12
                        Hello Gaby
                        I had a look into the MaxDrawDown script in the NinjaScript Editor under the "OptimizationFitness" before asking you. The problem is, that the optimization method MaxDrawDown is not the max drawdown, it's the MIN drawdown. Optimization for min drawdown is fine but not useful for my issue. I want to optimize to the key value "profit divided by MAX drawdown". As higher the key value is as better is the risk aspect of a strategy. So, I repeat my questions above. Please advice, thanks.

                        Comment


                          #13
                          Hello martini,

                          In an OptimizationFitness script, the strategy instance can be accessed from OnCalculatePerformanceValues.



                          The code below prints out the Drawndown for the strategy instance.

                          Code:
                          Print(strategy.SystemPerformance.AllTrades.TradesPerformance.Currency.Drawdown);
                          The forum post below has a sample OptimizationFitness script that calls values from a custom PerformanceMetric and also uses the strategy object.

                          Is it possible to access the Optimization Context from within an Optimizing Strategy. I need to record some metadata related to the optimization, I was hoping


                          Please let me know if you have any further questions. ​
                          Gaby V.NinjaTrader Customer Service

                          Comment


                            #14
                            Hello Gaby

                            It works as wished. As higher this factor as better. The factor is: Value = (strategy.SystemPerformance.AllTrades.TradesPerfor mance.GrossProfit + strategy.SystemPerformance.AllTrades.TradesPerform ance.GrossLoss) / -strategy.SystemPerformance.AllTrades.TradesPerform ance.Currency.Drawdown;

                            Thanks a lot for your awesome support!!!

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by fx.practic, 10-15-2013, 12:53 AM
                            5 responses
                            5,406 views
                            0 likes
                            Last Post Bidder
                            by Bidder
                             
                            Started by Shai Samuel, 07-02-2022, 02:46 PM
                            4 responses
                            98 views
                            0 likes
                            Last Post Bidder
                            by Bidder
                             
                            Started by DJ888, Yesterday, 10:57 PM
                            0 responses
                            8 views
                            0 likes
                            Last Post DJ888
                            by DJ888
                             
                            Started by MacDad, 02-25-2024, 11:48 PM
                            7 responses
                            160 views
                            0 likes
                            Last Post loganjarosz123  
                            Started by Belfortbucks, Yesterday, 09:29 PM
                            0 responses
                            9 views
                            0 likes
                            Last Post Belfortbucks  
                            Working...
                            X