No announcement yet.

Partner 728x90


Get Dollar Value of Total Slippage

  • Filter
  • Time
  • Show
Clear All
new posts

    Get Dollar Value of Total Slippage

    What is the correct way to get the total slippage for a strategy as a dollar value?

    I have a strategy that reports 93 as the value of TotalSlippage for a strategy on EMD with 527 trades. I would have expected a total slippage of something like $10,000 since each tick corresponds to $10.00 and we would lose 1 tick at the entry and 1 at the exit.

    var totalSlippage = SystemPerformance.AllTrades.TradesPerformance.Tota lSlippage
    After looking at the slippage of individual trades:

    var entrySlippage = SystemPerformance.AllTrades[i].Entry.Slippage;
    var exitSlippage = SystemPerformance.AllTrades[i].Exit.Slippage;
    it appears TotalSlippage is (correctly) the sum of all the individual trade slippages.

    The documentation says that execution slippage and total slippage are reported in ticks. Yet, these values are not an integer number of ticks, they seem to be a sum of tick sizes. For EMD, the tick size is ten cents. It appears slippage is being reported as a multiple of the tick size rather than as the number of ticks.

    Trades: 527
    Total Slippage: 93
    Total Entry Slippage: 52.7
    Total Exit Slippage: 40.3

    Is this a correct observation? Can I expect that slippage is always reported as a multiple of tick sizes? So that if I wanted the actual number of ticks I would divide by the tick size. Or if I wanted the dollar value of slippage I could just multiply TotalSlippage by the point value?


    Last edited by BarzTrading; 10-31-2018, 09:12 PM.

    Hello BarzTrading,

    Thanks for your post.

    Yes, your observations are correct. The number of ticks of slippage is presented in points and your math would be applicable to get the dollar value by multiplying by the point value.

    For example, if we take 1 trade on ES 12-18 with 1 tick of slippage will have 0.25 points slippage applied to each execution or 0.5 points of slippage for the full trade. This is what we would see in Total Slippage since there would only be 1 trade made.

    I have requested that the help guide gets updated to clarify this.

    If there is anything else we can do to help, please let us know.
    Last edited by NinjaTrader_Jim; 11-01-2018, 07:23 AM.
    JimNinjaTrader Customer Service


      Thanks for the confirmation, Jim.

      One related follow up question:

      When I run a strategy with 0 slippage and then run it with a slippage of 1 tick, the difference in total net profit is not exactly the total slippage.

      I've looped through all trades. All trade slippages add up correctly to the total slippage reported so I can't see where the difference would come from.

      For example here are some numbers when I run with 1 tick of slippage:
      Trade Number Entry Slippage Exit Slippage Rount Trip Slippage Cumulative Entry Slippage Cumulative Exit Slippage Cumulative Total Slippage Cumulative Net Profit (*)
      521 0.10 0.10 0.20 52.20 52.20 104.40 45,410.00
      522 0.10 0.10 0.20 52.30 52.30 104.60 45,160.00
      523 0.10 0.10 0.20 52.40 52.40 104.80 44,870.00

      Here's the result when I run with slippage set to zero:

      Trade Number Entry Slippage Exit Slippage Rount Trip Slippage Cumulative Entry Slippage Cumulative Exit Slippage Cumulative Total Slippage Cumulative Net Profit (*)
      521 0.00 0.00 0.00 0.00 0.00 0.00 55,490.00
      522 0.00 0.00 0.00 0.00 0.00 0.00 55,260.00
      523 0.00 0.00 0.00 0.00 0.00 0.00 54,990.00
      (*) From the sum of net profit on individual trades which agrees with the performance report.

      In short, everything makes sense and is consistent except the Cumulative Net Profit. By the way, I'm running with zero commission here.

      Let's take the last trade, 523. The different in cumulative net profit between the two scenarios is (54,990 - 44,870 = $10,120).

      So, now I'm expecting that the total slippage for the first scenario would be $10,120. But actually, it's reported as $10,480 (by SystemPerformance.AllTrades.TradesPerformance.Tota lSlippage).

      $10,480 is consistent with the Cumulative total slippage in points, which is 104.80. I'm running this test on EMD which has a point value of 100, so 104.80*100 = $10,480.

      So, we have a discrepancy of ($10,480 - $10,120 = $360).

      Now, again I'm not too concerned about $360 because, of course, our tests have much more uncertainty than this.

      But I'd like to know where this difference might come from to make sure there isn't a bug in my code or the NT code that could have greater implications later.

      Do you have any ideas why the difference between the two cumulative net profits would not differ by exactly the amount of total slippage? Even though the values from the individual trades all seem to add up correctly?


      It looks like I've at least partially figured out the answer to my own question. I think there must be a rule that some problems can only be solved after first posting a question in a forum.

      First we have to make sure the strategy is not sensitive to slippage. Clearly, for example, a stop loss could result in a different strategy performance because the current loss of a trade can depend on the entry price, which changes with slippage.

      Pretty sure my strategy was not sensitive in this way, but nonetheless I substituted a dirt simple strategy that entered long at every session open and exited at every session close (15min bars). What I found was that the difference in net profit between having 0 ticks of slippage and 1 tick of slippage was still less than the total slippage.

      When I tracked down the individual trades where the difference in net profit for those individual trades was different than the slippage I could see what was happening.

      This boiled down to the rule that slippage will not exceed the high or low of the bar.

      So, on one long trade, it exited at the open price of the bar, but the open price was also the low of the bar so if we subtracted slippage, then the price would go lower than that low of the bar. Since that's not allowed the exit price is then equal to the low of the bar.

      It appears this accounts for the discrepancy.

      My new question, then, is why the trade's entry and exit executions still report the full slippage.

      For example, the exit price of the trade does not have slippage because it's at the low of the bar, but the the exit execution still reports slippage as 0.10. The TotalSlippage in the TradesPerformance also includes this value.

      Honestly, I'm not sure this behavior is necessarily wrong, you have to choose something. But I'm not sure it's right either.

      At any rate, I'm again just looking for confirmation that this is the expected behavior.

      Last edited by BarzTrading; 11-01-2018, 11:32 AM.


        Hello BarzTrading,

        Total Slippage would account for how much slippage occurs, but this does not necessarily mean positive slippage or negative slippage, so Total Slippage would not reflect the entire difference in PnL when applying slippage and not applying slippage.

        Total Slippage depending on direction could be calculated by comparing the execution's fill price to the price submitted and totalling positive slippage and negative slippage. I would recommend using OnExecutionUpdate() to calculate this for each execution that passes. The order submission price would need to be tracked on your own for market orders, but stop and limit orders can have their prices fetched from the Order.StopPrice and Order.LimitPrice properties.

        Documentation on the items mentioned are linked below.

        OnExecutionUpdate() -

        Order -

        We look forward to being of further assistance.
        JimNinjaTrader Customer Service


          Thanks, Jim.

          I followed your suggestions and was able to account exactly for the difference between cumulative net profit when running the strategy with slippage of zero or slippage of 1.

          Thanks for you guidance.

          I'm going to make one final comment as a reminder to myself (or others) when I've forgotten what I learned here.

          First, in the following let's assume I'm talking only about long trades, only about historical backtests, and that I've set my strategy slippage to one tick:

          Note that this whole issue arises only because, when applying slippage, the execution price is not allowed to be higher than the high of the bar or lower than the low of the bar.

          Slippage can be added to your order fills to help mimic real market conditions. The value is expressed in "ticks", the minimum value of fluctuation for an instrument, and is only applied to market and stop-market orders. NinjaTrader will add the slippage to each order however you cannot have more slippage then the high/low price of the next bar.

          If we did allow execution prices to have values beyond the range of the bar (I'm not saying we should), then slippage for every trade would be exactly 2 ticks and the TotalSlippage would exactly match the difference in cumulative net profit between running the backtest with 1 tick of slippage or zero ticks of slippage. (Assuming your strategy rules are not sensitive to slippage, such as a stop loss which might exit on a different bar if the entry price is different.).

          But since we limit what the execution price can be, we have scenarios where the execution price of an entry or exit will not reflect any slippage. For example, suppose we enter a long position at the open and the open is the high price of the bar. Well, adding one tick of slippage would normally mean that the actual execution price would be one tick higher than the open. But since the open is the high, we're stuck using the high/open of the bar. As a result, our trade net profit is one tick greater than it would have been otherwise.

          The same thing can happen on exit, except in reverse. If we are exiting at the open of a bar and the open is the low of the bar, then we can't reduce the price by one tick. As a result the trade has one tick more of profit than it would have had otherwise.

          As a result of these limits, the slippage per trade will be either 2, 1 or 0 ticks, depending on if the slippage is limited at the entry, exit, both or neither.

          This means that the slippage reflected in the cumulative net profit will always be less than or equal to the maximum value. The maximum value is when every entry and every exit has one tick of slippage applied to the execution price.




            thanks. you have done a magnificent job in this thread.

            i was having similar problems trying to make sense of the discrepancies between how the values for slippage are defined in ticks and then the strange figure that the strategy analyzer reports after an optimization process that is not expressed neither in cumulative ticks nor monetary value.

            in this thread you have done a better job than nt's own manuals in explaining with clarity how slippage is defined, calculated and finally reported. i think i, myself, will do as other members of these fora have suggested and probably will add a credible slippage monetary figure to the commission costs to make sure slippage won't be under calculated when i run optimization processes.


            Latest Posts


            Topics Statistics Last Post
            Started by aslane, Today, 06:57 AM
            1 response
            Last Post NinjaTrader_Kate  
            Started by MisterGee, Yesterday, 09:27 PM
            2 responses
            Last Post MisterGee  
            Started by soyjesus, Today, 05:27 AM
            0 responses
            Last Post soyjesus  
            Started by JarodB, Today, 04:44 AM
            1 response
            Last Post NinjaTrader_Jason  
            Started by mahmud999, Today, 04:54 AM
            1 response
            Last Post NinjaTrader_Marco