Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problems with Stop Limit Orders with OCOB=false

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

    Problems with Stop Limit Orders with OCOB=false

    I am working on a strategy that runs on a 5-min chart with OCOB set to false. For some reason I am getting entry refusals for reasons that are not clear to me:

    2/27/2013 3:15:00 PM Entered internal PlaceOrder() method at 2/27/2013 3:15:00 PM: BarsInProgress=0 Action=Buy OrderType=StopLimit Quantity=1 LimitPrice=1516.25 StopPrice=1516.50 SignalName='Long Position' FromEntrySignal=''
    2/27/2013 3:15:00 PM Ignored PlaceOrder() method at 2/27/2013 3:15:00 PM: Action=Buy OrderType=StopLimit Quantity=1 LimitPrice=1516.25 StopPrice=1516.50 SignalName=Long Position' FromEntrySignal='' Reason='Invalid order price, please see log tab'

    Here is the context:



    As you can see the prior entry gets triggered at 14:40 and then becomes active at 14:50.

    The second entry gets triggered at 15:15 and is immediately refused. Looking at that candle I'm a bit confused as to why. Obviously this candle moved into the stop and then back up into the limit. So why is it being refused?

    Clearly I'm missing something here - could someone please point the way?

    Many thanks in advance.

    #2
    When placing a Buy Stop Limit you have to ensure the order is placed above the current market price. If you place it at a value below the current market you will get this error. Use caution with placing stoplimt orders too close to the current market as this could lead to the above happening as well.

    Please let me know if I can be of further assistance.
    LanceNinjaTrader Customer Service

    Comment


      #3


      Here again is the failing scenario - I mislabeled the stop/limit before. Question - as I see it the limit is at the open and the stop above the open. Is that not sufficient? I know rhetorical question - can you elaborate on why this breaks? You mentioned 'current market price' - what does that mean in the context of OCOB=false and during backtesting (when it's true)?
      Last edited by molecool; 03-04-2013, 05:49 AM.

      Comment


        #4
        When you're backtesting your order is going to be placed at the close of that bar, not at the open like you have drawn. Correct me if I'm misunderstanding but that bar you have labled as the entry is the 3:15 correct? This would mean that this bar is closing at 3:15 which would make price much higher than this.

        Because the focus of this strategy is COBC = false I would suggest trying the following to test and debug.

        add this to the start of your code to ignore all historical bars:
        Code:
        if(Historical)
          return;


        You could then use Market replay or a real time feed to do your testing.

        Additionally the simulated data feed will be excellent for performing your trade logic checks.
        LanceNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Lance View Post
          When you're backtesting your order is going to be placed at the close of that bar, not at the open like you have drawn. Correct me if I'm misunderstanding but that bar you have labled as the entry is the 3:15 correct? This would mean that this bar is closing at 3:15 which would make price much higher than this.
          Actually the strategy is supposed to take an entry as soon as the 3:15 bar satisfies the entry condition. This may be at the open or a minute or so later. Which is why I am a bit confused as to why it's complaining in the first place. After all the 3:15 bar could have opened at the close of the 3:10 bar (1516.25), initiated the Stop Limit @ 1516.5 x 1516.25. Then it may have dropped and then run up to eventually touch the stop and then the limit. So in theory there should not be an error message but obviously it's throwing one. I'm still confused as to why. Hope this makes sense.

          Comment


            #6
            Hello,

            If calculate on bar close is set to true it cannot check intrabar data. All it sees is the OHLC values at the end of the bar.

            When backtesting this will always be true and you would need to code in multi series information if you wish to reference intra-bar data historically. Even doing this would not be the exact same as COBC = false

            You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


            If your strategy requires COBC = false (which it sounds like it does) you will want to ignore historical data.
            LanceNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Lance View Post
              Hello,

              If calculate on bar close is set to true it cannot check intrabar data. All it sees is the OHLC values at the end of the bar.

              When backtesting this will always be true and you would need to code in multi series information if you wish to reference intra-bar data historically. Even doing this would not be the exact same as COBC = false

              You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


              If your strategy requires COBC = false (which it sounds like it does) you will want to ignore historical data.

              Okay, so at this point I have two options, correct me if I'm wrong please:

              1) Run the strategy without historical data to have it execute properly in live tape.
              2) Add a tick series and execute on that series in order to get as close as possible to what a live feed may have done (I know it's not 1:1). This way I will be able to see an approximation of how executions were done in the past. Not exactly but close.

              Do I have that right?

              Thanks!

              Comment


                #8
                Originally posted by molecool View Post
                Okay, so at this point I have two options, correct me if I'm wrong please:

                1) Run the strategy without historical data to have it execute properly in live tape.
                2) Add a tick series and execute on that series in order to get as close as possible to what a live feed may have done (I know it's not 1:1). This way I will be able to see an approximation of how executions were done in the past. Not exactly but close.

                Do I have that right?

                Thanks!
                Yep those are the first two options that come to mind. Don't forget you can also use the simulated data feed with it's slider to move the market in specific directions. This would allow you to test your orders and executions without having to wait on the market.

                LanceNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                672 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                379 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                111 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
                582 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X