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

Error message on Strategy Execution(Market order should be either immediate or cancel

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

    Error message on Strategy Execution(Market order should be either immediate or cancel

    Hi ,
    I have just finalized a Stratgey and code looks like...

    if (<Lots of conditions here>)
    {
    EnterLong(1, "");
    ExitLongStop(TrailingStopLoss, "", "");
    }


    But the buy/sell orders are being rejected by my broker(FuturesBetting). Apparently the orders need to be "Immediate or Cancel". I did not find that option anywhere in the wizard. Even if I were to code it, how do I go about it?
    Attached Files

    #2
    Hi,

    IOrder seems to have what I need. But how do I use it so as to submit a "immediate" order?

    Methods and Properties
    Action
    Possible values are:


    Action.Buy
    Action.BuyToCover
    Action.Sell
    Action.SellShort
    AvgFillPrice
    A double value representing the average fill price of an order
    Filled
    An int value representing the filled amount of an order
    FromEntrySignal
    A string representing the user defined fromEntrySignal parameter on an order
    Instrument
    An Instrument value representing the instrument of an order
    LimitPrice
    A double value representing the limit price of an order
    LiveUntilCancelled
    *A bool value representing if the order is live until cancelled by the user
    Name
    A string representing the name of an order which can be provided by the entry or exit signal name
    Oco
    A string representing the OCO (one cancels other) id of an order
    OrderId
    A string representing the broker issued order id value (this value can change)
    OrderState
    See table below
    OrderType
    Possible values are:


    OrderType.Limit
    OrderType.Market
    OrderType.Stop
    OrderType.StopLimit
    Quantity
    An int value representing the quantity of an order
    StopPrice
    A double value representing the stop price of an order
    Time
    A DateTime structure representing the last time the order changed state
    TimeInForce
    Possible values are:


    TimeInForce.Day
    TimeInForce.Gtc
    Token
    A string representing the unique id of an order
    ToString()
    A string representation of an order


    OrderState Values
    OrderState.Accepted
    Order has been acknowledged by the broker
    OrderState.Cancelled
    Order has been cancelled
    OrderState.Filled
    Order has been filled
    OrderState.PartFilled
    Order has been part filled
    OrderState.PendingCancel
    An order cancellation request has been submitted
    OrderState.PendingChange
    An order change request has been submitted
    OrderState.PendingSubmit
    An order has been submitted
    OrderState.Rejected
    An order has been rejected
    OrderState.Working
    An order is working at the exchange
    OrderState.Unknown
    An unknown order state


    Thanks

    Comment


      #3
      The problem is you cannot submit an exit order until you actually have a long position. You will want to wait till confirmation on a filled position before sending that exit order. To do this in the Wizard you want to expand the Strategy category and select the long market position as your condition.
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Hi Josh,
        Thanks for replying.
        I had tried removing the exit order as you sugested, so that my code looked like..

        if (<Lots of conditions here>)
        {
        EnterLong(1, "");
        }

        But, I still get the same error message!

        Any ideas??

        Thanks

        Comment


          #5
          SuperDriveGuy,

          Please post the exact error message. Please do not confuse IOrders with the Strategy Wizard. IOrders require advanced programming to utilize and are not accessible in the Wizard.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            The error message has been attached in my 1st post

            Comment


              #7
              SuperDriveGuy,

              As you start your strategy, please try a different TIF setting. See if that helps.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Hi Josh,
                I am listing below the relevant lines from the log...

                ------------------
                0/03/2009 15:32:45|1|32|Order='CorrID-6872-633740167660769325-35/N_SShah' Name='Buy' New State=Accepted Instrument='Z 06-09' Action=Buy Limit price=0 Stop price=0 Quantity=1 Type=Market Filled=0 Fill price=0 Error=NoError Native error=''
                30/03/2009 15:32:45|1|32|Order='181238392/N_SShah' Name='Buy' New State=Rejected Instrument='Z 06-09' Action=Buy Limit price=0 Stop price=0 Quantity=1 Type=Market Filled=0 Fill price=0 Error=OrderRejected Native error='Market order should be either 'Immediate Or Cancel' or 'Complete Volume''
                30/03/2009 15:32:45|0|32|Market order should be either 'Immediate Or Cancel' or 'Complete Volume' Affected Order: Buy 1 Market
                30/03/2009 15:32:45|0|128|Strategy 'MyRSIStrategy' submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.
                -------------------

                I am running on 15sec TIF, do you think I should try 1min?

                I have a programming background, so am quite comfortable with "advanced" coding, if required. Also, I have the following code in the initialize section, is that where the "close" is being called before the "open", as you were suggesting???

                -----------
                protected override void Initialize()
                {
                SetTrailStop("", CalculationMode.Ticks, TrailingStopLoss, false);
                SetProfitTarget("", CalculationMode.Ticks, ProfitTarget);

                CalculateOnBarClose = true;
                }
                --------------

                Thanks

                Thanks,

                Suleman

                Comment


                  #9
                  Suleman,

                  Sorry for the confusion. I am not referring to the time frame you are running your strategy on, but the Time-In-Force setting for your orders. When you start up a strategy you should be able to choose something like GTC (Good-till-Cancel). Please try a different TIF setting.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi Josh,
                    I will try that.


                    I have attached the whole strategy, its quite simple actually :-)

                    Let me know if anything stands out.

                    Thanks,
                    Attached Files

                    Comment


                      #11
                      Suleman,

                      The previous comment on your exits still stands. Please let me know what happens as you change TIFs.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Hi Josh,
                        Changing the TIF seems to have worked. I will check my PnL and confirm.

                        Many thanks.
                        Regards,

                        Suleman

                        Comment


                          #13
                          Hi Josh,
                          Just confirmed with the broker, the trades are coming through!

                          Hurray!! Many thanks for your help.
                          Regards,

                          Suleman

                          Comment


                            #14
                            Glad you got it resolved Suleman.
                            Josh P.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by MacDad, 02-25-2024, 11:48 PM
                            7 responses
                            158 views
                            0 likes
                            Last Post loganjarosz123  
                            Started by Belfortbucks, Today, 09:29 PM
                            0 responses
                            7 views
                            0 likes
                            Last Post Belfortbucks  
                            Started by zstheorist, Today, 07:52 PM
                            0 responses
                            7 views
                            0 likes
                            Last Post zstheorist  
                            Started by pmachiraju, 11-01-2023, 04:46 AM
                            8 responses
                            151 views
                            0 likes
                            Last Post rehmans
                            by rehmans
                             
                            Started by mattbsea, Today, 05:44 PM
                            0 responses
                            6 views
                            0 likes
                            Last Post mattbsea  
                            Working...
                            X