Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Profit target and stop loss bracket orders - fill behaviour in backtesting

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

    Profit target and stop loss bracket orders - fill behaviour in backtesting

    I coded a strategy to exit positions on close together limit and stop OCO orders.

    In backtesting though, it looks like NT7 is choosing to execute only the limit order, when in reality, I'm sure the stop order would get hit frequently.

    Can configure NT to backtest on 60mins bars with this OCO pair of exit orders, using the shorter timeframes like 1min bars to check whether the limit or the stop is hit first?

    Thanks

    PS - thought I'd posted this already, if it is duplicated, sorry but I can't see my first attempt.

    #2
    Hello adamus,

    Unfortunatey this is as expected. Please see the link below - 'Exit on close' will function the same.


    You see that limit orders will be modified so they will close out your position.

    Comment


      #3
      Sorry that was really badly phrased by me.

      Please read that question as:

      strategy to exit positions with close-together limit and stop OCO orders
      Because the target and the stop are close-together, they are usually both enclosed within the next bar - so how does NT decide in backtesting which order to take?

      WIth my current backtesting set-up, NT is always executing the target, so my backtest results are way too profitable compared to reality.

      Can I configure NT to backtest on 60mins bars with this OCO exit pair, and use a shorter timeframe like 1min bars to check whether the limit or the stop is hit first?

      Comment


        #4
        Please note that the Strategy Analyzer will calculate your conditions at the end of bars only and not intra-bar.

        Unfortunately it is not possibe to backtest on a 60 minute interval and use a shorter timeframe of 1 minute bars.

        Comment


          #5
          What about scripting a strategy using two timeframes? Is that not possible?

          Comment


            #6
            Yes, you can create strategies that use multiple timeframes. Please see the link below for more information.

            Comment


              #7
              Very interesting. You guys must have been busy. Is this a NT7 feature, or was it possible in NT6 as well? (I only used NT6 for about 48 hours).

              Comment


                #8
                This is supported in NinjaTrader 6.5 as well.

                Comment


                  #9
                  My strategy now uses 1 hour time frame and 1 min time frame.

                  I submit my orders and let NT cancel them at the end of the bar. From what I can tell looking at the results, NT will cancel all orders at the end of the first bar of the shortest time frame.

                  I thought that the orders I submit during the 1 hour onBarUpdate would remain active until throughout that bar, but it looks like that isn't happening - the order only lasts a minute. Is this expected?

                  If it is expected, are the only choices either (1) to resubmit my order every bar on the short timeframe, and (2) to submit with the barsInProgress parameter on the EnterXxxx() methods?
                  Last edited by adamus; 06-17-2010, 06:28 AM.

                  Comment


                    #10
                    Hi adamus,

                    Yes that is expected, even though the order was submitted against the 1 hour bar, the next OnBarUpdate will be the 1 minute bar, at which the order will be cancelled.

                    A few options...
                    1. You can resubmit the order. If the conditions are still satisfied, the order will resubmit automatically, provided it is not getting rejected for any reason.

                    2. You can use liveUntilCancelled set to true. If this is used, you will need to explicitly cancel the order with CancelOrder()
                    TimNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    648 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    369 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    108 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    572 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    573 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X