Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

writing all Trades to a file

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

    #16
    adamus,

    Thanks for your post. The Help Guide is still a work in progress so the index page isn't indexed yet.
    Josh P.NinjaTrader Customer Service

    Comment


      #17
      Accessing optimalisation results

      Hi there,

      How can I access the results of an 'Optimizer backtest', so that these can be further analysed in an statistical program?

      Currently, I'm using the following for the export of individual trades:
      Code:
      TradeCollection trades = Performance.AllTrades;
      foreach (Trade p in trades)
      {
           // accessing the traderesults through p. 
      }
      Even though this code can be used for an Optimizer Backtest (by calculating these values for each optimizer run), that would not be very helpful given that the TradeCollection class doesn't provide an 'ParameterSetting' variable which can be used to discriminate between the various trades written to the .txt file. To illustrate what I mean, I'm looking for something like:

      Code:
      StrategyCollection strategy = Performance.AllTrades;
      foreach (Strategy s in strategy)
      {
          // Accessing the results of the strategy variation, for example
          // for strategy "MA10/MA20", "MA10/15", etc.
      }
      The variable with the strategy settings is important because this will enable me to use this as a factor and differentiate between the various variations of the optimized strategy.

      (Edit: To illustrate my point further, I added an image with the NinjaTrader output of the 'parameter length' and 'parameter name' variable(s) which I'm trying to access through C#.)

      So, my question is:
      • Is there an way to access the parameter values of the strategy being optimized?
      • If that doesn't exist, is there a way to workaround this, so that I still can export the results of the optimized strategies?

      Thanks in advance for any suggestions,

      Regards,
      Attached Files
      Last edited by J_o_s; 02-09-2011, 02:54 AM. Reason: Added image

      Comment


        #18
        J_o_s, there's unfortunately no supported way of accessing those, but you can take a look into the default and GA optimization types and see if you can perhaps create your own from their base to suit your needs.

        Comment


          #19
          This can definately be done, you just need to program it yourself.

          In OnExecution add the trade to your own trades collection.

          In OnTermination write your trades collection to a file.

          Comment


            #20
            Thanks for your comments Bertrand and Darckeen.

            Perhaps it can be more simple than creating a base, here's what I have so far (which is good enough for my goal, namely to get the parameter values and name):
            Code:
            public void OutputOptimalisationData()
            {
                int length = StrategyData.Strategy.Indicators.Count;
                for (int i = 0; i < length; i++)
                {
                    Print(StrategyData.Strategy.Indicators[i].ToString());
                }
                
                foreach (Parameter i in Parameters)
                {
                    Print("Name: " + i.Name.ToString() + " value: " + i.Value.ToString());
                }
            
                Print("\n");
            }
            Which results in:
            Code:
            EMA(MSFT (Daily),7)
            EMA(MSFT (Daily),15)
            Name: EmaKort value: 7
            Name: EmaLang value: 15
            
            EMA(MSFT (Daily),7)
            EMA(MSFT (Daily),16)
            Name: EmaKort value: 7
            Name: EmaLang value: 16
            Regards,

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            656 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            371 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            109 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            574 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            579 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X