• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Questions about max time to recover and slippage

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

    Questions about max time to recover and slippage

    Hi guys,

    I have 2 questions

    1) could you please explain how "Max time to recover" works?
    According to the documentation(https://ninjatrader.com/support/help...etorecover.htm) it should take maximum from the following: time to recover from local draw-downs. In my strategy is shows that it is ~602 days, but I do not see any period where recovery was more than 1 year. Could you please say from where all this 600 days appears in summary? 2 screenshots attached.

    *Even if you consider calendar days(365 days a year) and not trading days(~252 days a year), still this number do not look correct to me

    2) Could you please explain how slippage works in Strategy analyzer? My understanding that slippages value(in ticks) will be added randomly to some executions. Is that correct? Or it will be added to each execution(entry/exit) ?




    Attached Files

    #2
    Ok, second question you can ignore, I did test myself, seems number of ticks from settings added almost 99% to each execution(fill), if somebody interested in results attaching screenshots.

    on screenshots:

    (Entry price slippage=0 minus Entry price slippage=1)
    (Exit price slippage=0 minus Exit price slippage=1)

    (Entry price slippage=0 minus Entry price slippage=2)
    (Exit price slippage=0 minus Exit price slippage=2)


    Instument TickSize=0.01
    Attached Files

    Comment


      #3
      Hello login_dejavu,

      Thanks for your post.

      Slippage is only applied to market, stop-market and Market-if-touched orders. NinjaTrader will add the slippage to each order however you cannot have more slippage then the high/low price of the next bar, so some orders you may not see the slippage applied.

      As far as max time to recover goes, that's not a well documented statistic. In the help guide it is simply defined as "The maximum time to recover statistic returns the largest time it took to recover back to the highest profit experienced."

      We would want to look at the strategy and template/settings you're using. That way we can test over similar data and take a look at the trades it's taking to check over whether this appears to be calculating as we'd expect. If you're comfortable with posting that here, you can attach it to your reply. If you'd rather, you can send it to us via email at platformsupport [at] ninjatrader [dot] com with "2649854 ATTN Kate W." in the subject line.

      Thanks in advance; I look forward to assisting you further.
      Kate W.NinjaTrader Customer Service

      Comment


        #4
        Hi Kate, thanks for your response,

        I can't share the strategy. But I could ask you differently with code example which I prepared to illustrate my question better. Does NT expectation for "max time to recover" to do something like code below doing? Because if so, then there is bug in calculating this value, because it is different from what NT shows. But If you sure that there is no bug, and I'm missing something, then I would like to know how exactly you're(NT) calculating to know why I see this huge difference.

        Additionally I draw picture with my expectation from "max time to recover" and would like you to confirm that my expectation is correct in respect to NT "max time to recover"

        Thanks in advance.


        PHP Code:

        private double cumProfit 0.0;
        private 
        double lastAccountPeak 0.0;
        private 
        DateTime lastAccounPeakTime;
        private 
        TimeSpan maxRecover;

        protected 
        override void OnAddTrade(Cbi.Trade trade)
        {
            
        cumProfit += trade.ProfitCurrency;

            if(
        cumProfit lastAccountPeak)
            {
                
        lastAccountPeak cumProfit;

                if(
        lastAccounPeakTime == DateTime.MinValue)
                {
                    
        lastAccounPeakTime trade.Exit.Time;
                }
                else
                {
                    var 
        newRecover trade.Exit.Time lastAccounPeakTime;
                    if(
        newRecover.TotalDays maxRecover.TotalDays)
                        
        maxRecover newRecover;

                    
        lastAccounPeakTime trade.Exit.Time;
                }

            }


            for (
        int i 0Values.Lengthi++)
                
        Values[i] = maxRecover.TotalDays;

        Attached Files
        Last edited by login_dejavu; 07-14-2020, 05:39 AM.

        Comment


          #5
          Hi login_dejavu ,

          there is the fringe case where cumulative profit is at its peak and the next trade is profitable. Because there was no draw down there is nothing to recover from.
          It won't make a big difference but technically it should be added.

          Also to be ultra correct, when testing a system, max time to recover should be recalculated on the last bar with the end time of the test period.

          NT's values look to be off by a factor of 2 in your report, usually they are correct though.
          Last edited by MojoJojo; 07-14-2020, 05:43 AM.

          Comment


            #6
            MojoJojo you're absolutely correct, but my original question was with strategy which has many trades, where I do not have flat periods longer than 10 days, so I guess each trade could qualify as last bar re-calculation. I see difference in about 2 years not in few days. Thanks for the reply anyway!

            Comment


              #7
              login_dejavu , I agree NT's metric looks to be off. In my opinion based on imprecise information it's a year or more. The strategy looks like it goes through draw down periods of 6-8 months. Fortunately for you it doesn't lose almost any money during that time, that's why it is difficult to estimate by eye.
              It's still a large difference between NT's numbers and actual data.
              Attached Files

              Comment


                #8
                Hello login_dejavu and MojoJojo,

                Thank you for your replies and input.

                I'll be doing some testing on this to see if there may be an issue calculating this statistic. I'll let you know my findings as soon as I have them.

                Thanks in advance; I look forward to assisting you further.
                Kate W.NinjaTrader Customer Service

                Comment


                  #9
                  Hello Kate, I hope you're doing well,

                  any chance you've tried to test something related to subject?

                  Comment


                    #10
                    Hello login_dejavu and MojoJojo,

                    Kate asked me to have a look at this one.

                    The MaxTimeToRecover metric is calculated by accumulating cumulative profit from trade.ProfitPoints, and then stores the max cumulative profit seen so we have a "LastTopPoints" value.

                    From there, we see if this is the first trade made. If it is, we use the entry time in ticks (DateTime.Ticks) for the "bottom time" we use to calculate MaxTimeToRecover. If it is not the first trade, we see if our cumulative profit is greater than the last peak and use that trade's exit time in ticks for our "bottom time." Otherwise we keep the existing "bottom time."

                    We then keep track of the maximum difference between the "bottom time" and each trade's exit time in ticks. (This is calculated as each trade is added, not looping over all trades.) This gives us Max Time To Recover in DateTime.Ticks which then gets converted to a TimeSpan and the TimeSpan's Total Days property is used for the metric.

                    I may not be able to share a code example to demonstrate since my example is built off of code that the Development team gave me to test, but I can share a screenshot of my Strategy Analyzer that calculates the metric following this direction.

                    We look forward to assisting.
                    Attached Files
                    JimNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by jeronymite, Today, 09:26 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post jeronymite  
                    Started by ttodua, Yesterday, 06:45 AM
                    2 responses
                    17 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by franco12364, Today, 08:08 PM
                    2 responses
                    11 views
                    0 likes
                    Last Post franco12364  
                    Started by smcllr, Today, 06:10 PM
                    1 response
                    16 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by lupearadu, Today, 01:58 PM
                    7 responses
                    38 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Working...
                    X