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 sugalt, 04-30-2024, 04:02 AM
          2 responses
          13 views
          0 likes
          Last Post sugalt
          by sugalt
           
          Started by merc410, Today, 03:41 AM
          0 responses
          3 views
          0 likes
          Last Post merc410
          by merc410
           
          Started by Ndakotan1313, 03-14-2024, 05:02 PM
          2 responses
          60 views
          0 likes
          Last Post blaise_code  
          Started by claxxical, 05-30-2017, 12:30 PM
          37 responses
          4,457 views
          0 likes
          Last Post Padan
          by Padan
           
          Started by SugarDefwebsite, Today, 02:18 AM
          0 responses
          4 views
          0 likes
          Last Post SugarDefwebsite  
          Working...
          X