Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Target and Stop Execution in Strategy

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

    Target and Stop Execution in Strategy

    I'm using SetProfitTarget and SetStopLoss in my strategy. Using the default option for historical fill processing in a strategy backtest, how do the targets and stops get filled? The help file says the default algorithm requires penetration of price levels for a fill, but it's not clear if this only applies to entries, or whether it also applies to stops and targets. When I analyzed my backtest results, some targets and stops were filled on touch and others were filled on penetration of the level, so it looks like the default option only applies to entries. How can I guarantee that historical stops and targets are filled only on penetration?

    Thanks
    AutoTraderDev

    #2
    Hello,

    Thanks for your note.

    This occurs in live only scenarios with the fill engine.

    In a backtest the fill engine can only run off the last price only. Therefor the only way to account for this in the backtester is to extend your stop loss by 1 tick for example to account for this. Then when it gets hit your original stop loss would have to have been penetrated.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      Brett,

      Here's the problem. If I want to test a 5 tick target on historical data, and I set the target to 6 ticks to guarantee that 5 ticks were penetrated, the back test indeed would guarantee that all 5 tick targets were penetrated. However, the profit/loss and everything else in the back test report would be calculated based on 6 tick gains, not 5 tick gains. This would be very misleading.

      Is there a way to code the strategy so that a 5 tick target on historical data would have to be penetrated, and the back test report would be calculated on 5 ticks of profit?

      Thanks,
      AutoTraderDev
      Last edited by AutoTraderDev; 03-14-2011, 01:57 PM.

      Comment


        #4
        Hello,

        Unfortuanley not possible without coding your own fill engine. Which you are able to do, however there is very limited support on assistance to help with coding this.



        Let me know if I can be of further assistance.
        BrettNinjaTrader Product Management

        Comment


          #5
          Fill price vs SetProfitTarget price

          NT Support,

          I am testing a model that holds positions overnight in ES trading the primary session only. In my backtest the model got long on 3/28/2011 and then made the following call:

          SetProfitTarget(CalculationMode.Price,1320.75);

          in OnBarUpdate() on the last bar of the session (3:15pm). My time in force is set to GTC. On 3/29 the market gapped up to open at 1321.25, but NinjaTrader reported my fill price as 1320.75?! Shouldn't I get the opening print which was 2 ticks higher. BTW, my FillType is set to Default.

          I've found other examples where I've been shortchanged as many as 10 points because the opening price of the next bar was better than the profit target.

          What's going on here?

          Regards,

          TFH

          Comment


            #6
            Hello,

            Thanks for the forum post.

            Here is the line in our fill processing for liberal: This can be found in My Documents->NinjaTrader 7->bin->custom->type->Default Fill type.

            I suggest that you look this check this over a bit as all the fill proccessing is done by this file:


            FillPrice = order.StopPrice < nextOpen - epsilon ? Math.Min(nextHigh, nextOpen + SlippagePoints) : Math.Min(nextHigh, order.StopPrice + SlippagePoints);


            Let me know if I can be of further assistance.

            BrettNinjaTrader Product Management

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            668 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            377 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