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

save trades of each optimization iteration

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

    save trades of each optimization iteration

    Dear NT,

    I need to save trades of each optimization iteration. I do that in OnStateChange() when State == State.Terminated. This works well. Unfortunately the data is saved not only when optimization is running but also when I select different result in SA. Is there any way how to export trades to text file only at the time when optimization runs?

    Thanks

    #2
    Hello marada,

    Thank you for your note.

    When you refer to a different result can you detail what you steps you are taking?

    I look forward to your response.

    Comment


      #3
      I mean when I click on another line in Best results table, see the orange part. The strategy runs again and saves trades to text file again. I want to save trades for each line but only when Optimization runs. Clear? Sorry for my English.

      Comment


        #4
        Hello marada,

        Thank you for your response.

        There is no NinjaScript property or function to check this. However, I will investigate further on my end to see if there is a means to achieve this.

        Comment


          #5
          Hello marada,

          I'm responding on behalf of PatrickH who is out of the office today.

          While this is not documented, we had previously shared during the beta period how this can be accomplished. Through testing, this code to detect if you are running an optimization has not changed since public release of NinjaTrader 8. Although unlikely, it is possible that this may change in the future since it is not locked into documentation. If the script stops working after an update, please be sure to verify that this code is still working.

          Code:
           
           if (State == State.Configure) { 	if (Category == Category.Backtest) 		Print("Strategy is running a regular backtest "); 	else if (Category == Category.Optimize) 		Print("Strategy is running an optimization "); 	else if (Category == Category.WalkForward) 		Print("Strategy is running walk forward optimization"); 	else if (Category == Category.MultiObjective) 		Print("Strategy is running a multi objective optimization "); 	else if (Category == Category.NinjaScript) 		Print("Strategy is running on an account from a chart/strategies tab "); }
          Please let us know if there is anything else we can do to help.
          JimNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by yertle, Yesterday, 08:38 AM
          7 responses
          28 views
          0 likes
          Last Post yertle
          by yertle
           
          Started by bmartz, 03-12-2024, 06:12 AM
          2 responses
          21 views
          0 likes
          Last Post bmartz
          by bmartz
           
          Started by funk10101, Today, 12:02 AM
          0 responses
          5 views
          0 likes
          Last Post funk10101  
          Started by gravdigaz6, Yesterday, 11:40 PM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by MarianApalaghiei, Yesterday, 10:49 PM
          3 responses
          11 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Working...
          X