Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to calculate REAL avg trades per day?

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

    How to calculate REAL avg trades per day?

    Hello,

    One of the bumps I'm running into with my optimizations are due to the averages. For instance, the AvgTradesPerDay metric only seems to calculate for the days traded, not days where no trades were placed.

    For example, in 5 days, the strategy places 6 trades as 0,4,2,0,0 where 3 of these days are 0 trades. This ends up being returned at an avg of 3 trades per day (as there were only 2 days in which trades were placed), instead of ~1.2 trades per day.

    My goal is to help optimize towards a consistent minimum # of trades occurring each day, even if there are still spikes here and there. I am trying hard to avoid months and months without trades and then one month with 80% of them.

    One idea was to take AllTrades.TradePerformance.TradeCount within the strategy and divide it by the start date of the run up to the current date the strategy is running (or end date, if possible!) (i.e. # trades / (days in (end date - start date)) )

    How does one access the start date and end date of an optimization from within a strategy? If not from within a strategy, then how?

    AvgTradesPerDay is very misleading, given your implementation. It implies every day, not just trading days.

    On the upgrade list, could you add my suggestion of also including basic stats for some of these attributes? For instance, AvgTradesPerDay = 10 is great. However having a StdDev of 40 (which implies 0 trades per day likely) is very different than a StdDev of 5 (which implies at least 5 trades per day 67% of the time). I believe these measures are meaningful when running long backtests and optimizations.

    Please let me know about the start/end date. I think my question is easily solved with access to those two fields.

    Thank you!

    #2
    Hi khoga,

    Thanks for the feedback. I'll be sure to forward your comments about this field for clarification purposes in our documentation as well as to consider changing it per your recommendation.

    Here's a snippet you could use to get start and end bars of the strategy at the end of each optimization run:

    Code:
    protected override void OnTermination()
    {
    	DateTime 	startTime        = Time[CurrentBar];
    	DateTime	endTime		= Time[0];
    	TimeSpan	myTimeSpan	= endTime - startTime;
    	Print(myTimeSpan.Days);
    }
    These properties are not supported but could be used to get the same dates selected from the UI:
    Print(BackTestFrom);
    Print(BackTestTo);
    Last edited by NinjaTrader_RyanM1; 06-26-2012, 08:40 AM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      thank you for the response! the Time[x] object isn't available in fitness functions.

      how do i access the start and end dates of a strategy analyzer session for a fitness function?

      Comment


        #4
        There are no supported properties for this. We have looked into changing this statistic as an enhancement request with id #1509. Thanks for sharing your feedback.
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        666 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        376 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        110 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        575 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        580 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X