Announcement

Collapse
No announcement yet.

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.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          56 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          133 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          73 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          45 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          49 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X