Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Order not cancelled ?

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

    Stop Order not cancelled ?

    Hello


    I have an issue, we are sending a stop for our positions, but before going overnight, the strategy stops sending the order one bar before the SessionEnd to make sure we don't have a stop overnight.

    But, it appears the stop doesn't cancel if we stop sending the stop order, it just stays there in ACCEPTED state.
    This is true both in Sim101 and in IB.

    I've made a simple strat to illustrate .

    I'm running on EMD 09-10

    Code:
     protected override void OnBarUpdate()
            {
                if (CurrentBar < 10) 
                        return; 
                
                if(Position.MarketPosition == MarketPosition.Flat)
                    EnterLong(1,"Enter L");
                
                if (ToTime(Time[0]) < (173500))
                {
                    
                    ExitLongStop(0, false, 1, Close[0]-10 , "Stop L", "");
                    
                    
                }
                    
                
            }
    Usage : look at the time : example : 11h30
    create chart EMD 09-10 30days 1minute bar

    Replace in the strat 1735 with 1132
    compile
    insert strat in graph

    look at the Accepted Stop order
    Look at watch go past 11h32 and the stop order still present even though traceorders show that no new order is sent ....


    Please advice

    #2
    Hello Zark.Be,

    Your code submits the order before the time, but there's no logic there to cancel it.

    Since you're using liveUntilCanceled = false, the order should be canceled if not filled on the bar it's submitted on. Let us know if you're seeing something different.

    If you would like to cancel the order on your own conditions, please see this reference sample which discuss this.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Ryan i do not understand your post ...

      "Your code submits the order before the time, but there's no logic there to cancel it."

      indeed, but as the help file says and you mention, "the order should be canceled if not filled on the bar it's submitted on"

      Well thats exactly what i'm saying, it SHOULD cancel it at next bar, like our targets do ...

      but like i mentionned in my first post, stop orders stay as ACCEPTED and just stay there instead of getting cancelled ....
      I really don't know how to make things clearer....



      1/ What is the difference between an ACCEPTED and a WORKING order ( this is not mentionned in help file)
      2/ what happens to a stop order that is ACCEPTED if the stop price is reached ? (hard to test this in non-historical context).
      3/ Why would stop orders not get cancelled if not renewed at next bar ?

      Comment


        #4
        Hi Zark.be,

        Your orders should be canceled if they are not filled on the bar they're submitted to, unless you have liveUntilCanceled = true.

        The snippet you posted works this way here. Can you share the strategy file you're using where this is not the case? Can attach the .cs file from My Documents\bin\custom\strategy. Can also mail to [email protected] if you would prefer not to post here.


        See here for order state definitions.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          The issue is happening on a strategy running live on IB

          So i tested it on my dev pc, running in Sim mode. same issue.

          so i created a small strat which is running with only that snippet of code, and same issue.

          No need to send the strategy, just create one and copy paste the code i sent you in there, thats what i did.

          There's just the exitonClose= false and thats it.



          1/ What is the difference between an ACCEPTED and a WORKING order ( this is not mentionned in help file)
          2/ what happens to a stop order that is ACCEPTED if the stop price is reached ? (hard to test this in non-historical context).
          3/ Why would stop orders not get cancelled if not renewed at next bar ?

          Comment


            #6
            3/ Why would stop orders not get cancelled if not renewed at next bar ?
            What interval are you submitting these orders against? If you're submitting against daily bars, then the order is good until the next day. If you're submitting against 60 minute bars, then the order could remain accepted for up to 60 minutes (if submitted at start of bar).


            2/ what happens to a stop order that is ACCEPTED if the stop price is reached ? (hard to test this in non-historical context).
            Stop orders are submitted as market orders if the stop price = last traded price.


            1/ What is the difference between an ACCEPTED and a WORKING order ( this is not mentionned in help file)
            Please see this link for order state definitions.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Its running on 1minutes bar ...


              Okay, so you have nooooooooooo idea what so ever why on 2 different machines with different strats both running the latest NinjaTrader6 and recommended IB TWS version, i have the same issue of a stop order not getting cancelled even though it should be ?

              Comment


                #8
                zark.be, can you please contact us with Trace / logs and an approx. time when you saw this happen? You can send them in via Help > Mail to Support.

                Also: is this a Multi or SingleSeries strategy you're using?

                Comment


                  #9
                  Ok

                  I've investigated this further, and i don't understand how i'm the only one with this issue.
                  The problem is much worse than i thought, not only do we have issues with a stop not cancelling after the end of a session, it won't send the stop after the start of session ....

                  I took my personnal laptop (which never saw ninja), running xp pro.
                  my steps :
                  * Installed latest ninjaTrader
                  * installed latest IB ( the java version from their website) (basically since the recommded TWS had problems, might as well try updated software).
                  * Configured IB in Ninja, no other config changes.
                  * Created a new strat :


                  Code:
                  #region Using declarations
                  using System;
                  using System.ComponentModel;
                  using System.Diagnostics;
                  using System.Drawing;
                  using System.Drawing.Drawing2D;
                  using System.Xml.Serialization;
                  using NinjaTrader.Cbi;
                  using NinjaTrader.Data;
                  using NinjaTrader.Indicator;
                  using NinjaTrader.Gui.Chart;
                  using NinjaTrader.Strategy;
                  #endregion
                  
                  // This namespace holds all strategies and is required. Do not change it.
                  namespace NinjaTrader.Strategy
                  {
                      /// <summary>
                      /// Enter the description of your strategy here
                      /// </summary>
                      [Description("Enter the description of your strategy here")]
                      public class testStrat : Strategy
                      {
                          #region Variables
                          // Wizard generated variables
                          private int myInput0 = 1; // Default setting for MyInput0
                          // User defined variables (add any user defined variables below)
                          #endregion
                  
                          /// <summary>
                          /// This method is used to configure the strategy and is called once before any strategy method is called.
                          /// </summary>
                          protected override void Initialize()
                          {
                              CalculateOnBarClose = true;
                  			TraceOrders = true;
                  			ExitOnClose=false;
                          }
                  
                          /// <summary>
                          /// Called on each bar update event (incoming tick)
                          /// </summary>
                          protected override void OnBarUpdate()
                          {
                  			
                  			if(Position.MarketPosition == MarketPosition.Flat)
                  				EnterLong(1,"Enter");
                  			
                  			
                  			if (  ( ToTime(Time[0]) > 152300) && ( ToTime(Time[0]) < 152500))
                  				ExitLongStop(Close[0]-100,"Enter");
                  			
                  			
                  			
                          }
                  
                          #region Properties
                          [Description("")]
                          [Category("Parameters")]
                          public int MyInput0
                          {
                              get { return myInput0; }
                              set { myInput0 = Math.Max(1, value); }
                          }
                          #endregion
                      }
                  }

                  So basically We send a stop only after a certain time.
                  The idea is to be able to start the strat before the time expressed in the condition.
                  NOtice that there are no stop orders (normal).
                  Then the time passes, and you should hear a "order pending" but there is not !

                  looking at the traceOrders you see a very strange distinction once the strategy is out of historical bars ...

                  Code:
                  02/08/2010 08:21:00 Entered internal PlaceOrder() method at 02/08/2010 08:21:00: Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='Enter' FromEntrySignal=''
                  02/08/2010 15:24:00 Entered internal PlaceOrder() method at 02/08/2010 15:24:00: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=6180.0 SignalName='' FromEntrySignal='Enter'
                  02/08/2010 15:25:00 Cancelled expired order: BarsInProgress=0: Order='NT-00001/Sim101' Name='Sell' State=Working Instrument='FDAX 09-10' Action=Sell Limit price=0 Stop price=6180 Quantity=0 Strategy='testStrat' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='92ac83a94b5e46e8a5afb9e4fdaa824f' Gtd='01/12/2099 00:00:00'
                  03/08/2010 15:24:00 Entered internal PlaceOrder() method at 03/08/2010 15:24:00: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=6198.0 SignalName='' FromEntrySignal='Enter'
                  03/08/2010 15:25:00 Cancelled expired order: BarsInProgress=0: Order='NT-00002/Sim101' Name='Sell' State=Working Instrument='FDAX 09-10' Action=Sell Limit price=0 Stop price=6198 Quantity=0 Strategy='testStrat' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='9fbe374f2863487c9e08cc6b9e922496' Gtd='01/12/2099 00:00:00'
                  04/08/2010 15:24:00 Entered internal PlaceOrder() method at 04/08/2010 15:24:00: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=6227.0 SignalName='' FromEntrySignal='Enter'
                  04/08/2010 15:25:00 Cancelled expired order: BarsInProgress=0: Order='NT-00003/Sim101' Name='Sell' State=Working Instrument='FDAX 09-10' Action=Sell Limit price=0 Stop price=6227 Quantity=0 Strategy='testStrat' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='a4f860af56bd4a2fb254dc68307d4d36' Gtd='01/12/2099 00:00:00'
                  05/08/2010 15:24:00 Entered internal PlaceOrder() method at 05/08/2010 15:24:00: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=6241.0 SignalName='' FromEntrySignal='Enter'
                  05/08/2010 15:25:00 Cancelled expired order: BarsInProgress=0: Order='NT-00004/Sim101' Name='Sell' State=Working Instrument='FDAX 09-10' Action=Sell Limit price=0 Stop price=6241 Quantity=0 Strategy='testStrat' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='685733657c394d4f9316b22faecf7ab5' Gtd='01/12/2099 00:00:00'
                  06/08/2010 15:24:00 Entered internal PlaceOrder() method at 06/08/2010 15:24:00: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=6177.5 SignalName='' FromEntrySignal='Enter'
                  06/08/2010 15:25:00 Cancelled expired order: BarsInProgress=0: Order='NT-00005/Sim101' Name='Sell' State=Working Instrument='FDAX 09-10' Action=Sell Limit price=0 Stop price=6177.5 Quantity=0 Strategy='testStrat' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='0068a6d1a5be4a2cbf77ea73581b26c1' Gtd='01/12/2099 00:00:00'
                  09/08/2010 15:24:00 Entered internal PlaceOrder() method at 09/08/2010 15:24:00: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=6248.5 SignalName='' FromEntrySignal='Enter'
                  09/08/2010 15:25:00 Cancelled expired order: BarsInProgress=0: Order='NT-00006/Sim101' Name='Sell' State=Working Instrument='FDAX 09-10' Action=Sell Limit price=0 Stop price=6248.5 Quantity=0 Strategy='testStrat' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='003c33ffeea1447981afc7fd600755d8' Gtd='01/12/2099 00:00:00'
                  10/08/2010 15:24:00 Entered internal PlaceOrder() method at 10/08/2010 15:24:00: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=6181.5 SignalName='' FromEntrySignal='Enter'
                  10/08/2010 15:25:00 Cancelled expired order: BarsInProgress=0: Order='NT-00007/Sim101' Name='Sell' State=Working Instrument='FDAX 09-10' Action=Sell Limit price=0 Stop price=6181.5 Quantity=0 Strategy='testStrat' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='ca7f31055f914c04b0965143c4051cd7' Gtd='01/12/2099 00:00:00'
                  11/08/2010 15:24:00 Entered internal PlaceOrder() method at 11/08/2010 15:24:00: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=6074.0 SignalName='' FromEntrySignal='Enter'
                  11/08/2010 15:25:00 Cancelled expired order: BarsInProgress=0: Order='NT-00008/Sim101' Name='Sell' State=Working Instrument='FDAX 09-10' Action=Sell Limit price=0 Stop price=6074 Quantity=0 Strategy='testStrat' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='10aa58869d7844f9932fa97af4fa7886' Gtd='01/12/2099 00:00:00'
                  12/08/2010 15:24:00 Entered internal PlaceOrder() method at 12/08/2010 15:24:00: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=6008.5 SignalName='' FromEntrySignal='Enter'
                  12/08/2010 15:25:00 Cancelled expired order: BarsInProgress=0: Order='NT-00009/Sim101' Name='Sell' State=Working Instrument='FDAX 09-10' Action=Sell Limit price=0 Stop price=6008.5 Quantity=0 Strategy='testStrat' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='6c5806ce1f5449138c7f9c54910ccb1d' Gtd='01/12/2099 00:00:00'
                  13/08/2010 15:24:00 Entered internal PlaceOrder() method at 13/08/2010 15:24:00: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=6000.0 SignalName='' FromEntrySignal='Enter'
                  13/08/2010 15:25:00 Cancelled expired order: BarsInProgress=0: Order='NT-00010/Sim101' Name='Sell' State=Working Instrument='FDAX 09-10' Action=Sell Limit price=0 Stop price=6000 Quantity=0 Strategy='testStrat' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='863947e0cc7a452d9dcb91b4199117fe' Gtd='01/12/2099 00:00:00'
                  16/08/2010 15:24:01 Entered internal PlaceOrder() method at 16/08/2010 15:24:01: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=5985.0 SignalName='' FromEntrySignal='Enter'
                  16/08/2010 15:24:01 Ignored PlaceOrder() method: Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=5985.0 SignalName=Sell' FromEntrySignal='Enter' Reason='There already is a matching, terminal exit order in place'

                  And the stop order is not sent of course ...

                  I'm running on a SIM key.
                  No other message on the LOG tab in Control Center (apart from the classic "Starting Strategy")

                  Comment


                    #10
                    Zark,

                    Can you please share log and trace files for this day? You can find them here:
                    My Documents\NinjaTrader\trace\trace.20100816.txt
                    My Documents\NinjaTrader\log\log.20100816.txt

                    You can post here or send to [email protected] and reference this thread:
                    Support for the development of custom automated trading strategies using NinjaScript.
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #11
                      mail sent.

                      Comment


                        #12
                        Thanks for the files. What setting do you have enabled under Tools > Options > Strategies > NinjaScript > On starting a real-time strategy ?
                        Ryan M.NinjaTrader Customer Service

                        Comment


                          #13
                          Immediately submit live working orders.

                          (all settings are on the ninjatrader default, as i just installed it on a fresh machine, and have the same problem on 2 other machines which have some different options).

                          Comment


                            #14
                            For info,

                            i replaced the ExitLongStop with a ExitLongLimit (to create a target instead of a stop order)
                            and i have the exact same issue.

                            Code:
                            16/08/2010 14:57:00 Entered internal PlaceOrder() method at 16/08/2010 14:57:00: Action=Sell OrderType=Limit Quantity=0 LimitPrice=6198.5 StopPrice=0 SignalName='' FromEntrySignal='Enter'
                            16/08/2010 14:57:00 Amended open order: Action=Sell OrderType=Limit Quantity=0 LimitPrice=6198.5 StopPrice=0 SignalName=Sell' FromEntrySignal='Enter'
                            16/08/2010 14:58:00 Cancelled expired order: BarsInProgress=0: Order='NT-00011/Sim101' Name='Sell' State=Working Instrument='FDAX 09-10' Action=Sell Limit price=6198.5 Stop price=0 Quantity=0 Strategy='testStrat' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='35fb38ea9b604f3d912982dde490f344' Gtd='01/12/2099 00:00:00'
                            17/08/2010 14:55:02 Entered internal PlaceOrder() method at 17/08/2010 14:55:02: Action=Sell OrderType=Limit Quantity=0 LimitPrice=6282.5 StopPrice=0 SignalName='' FromEntrySignal='Enter'
                            17/08/2010 14:55:02 Ignored PlaceOrder() method: Action=Sell OrderType=Limit Quantity=0 LimitPrice=6282.5 StopPrice=0 SignalName=Sell' FromEntrySignal='Enter' Reason='There already is a matching, terminal exit order in place'
                            17/08/2010 14:56:01 Entered internal PlaceOrder() method at 17/08/2010 14:56:01: Action=Sell OrderType=Limit Quantity=0 LimitPrice=6282.5 StopPrice=0 SignalName='' FromEntrySignal='Enter'
                            17/08/2010 14:56:01 Ignored PlaceOrder() method: Action=Sell OrderType=Limit Quantity=0 LimitPrice=6282.5 StopPrice=0 SignalName=Sell' FromEntrySignal='Enter' Reason='There already is a matching, terminal exit order in place'
                            17/08/2010 14:57:08 Entered internal PlaceOrder() method at 17/08/2010 14:57:08: Action=Sell OrderType=Limit Quantity=0 LimitPrice=6280.5 StopPrice=0 SignalName='' FromEntrySignal='Enter'
                            17/08/2010 14:57:08 Ignored PlaceOrder() method: Action=Sell OrderType=Limit Quantity=0 LimitPrice=6280.5 StopPrice=0 SignalName=Sell' FromEntrySignal='Enter' Reason='There already is a matching, terminal exit order in place'
                            restarting the strat when inside that timeframe gives no problem, its starting the strat before the trigger time that just totally f**** things up ...

                            Comment


                              #15
                              Hi zark.be,

                              Can you clarify the issue you are experiencing? The original issue was that stop loss orders didn't cancel. Thanks for including all this information but I've been unable to identify the specific issue you're facing.

                              It may be best to discuss by phone - send a note to [email protected] Attn: RyanM and we can proceed that way.
                              Ryan M.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              633 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              364 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              105 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              566 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              568 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X