Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Optimization Fitnesses: Trading Days

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

    Optimization Fitnesses: Trading Days

    I'm working on a custom optimization fitness script and need the number of trading days that the "Time frame" spans. So, how is the number of trading days best obtained (that I can use in this script) ?

    #2
    Hello spottysallrite,

    The strategy.SystemPerformance would have the trades. You could look at the first index entry datetime and compare this with the last index exit datetime.

    Code:
    Print((strategy.SystemPerformance.AllTrades[0].Entry.Time - strategy.SystemPerformance.AllTrades[strategy.SystemPerformance.AllTrades.Count - 1].Exit.Time).Days);
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      mmm. Doesn't that formula assume that there are trades on the first day as well as the last day?

      I tried dividing TradesCount by TradesPerDay, but it looks like the calc for TradesPerDay is off. Could you look into that as well?

      Seems like that since the "Summary" in the Strategy Analyzer has the Start date and the End date that this would be easily obtained. No ?

      Comment


        #4
        Is there no answer to this?

        Comment


          #5
          Hello spottysallrite,

          This would be undocumented, but try using the strategy.Bars.FromDate, strategy.Bars.ToDate.

          Hello, I want to build an optimization fitness that uses Start Date and End Date that is set manually in Strategy Analyzer's settings. I want to use that and not Minimum Trade Date and Maximum Trade Date, because for strategies with low trade numbers, there may not be enough data to get correct Start and End date. So how
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Works ! Thanks !!!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Mindset, 04-21-2026, 06:46 AM
            0 responses
            91 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by M4ndoo, 04-20-2026, 05:21 PM
            0 responses
            137 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by M4ndoo, 04-19-2026, 05:54 PM
            0 responses
            68 views
            0 likes
            Last Post M4ndoo
            by M4ndoo
             
            Started by cmoran13, 04-16-2026, 01:02 PM
            0 responses
            121 views
            0 likes
            Last Post cmoran13  
            Started by PaulMohn, 04-10-2026, 11:11 AM
            0 responses
            72 views
            0 likes
            Last Post PaulMohn  
            Working...
            X