Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

order ignored

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

    order ignored

    Hi,

    I'm developing a multi-instrument strategy in which I would establish long positions of various instruments. At some later point, I'd like to replace a position of instrument A with a new position of instrument B. Here is the code snippet:

    ExitLong(0, 100, "EXIT POSITION A", "ENTER POSITION A");
    EnterLong(1, 200, "ENTER POSITION B");

    With Entries Per Diraction and Entry Handling set to 3 and AllEntries, I found that the EnterLong() order was ignored (see the log below). I suspect it has something to do with the fact that the EnterLong() order was entered, while the ExitLong() order was still working. Is this true? If yes, what's your advise to get this to work. Thanks.

    -------------------------- log --------------------------------
    2/22/2013 1:00:00 PM Entered internal PlaceOrder() method at 2/22/2013 1:00:00 PM: BarsInProgress=6 Action=Sell OrderType=Market Quantity=42 LimitPrice=0 StopPrice=0 SignalName='myRS1[3] SELL 42 XLE' FromEntrySignal='myRS1[2] BUY 42 XLE'

    2/22/2013 1:00:00 PM Entered internal PlaceOrder() method at 2/22/2013 1:00:00 PM: BarsInProgress=9 Action=Buy OrderType=Market Quantity=89 LimitPrice=0 StopPrice=0 SignalName='myRS1[4] BUY 89 XLU' FromEntrySignal=''

    2/22/2013 1:00:00 PM Ignored PlaceOrder() method at 2/22/2013 1:00:00 PM: Action=Buy OrderType=Market Quantity=89 LimitPrice=0 StopPrice=0 SignalName='myRS1[4] BUY 89 XLU' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'

    OnExecution (6, XLE) on bar[35] order filled Execution='NT-00003' Instrument='XLE' Account='Backtest' Name='myRS1[3] SELL 42 XLE' Exchange=Default Price=78.48 Quantity=42 Market position=Short Commission=0 Order='NT-00003' Time='2/25/2013 1:00:00 PM'
    --------------------------- end of log --------------------

    #2
    Hi cartoosh, I would work with the IOrder objects to be able to submit the new entry on your symbol B once the exit order for A reports .Filled state - http://www.ninjatrader.com/support/h...nt7/iorder.htm

    Comment


      #3
      Thanks for your reply. EnterLong() did not return an IOrder object, though. Are you saying I should call EnterLong(), after the exit order reports Filled? Am I supposed to do this, every time I want to issue new orders in a different direction?

      Comment


        #4
        All Enter() methods would return an IOrder if you desire so, you would need to assign one first when placing to have access.



        'Am I supposed to do this, every time I want to issue new orders in a different direction?'

        I would suggest this sequencing to avoid needing to uppen that EntryHandling setting. As otherwise you process the exit technically still when trying to place the new order.

        Comment


          #5
          1) I meant to say that EnterLong() returned NULL, in the case that the order was ignored due to the above issue. Is it a bug?
          2) In my case, the strategy must wait for the exit order to fill in order to use the proceeds to fund the new long position.

          Comment


            #6
            1) How are you assigning this IOrder and where are you checking for it's value?

            2) Yes, you would have to wait until the order was filled before you issued a new order. Otherwise you would have to increase the "Entries Per Direction" which would lead to possible unwanted positions.
            MatthewNinjaTrader Product Management

            Comment


              #7
              1) How are you assigning this IOrder and where are you checking for it's value?
              The code looks like this...

              protected override void OnBarUpdate() {
              ...
              IOrder o = ExitLong(0, 100, "SELL A", "BUY A");
              if (o == null)
              // order ignored...
              o = EnterLong(1, 200, "BUY B");
              if (o == null)
              // order ignored...
              ...
              }

              Comment


                #8
                Hi,

                The IOrder object will be null at anytime the order does not exist, this does not imply that the order was ignored.

                Also, you may want to consider creating unique order objects for the Exit and Enter so you do not run into conflicting conditions.

                What you're looking for is something that would look like this:

                Code:
                				IOrder exitOrder = ExitLong(0, 100, "SELL A", "BUY A");
                				
                				if(exitOrder != null && exitOrder.OrderState == OrderState.Filled)
                				{
                					IOrder entryOrder = EnterLong(1, 200, "BUY B");
                				}
                MatthewNinjaTrader Product Management

                Comment


                  #9
                  Hi,

                  From my tests, EnterLong() within the if statement never got called, if it was placed right behind ExitLong(). It would work, if I placed the if statement that checked the exit order status inside OnExecution(). Is that a good practice?

                  Comment


                    #10
                    Hello,

                    Yes, it would be best to work in OnExecution so you can check the order status as soon as the order is executed.
                    MatthewNinjaTrader Product Management

                    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