Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adjusting Entry Order

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

    Adjusting Entry Order

    I have been trying to implement an limit entry order update system but it isn't working. I am not getting the 2nd order (updated order) to work. Here is the code I am using:

    Code:
    			protected override void OnOrderUpdate(IOrder order)
    			{
        		if (myEntryOrder_L != null && myEntryOrder_L == order)
    				{
    				if (Close[0] > Close[1])
        				{
    					Variable1 = Close[0] - OE_Offset * TickSize;	
    					Print(" Submitting L2 order for 6E " + " New Entry Limit Order Price = " + Variable1);
    					myEntryOrder_L = EnterLongLimit(0, true, 0, Variable1, "Sct_Entry_L2");					
    					DrawLine("L2Sct_Entry" + CurrentBar, true, 5, Variable1, 0, Variable1, Color.Cyan, DashStyle.Dot, 2);
    					my_count = CurrentBar;	
             			}
            	 	}
    My named entry is myEntryOrder_L for a long entry and myEntryOrder_S for a short entry. When I detect that price has moved away from an limit entry I want to move the limit entry up to the new price level, but this mode isn't working. Do I need to cancel the old order and submit a new one, or just submit the same order with a new limit entry price?
    Thanks
    DaveN

    #2
    Hello,

    Are you getting any errors when attempting to change this order?

    When your Print the Variable1 at that time, is it the new price you expect?
    MatthewNinjaTrader Product Management

    Comment


      #3
      Turns out the order is not changing, but rather the original order is increasing or decreasing with new bar entry conditions. However, this latter method lags what I want to do with the limit entry price. Is there something wrong with my syntax? is there another way to submit a new order to replace the old one?
      The printed price is consistent with the new intended order, but it isn't what actually shows up on the dom.
      Thanks
      DaveN

      Comment


        #4
        Also I am getting no errors in the log, and the printed price is consistent with what I expect from the strategy, but the actual submitted order is not the changed order but the original order.

        Comment


          #5
          daven,

          Your syntax is correct if you want to change the limit price of your order. You should see the order.OrderState go to PendingSubmit, Working and then Accepted at the new price.

          If you want to cancel the order first, you must explicitly cancel the order. However keep in mind on the back end that a PendingChange state in NT, would be the same as a cancel/replace.

          Can you elaborate on what is lagging?
          MatthewNinjaTrader Product Management

          Comment


            #6
            Here's an example of what I mean. This is a current message from the output box.

            L1_Sct Short Entry for ES Limit Entry Price is 1687.83937762549 Close is 1686
            Submitting S2 order for ES New Short Entry Price is : 1685.5 Close is 1686

            On the DOM the limit price is 1687.75, which is the original order that was submitted. So even though I am getting the messages that would indicate my logic for price change is in effect, the limit price itself is not changing.

            By the way, I tried putting cancel order before everything else in the execution stack, and at that point I got no executions at all.This is the format I used:

            Code:
                				{
            					CancelOrder(myEntryOrder_L);
            					Variable1 = Close[0] + 2  * TickSize;
            					Print(" Submitting L2 order for CL " + " New Long Entry Price is : " + Variable1 + "  Close is  " + Close[0]);
            					myEntryOrder_L = EnterLongLimit(0, true, 0, Close[0] + 2  * TickSize, "Sct_Entry_L2");					
            					DrawLine("L2Sct_Entry" + CurrentBar, true, 5, Close[0] + 2  * TickSize, 0, Close[0] + 2 * TickSize, Color.Cyan, DashStyle.Dot, 2);
            					my_count = CurrentBar;	
                     			}
            So the message indicates the logic is working and the new order limit is being submitted, but the order limit price on the DOM doesn't change.
            How do I monitor the price state changes as you suggested in your last response?
            DaveN

            Comment


              #7
              You can simply print order.OrderState in OnOrderUpdate.

              Hmm... are you sure that the order is not filling and being replaced? If this is a EnterLongLimit, the order would need to be placed below the Close price. However you're attempting to place it above the Close price. This order would just fill right away and depending on your entry logic, may be re-submitting to original price once filled.

              Are you trying to go long or short here?
              MatthewNinjaTrader Product Management

              Comment


                #8
                In the case of the last example I was trying to go short with a limit entry above the current price, in a market that is micro-trending down. And I am sure it isn't filling and resubmitting, I can tell by watching it. What I am trying to do is re-establish a new entry price (for a short) above the current price, but following price down as the market trends down. I will try adding the order state to my print statements to see if that shows anything interesting. Any other suggestions?

                Comment


                  #9
                  Here are output statements now including the order state. This one is on TF:

                  L1_Sct Long Entry for TF Limit Entry Price is 1045.09470564986 Close is 1045.6
                  Submitting L2 order for TF New Long Entry Price is : 1045.8 Close is 1045.6
                  TF Order State is: Order='2498e8e302d54813aefbc509f1c36ca5/M4842!Dorman!Mirus' Name='Sct_Entry_L' State=PendingSubmit Instrument='TF 09-13' Action=Buy Limit price=1045.1 Stop price=0 Quantity=1 Type=Limit Tif=Day OverFill=False Oco='' Filled=0 Fill price=0 Token='3ef9a965f09544248261bac7ddb78e51' Gtd='1/1/0001 12:00:00 AM'

                  You can see that an existing order limit is sitting at 1045.09 (1045.1), A new order limit is placed at 1045.6, but then a pending submit comes through at 1045.1. Ultimately the order was filled at 1045.1.
                  So, I'm not sure what this means. Are my orders perpetually at a "pending" state?
                  DaveN

                  Comment


                    #10
                    Actually I see that the order update was trying to submit a limit to go long above the current price. Will that order be ignored or immediately be filled at the market price. (That isn't what happened by the way.)
                    DaveN

                    Comment


                      #11
                      Hello,

                      I'm noticing you're placing EnterLongLimit but you say you're trying to enter Short

                      myEntryOrder_L = EnterLongLimit(0, true, 0, Close[0] + 2 * TickSize, "Sct_Entry_L2");

                      Is this what you intended or should this be EnterShortLimit()?



                      Will that order be ignored or immediately be filled at the market price
                      It will be filled at market price on the SIM account

                      Let me know if changing this doesn't resolve your issue.
                      LanceNinjaTrader Customer Service

                      Comment


                        #12
                        I just made a mistake documenting the entry problem. I've checked the strategy and when I want to go long I am entering a long order and when I want to go short I am entering a short order. It seems that everything is properly documented and the logic is correct, but for whatever reason the updated orders are just not being accepted, but there is no documentation of order errors in the log. Occassionally I do see an error like this:

                        8/13/2013 10:21:47 AM Strategy An Enter() method to submit an entry order at '8/9/2013 7:28:20 AM' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.

                        Is this the source of my problem perhaps, and how do learn more about how to fix this?
                        DaveN

                        Comment


                          #13
                          It could be the case but the strategy logic would need to be debugged to know for sure.

                          Please read through the internal order handling rules here to find out why your order is being ignored (last section): http://www.ninjatrader.com/support/h...d_approach.htm

                          If you have a simple script that replicates the issue feel free to post it and I'll take a quick look.
                          LanceNinjaTrader Customer Service

                          Comment


                            #14
                            Is it possible that my EntriesPerDirection set to true is preventing multiple entries from replacing exisitng entries? Or is EntriesPerDirection only triggered when a position is actually entered?

                            Comment


                              #15
                              Depending on your orders you're placing yes this could prevent additional entries. You can choose how many entries per direction are allowed. If you have it set to 1 and are currently long, it will not place additional long entries. Or if you are flat and currently have 1 entry order open.

                              Let me know how I can further assist.
                              LanceNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by andrewtrades, Today, 04:57 PM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_Manfred  
                              Started by chbruno, Today, 04:10 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post chbruno
                              by chbruno
                               
                              Started by josh18955, 03-25-2023, 11:16 AM
                              6 responses
                              436 views
                              0 likes
                              Last Post Delerium  
                              Started by FAQtrader, Today, 03:35 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post FAQtrader  
                              Started by rocketman7, Today, 09:41 AM
                              5 responses
                              19 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X