Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Enter() method ignored

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

    Enter() method ignored

    I cannot seem to figure this one out. I am getting the error message "An Enter() method to submit an entry order at 'x/x/x' has been ignored. Please search the term 'Internal Order Handling Rules' in the help guide for a detailed expaination."

    The help guide says the following...

    "Methods that generate orders (excluding market orders) to enter a position will be ignored if:

    1. A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction

    2. A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction

    3. The strategy position is flat and an order submitted by an enter method (EnterLongLimit() for example) is active and the order is used to open a position in the opposite direction "

    So there are 3 scenarios that can cause this. To handle scenario #1 and #3 I've added code to cancel all orders before sending an entry order. I don't use any set methods in the code so scenario #2 cannot be the cause. My code is very simple, I have 2 entries, 2 stops, and 2 profit targets (1 each for long and short). This is my code for entering long trades. It is the same structure as used in entering short trades.

    Code:
    if (mycondition && Positions[0].MarketPosition!=MarketPosition.Long)
    {
     if (Close[0]<orderprice)
     {
       if (SEntry!=null)
        CancelOrder(SEntry);
     
       if (SProfit!=null)
        CancelOrder(SProfit);
     
       if (SStop!=null)
        CancelOrder(SStop);
     
       LEntry=EnterLongStop(orderprice);
      }
     }
    Last edited by SystemTrading; 11-23-2008, 10:44 AM.

    #2
    Some one will follow up on this post on Monday.
    RayNinjaTrader Customer Service

    Comment


      #3
      Remember, just because you did CancelOrder() does not mean you have successfully cancelled the order yet. You need to wait until the actual OnOrderUpdate() event that confirms the order cancellation before you can submit your next EnterLongStop().
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        The next OBU() could be 30 minutes. Can I use a while loop to wait for confirmation?

        Comment


          #5
          You could just program inside the OnOrderUpdate() and then you will get the cancellation immediately when it is triggered.

          In OnBarUpdate() instead of submitting your EnterLongStop() just set a flag variable that says you want to trade. Go into OnOrderUpdate() and after you have received cancellations on all of your orders then fire off your EnterLongStop(). Reset all your flags afterwards. Remember, you want to receive ALL cancellations before proceeding. You may need to flag each one and just have a big if-statement that checks for all the flags to be true.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Good thinking. Thanks!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by elirion, Today, 09:32 PM
            0 responses
            2 views
            0 likes
            Last Post elirion
            by elirion
             
            Started by cre8able, Today, 09:15 PM
            1 response
            5 views
            0 likes
            Last Post bltdavid  
            Started by cummish, Today, 08:43 PM
            0 responses
            12 views
            0 likes
            Last Post cummish
            by cummish
             
            Started by Option Whisperer, Today, 07:58 PM
            4 responses
            21 views
            0 likes
            Last Post Option Whisperer  
            Started by ETFVoyageur, 05-07-2024, 07:05 PM
            13 responses
            87 views
            0 likes
            Last Post ETFVoyageur  
            Working...
            X