Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Orders canceled before getting filled

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

    Orders canceled before getting filled

    Hi,

    I'm just starting to run strategy (my first strategy) live on IB paper acct. On historical data, the strategy does what it's supposed to 99.99%.

    On live data, I have no clue what's going on. The strategy is end of bar, if I get a signal to go long, I submit a Buy Stop just above current price. I see the orders showing up in the TWS api tab, they're there for a second or two, and then they just disappear.

    This happens over and over, no position ever being entered. Where do I even start to try and sort this out?

    EDIT: I should have mentioned that I see nothing in the NT log tab about cancelations or errors.
    Last edited by coolmoss; 03-19-2012, 08:07 AM.

    #2
    Hi coolmoss,

    What does the TraceOrders output say about these orders? See this page below for more information on enabling and using TraceOrders:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Got so worked up I forgot output the trace thing, LOL. I pasted in an example below (sorry for wacky formatting, don't know best way to put output.txt in a post). This instantly showed my that my placed order is being canceled by BarsInProgress ==1. The thing is, the part of the code related to BarsInProgress ==1 executes only when not flat. These cancellations are occurring when position is flat (haven't even had a single fill).

      Thanks much for your help.

      3/19/2012 9:46:44 AM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='' Mode=Price Value=110.24 Currency=0 Simulated=False
      3/19/2012 9:46:44 AM Entered internal SetStopTarget() method: Type=Target FromEntrySignal='FIRSTTARGET' Mode=Ticks Value=30 Currency=0 Simulated=False
      3/19/2012 9:46:44 AM Entered internal SetStopTarget() method: Type=Target FromEntrySignal='SECONDTARGET' Mode=Ticks Value=60 Currency=0 Simulated=False
      3/19/2012 9:46:44 AM Entered internal SetStopTarget() method: Type=Target FromEntrySignal='THIRDTARGET' Mode=Ticks Value=30 Currency=0 Simulated=False
      3/19/2012 9:46:44 AM Entered internal PlaceOrder() method at 3/19/2012 9:46:44 AM: BarsInProgress=0 Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=110.59 SignalName='FIRSTTARGET' FromEntrySignal=''
      3/19/2012 9:46:44 AM Entered internal PlaceOrder() method at 3/19/2012 9:46:44 AM: BarsInProgress=0 Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=110.59 SignalName='SECONDTARGET' FromEntrySignal=''
      3/19/2012 9:46:44 AM Entered internal PlaceOrder() method at 3/19/2012 9:46:44 AM: BarsInProgress=0 Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=110.59 SignalName='THIRDTARGET' FromEntrySignal=''
      3/19/2012 9:46:44 AM Entered internal PlaceOrder() method at 3/19/2012 9:46:44 AM: BarsInProgress=0 Action=Buy OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=110.59 SignalName='RUNNER' FromEntrySignal=''
      3/19/2012 9:46:44 AM Cancelled expired order: BarsInProgress=1: Order='b333bed8eae247688329d002d4d6c113/DU131303' Name='FIRSTTARGET' State=PendingSubmit Instrument='FAS' Action=Buy Limit price=0 Stop price=110.59 Quantity=1 Strategy='jugKCI2012march16' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='8713b3e6d24d4b8192376b4af55adaad' Gtd='12/1/2099 12:00:00 AM'
      3/19/2012 9:46:44 AM Cancelled expired order: BarsInProgress=1: Order='3c25d61dc4834277919a3cbc3c82deb8/DU131303' Name='SECONDTARGET' State=PendingSubmit Instrument='FAS' Action=Buy Limit price=0 Stop price=110.59 Quantity=1 Strategy='jugKCI2012march16' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='c58e864ce7f94047839a8bd4a06360fb' Gtd='12/1/2099 12:00:00 AM'
      3/19/2012 9:46:44 AM Cancelled expired order: BarsInProgress=1: Order='5a886525c90f4203a54b2f431ac26929/DU131303' Name='THIRDTARGET' State=PendingSubmit Instrument='FAS' Action=Buy Limit price=0 Stop price=110.59 Quantity=1 Strategy='jugKCI2012march16' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='ac77b44f0466455a847bdeb9150af556' Gtd='12/1/2099 12:00:00 AM'
      3/19/2012 9:46:44 AM Cancelled expired order: BarsInProgress=1: Order='b2a7ce2fccaa4a898fa81f288f63a2c8/DU131303' Name='RUNNER' State=PendingSubmit Instrument='FAS' Action=Buy Limit price=0 Stop price=110.59 Quantity=1 Strategy='jugKCI2012march16' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='17d54bba74af4292be36c871fccfa736' Gtd='12/1/2099 12:00:00 AM'

      Comment


        #4
        It looks like it's cancelling due to auto expiration. Be default orders are cancelled if they're not filled on the bar they're submitted to. In Multiseries scripts, autoexpiration will be triggered by the next OnBarUpdate() received for any series.

        The orders will persist more than one bar if the conditions remain true for the order, or you use the advanced overloads with liveUntilCancelled = true. This sample can help submit these orders:


        3/19/2012 9:46:44 AM Cancelled expired order: BarsInProgress=1:
        Last edited by NinjaTrader_RyanM1; 03-19-2012, 11:00 AM.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Oh fudge. Just to make sure I understand: it's not just one bar of the primary series, but if a secondary series is faster (like in this case) the close of the next secondary series bar will effect the cancellation?

          If so, then I get that part. When these cancellations are coming in, it's outside the block of code actually referencing the secondary series. Would these cancellations occur regardless of when/where BarsInProggress==1 is in the code, just the fact that the secondary series is present will effect the cancellation?

          Comment


            #6
            Yes, you have that right. I will edit previous posts to clarify this in multiseries strategies.

            Autoexpirations will be triggered by the next OnBarUpdate(), so any series. Best will be to set these up as liveUntilCancelled, and handle the Cancelling manually with CancelOrder().
            When using NinjaTrader's Enter() and Exit() methods, the default behavior is to automatically expire them at the end of a bar unless they are resubmitted to keep them alive. Sometimes you may want more flexibility in this behavior and wish to submit orders as live-until-cancelled. When orders are submitted as live-until
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              I've studied the available sample code, which does make at least some use of onOrderUpdate and onExecution. As of this point, I've avoided using IOrder stuff because I don't quite get it yet.

              I'm currently using Stop orders for entry on my primary data series (the second series is only to deal with reversal signals) and using Set statements for stop loss and target orders.

              Is it possible to use the overload for setting liveUntilCancelled on my entry orders WITHOUT using IOrder objects (thus letting me continue to use Set statements)? My guess is that's not possible, but just looking for the easiest way out of the quagmire I've gotten myself into, LOL.

              Comment


                #8
                Originally posted by coolmoss View Post
                Is it possible to use the overload for setting liveUntilCancelled on my entry orders WITHOUT using IOrder objects (thus letting me continue to use Set statements)?
                Yes, liveUntilCancelled is possible without IOrder. If you need to use CancelOrder() manually on these at some point, it will require IOrder. There's no other way to reference an order without it.
                Last edited by NinjaTrader_RyanM1; 03-19-2012, 12:53 PM.
                Ryan M.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by funk10101, Today, 09:43 PM
                0 responses
                6 views
                0 likes
                Last Post funk10101  
                Started by pkefal, 04-11-2024, 07:39 AM
                11 responses
                37 views
                0 likes
                Last Post jeronymite  
                Started by bill2023, Yesterday, 08:51 AM
                8 responses
                44 views
                0 likes
                Last Post bill2023  
                Started by yertle, Today, 08:38 AM
                6 responses
                26 views
                0 likes
                Last Post ryjoga
                by ryjoga
                 
                Started by algospoke, Yesterday, 06:40 PM
                2 responses
                24 views
                0 likes
                Last Post algospoke  
                Working...
                X