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

Limit Order Error

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

    Limit Order Error

    Hello !!! i try to run strategy base on limit order expiration on every bar
    one side work fine but if i place Sell after Buyl order
    got error

    An Enter method to submit an entry order has been ignored ...

    how can i control order placment after limit expire ?
    look like buy side dont stop plasing limit orders

    SetProfitTarget("Buy", CalculationMode.Ticks, Profit);
    SetStopLoss("Buy", CalculationMode.Ticks, Stop, false);
    SetProfitTarget("Sell", CalculationMode.Ticks, Profit);
    SetStopLoss("Sell", CalculationMode.Ticks, Stop, false);

    private IOrder entryOrder = null;

    Close[1] > Close[2]
    entryOrder = EnterLongLimit(0, false, 1, Low[0] - GapB*TickSize, "Buy");

    Close[1] > Close[2]
    entryOrder = EnterShortLimit(0, false, 1, High[0] + GapS*TickSize, "Sell");

    And somethimes strategy got rejected for wrong limit price order lower then bid or ask

    #2
    Hello GainForex,

    An order being ignored means you are violating one of the internal order handling rules with the managed approach.

    http://ninjatrader.com/support/helpG...d_approach.htm

    Methods that generate orders to enter a position will be ignored if:
    • 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
    • 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
    • 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
    • The entry signal name is not unique


    If you want to place both a sell and a buy order at the same time while in a flat position, you will need to switch to using the unmanaged approach.
    http://ninjatrader.com/support/helpG...d_approach.htm


    If orders are being rejected, it is because they are being placed at an invalid price. This true when doing manual trading as well. Orders will be rejected if placed at an invalid price.
    Are you checking that the prices the orders will be submitted to are on the correct side of the market price before placing the order?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi !!! i,m no submiting two orders at same time
      i made mistake in condition Close[1] > Close[2] buy
      Close[1] < Close[2] sell
      how do i enter under managed approach ?
      i got only one error for 5000 trades
      i use if(Positions[0].MarketPosition == MarketPosition.Flat
      but same broblem
      if i check for entryOrder = null
      strategy stop working
      Last edited by GainForex; 02-03-2016, 09:14 PM.

      Comment


        #4
        GainForex,

        The error indicates that you are violating one of these internal handling rules.

        To enter an order with the managed approach you can call EnterLong(), EnterLongLimit(), EnterLongStop, EnterLongStopLimit, EnterShort(), EnterShortLimit(), EnterShortStop(), EnterShortStopLimit().

        http://ninjatrader.com/support/helpG.../enterlong.htm

        Once, your order has filled (or the trade is exited), are you setting the IOrder to null so that new orders can be made?

        I recommend you add prints to your code anywhere an order is being submitted so that you can see what code is triggering and when.

        For example:
        if (/* condition to enter *)
        {
        EnterLong();
        Print(string.Format("{0} | EnterLong()", Time[0]));
        }

        Prints will go to the output window. Tools -> Output window...
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi !! yes i think i set order to null

          protected override void OnExecution(IExecution execution)

          if (BuyOrder != null && execution.Order.OrderState == OrderState.Filled)
          {
          SetProfitTarget("Buy", CalculationMode.Ticks, Profit);
          SetStopLoss("Buy", CalculationMode.Ticks, Stop, false);
          BuyOrder = null;
          Print(string.Format("{0} | EnterLong()", Time[0]));


          6/2/2015 11:30:00 PM Entered internal PlaceOrder() method at 6/2/2015 11:30:00 PM: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=0.01M LimitPrice=190.43 StopPrice=0 SignalName='Sell' FromEntrySignal=''
          6/2/2015 11:40:00 PM Entered internal PlaceOrder() method at 6/2/2015 11:40:00 PM: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=0.01M LimitPrice=190.44 StopPrice=0 SignalName='Sell' FromEntrySignal=''
          6/2/2015 11:40:00 PM Amended open order: Action=SellShort OrderType=Limit Quantity=10000 LimitPrice=190.44 StopPrice=0 SignalName=Sell' FromEntrySignal=''
          6/2/2015 11:50:00 PM Entered internal PlaceOrder() method at 6/2/2015 11:50:00 PM: BarsInProgress=0 Action=SellShort OrderType=Limit Quantity=0.01M LimitPrice=190.42 StopPrice=0 SignalName='Sell' FromEntrySignal=''
          6/2/2015 11:50:00 PM Amended open order: Action=SellShort OrderType=Limit Quantity=10000 LimitPrice=190.42 StopPrice=0 SignalName=Sell' FromEntrySignal=''
          6/2/2015 11:50:00 PM Entered internal SetStopTarget() method: Type=Target FromEntrySignal='Sell' Mode=Ticks Value=7.79999999999956 Currency=0 Simulated=False
          6/2/2015 11:50:00 PM Amended target order: Order='NT-05751/Backtest' Name='Profit target' State=Working Instrument='$GBPJPY' Action=BuyToCover Limit price=190.34 Stop price=0 Quantity=0.01M Strategy='OrderMenagmentHFT' Type=Limit Tif=Gtc Oco='NT-00598-15650' Filled=0 Fill price=0 Token='4acf079031da416fa5b3860c8bc98d0a' Gtd='12/1/2099 12:00:00 AM'
          6/2/2015 11:50:00 PM Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='Sell' Mode=Ticks Value=36.9999999999979 Currency=0 Simulated=False
          6/2/2015 11:50:00 PM Amended stop order: Order='NT-05750/Backtest' Name='Stop loss' State=Working Instrument='$GBPJPY' Action=BuyToCover Limit price=0 Stop price=190.79 Quantity=0.01M Strategy='OrderMenagmentHFT' Type=Stop Tif=Gtc Oco='NT-00598-15650' Filled=0 Fill price=0 Token='952b21c0538a414bafa836f63d2198c3' Gtd='12/1/2099 12:00:00 AM'
          6/2/2015 11:50:00 PM | EnterShortLimit()
          Last edited by GainForex; 02-04-2016, 09:12 AM.

          Comment


            #6
            Hello GainForex,

            Did you add prints to your code anywhere an order is submitted (and not in OnExecution unless you are submitting orders in OnExecution...)?

            The prints are not appearing with the TraceOrder information. This leads me to think that the prints are not placed where the orders are being placed.

            This is so that we can understand why and order would be ignored. I am also not seeing that any orders have been ignored.

            Are we investigating an ignored order or are you inquiring about different behavior?


            When you require that your entry IOrder handle be null before a new order can be placed, is the value null after the trade is exited?

            You can use a print to find out.

            Assuming that your entry order IOrder is called BuyOrder.

            if (BuyOrder == null)
            {
            Print(string.Format("{0} | BuyOrder is null before entry", Time[0]));
            }
            else
            {
            Print(string.Format("{0} | BuyOrder is not null before entry", Time[0]));
            }

            This would go outside of and before the condition that places the entry order that is saved to the BuyOrder IOrder handle.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi !!! thank you , i fix the problem just check for oposite order = null
              one more problem showup , i place limit order with exparation on 1min time frame
              i think it will repaced every 1min but log show 3-5min or even more somethimes
              this somthig that broker conroll ?
              do i have to force it to cancel ?
              how do check time from order was place in order to cancel ?

              entryOrder = EnterLongLimit(0, false, 1, Low[0] - GapB*TickSize, "Buy");

              Comment


                #8
                Hello GainForex,

                I do not quite understand your inquiry.

                When you mention " i place limit order with exparation on 1min time frame
                i think it will repaced every 1min but log show 3-5min or even more somethimes
                this somthig that broker conroll ?", are you asking about an order that is automatically being cancelled?

                Is this a SetStopLoss/SetProfitTarget order or is this an Enter/Exit order?

                This likely will be due to the liveUntilCancelled bool not being set to true or not being used at all. When liveUntilCancelled is not used, this will default to false. When liveUntilCancelled is false, this will cause any working order to become cancelled after the bar it was submitted on closes.

                To find out the time between when an order is submitted and when it is cancelled you would need to record this information to a variable when OnOrderUpdate has a state change for that order.

                Record the current time when the order is submitted, then when the order is cancelled, you can subtract the current time from the recorded time and save this difference to another variable.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hi !!! i,m sorry i use false in order expiration
                  EnterLongLimit(0, false, !!!!!!!!!!!!
                  i think false mast expire at end of the bar , but log show 3-5 bars somethimes
                  do i have to force it to cancel ?

                  Comment


                    #10
                    Hi GainForex,

                    If the liveUntilCancelled is set to false, or not used, you would not need to cancel the order manually. The order should cancel after the bar it was submitted on closes.

                    Is the script re-submitting the order? (Is the condition true on multiple bars?)
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi !! i,m sorry like i say beafore order stay somethimes 3-5 bars longer
                      i SET EXPIRATION TO FALSE !!
                      entryOrder = EnterLongLimit(0, false, !!!!!!!!!!!!!!!!
                      script dont re-submitting the order , i,m tlking about same order that dont want to expire
                      buy order takes 3-5 bars to expire somethimes

                      Comment


                        #12
                        Hello GainForex,

                        Thank you for your response.

                        Can you detail a specific instance of this behavior? Such as Instrument, order price, and time of the order?

                        In addition, can you send us your Log and Trace files? You can do this by going to the Control Center-> Help-> Mail to Platform Support. Please place 'ATTN: Patrick H - 1458376' in the subject line.

                        Comment


                          #13
                          Hi !!! i think i just fix it , was iorder = null errors
                          thank you

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by sidlercom80, 10-28-2023, 08:49 AM
                          168 responses
                          2,262 views
                          0 likes
                          Last Post sidlercom80  
                          Started by Barry Milan, Yesterday, 10:35 PM
                          3 responses
                          10 views
                          0 likes
                          Last Post NinjaTrader_Manfred  
                          Started by WeyldFalcon, 12-10-2020, 06:48 PM
                          14 responses
                          1,429 views
                          0 likes
                          Last Post Handclap0241  
                          Started by DJ888, 04-16-2024, 06:09 PM
                          2 responses
                          9 views
                          0 likes
                          Last Post DJ888
                          by DJ888
                           
                          Started by jeronymite, 04-12-2024, 04:26 PM
                          3 responses
                          41 views
                          0 likes
                          Last Post jeronymite  
                          Working...
                          X