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

An exit order placed. . . has been ignored

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

    An exit order placed. . . has been ignored

    I am using a basic EnterLongStopLimit order tagged with a SignalName that is also used to SetProfitTarget() and SetStopLoss() within the Initialize method. Once a position is established, I execute an early exit under certain conditions by submitting a ExitLongLimit command. However, I receive the following message:

    2007-11-17 14:41:30:843 ERROR: An exit order placed at '6/11/2007 3:15:00 PM' has been ignored since there already is a pending 'Stop loss' in place. Please fix your strategy.
    The "pending Stop Loss" condition is unexpected and I don't recall seeing it in 6.0. In this context, is there a way to execute an early exit stop limit when a stop market order is in play and without necessarily using the new advanced order handling? Using the simple order entry functions I don't see how I might be able to cancel the stop market before submitting the stop limit. Thanks.

    Regards,

    Whitmark
    whitmark
    NinjaTrader Ecosystem Vendor - Whitmark Development

    #2
    Correct, we have made things more strict with 6.5. Please check out the 6.5 Help Guide section NinjaScript > NinjaScript Language Reference > Custom Strategy Methods and Properties > Order Methods > Overview.

    Check out the bottom section "
    Interal Order Handling Rules that Reduce Unwanted Positions"
    RayNinjaTrader Customer Service

    Comment


      #3
      I see, which leads me to a few questions . . .

      1) If in a Long position in the as outlined in the previous example, can I assume using a IOrder signature for the ExitShortStop stop loss order vs the SetStopLoss will get around this check?

      2) Can I be assured that if I place an early exit ExitShortLimit IOrder, in addition to the working stop loss and profit target IOrders, that if one of these three orders gets filled, the other two will OCO cancel if each is tagged with the same entry signal name?

      3) Is there any built-in functionality to perform a "Close Position" on a NinjaScript order that works the same way as the close action button on the DOM or closing an ATM strategy to modify existing orders or must this be done programmatically?

      Thanks,

      Whitmark
      whitmark
      NinjaTrader Ecosystem Vendor - Whitmark Development

      Comment


        #4
        1) Not sure if that will work or if it would be ignored. If you are long and you want to get out early, submit exit orders via ExitLongLimit() and ExitLongStop(), do this within the OnOrderUpdate() triggered by fill of entry order, that way you get orders to the market immediately and not on the close of a bar (see reference sample in forum for this) then modify limit price below market when you want to exit early. You could also cancel both stop and limit orders, wait for cancel confirmation in the OnOrderUpdate() and then submit market order to exit if none of the other two exit orders were filled or partially filled.

        2) If it does work then once a position is flat, the other orders would immediately be cancelled.

        3) No
        RayNinjaTrader Customer Service

        Comment


          #5
          So how DO you cancel an order?

          I am kind of confused. In a previous thread (not this one), it seemed that NT 6.5 NinjaScript will offer a way to cancel orders entered from NS (e.g. EnterLongLimit() etc). But your discussion in thread makes me doubt, because I was expecting something like CancelOrder(orderId) method.

          So... How do you cancel an order in NS before the end of the day is up? And will this work with historical data--you know, for strategy backtesting and optimization?

          Comment


            #6
            There is a CancelOrder() method available henry.omd.

            Please check it out in your help guide for NT6.5.
            NinjaScript > NinjaScript Language Reference > Custom Strategy Methods and Properties > Order Methods > CancelOrder()
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Thanks Josh!
              Since there is no ModifyOrder (is there?) I assume that I have to CancelOrder() and then place a new order?

              Comment


                #8
                That is one way of doing it. If you are using EnterLongLimit() or the likes I believe you can simply resubmit it at a different price and that will modify the order for you. Remember if you are using NS orders and you do not resubmit at the beginning of a new bar the order will be cancelled automatically (except for when you use the new liveUntilCancelled). If a resubmission is sent the order will be kept alive.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Interesting... Are you saying that if I use liveUntilCancelled = true, and call EnterLongLimit twice (let's say one yesterady and one today), NT will simply modify the existing order instead of creating a new order? I was thinking I would have to cancel the yesterday's order first before I can submit a new order with a new price...

                  What if I placed a buy order yesterday (with liveUntilCanceled) but want to do a sell short order today? Do I have to cancel the order then with CancelOrder().

                  Comment


                    #10
                    Can I request a feature?
                    I was using IOrder structure, and it occurs to me that having the original placement (when I called EnterLong for example) would be helpful. Right now, I have to parse out the DateTime structure and compare against Time[0] to calculate the number of bars passed, but the answer changes depending on the bar size I use. It would be VERY convenient if NT exposed the BarsSinceOrder in the IOrder structure.

                    Does this make sense or am I missing something?

                    Comment


                      #11
                      Okay. Please take a look at this reference sample. Pay attention to the code commentary in the OnBarUpdate() method. http://www.ninjatrader-support.com/v...ead.php?t=3917

                      Also have you tried BarsSinceEntry() for your suggestion?

                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks Josh, I will experiment a bit more about the necessity of cancelling the order explicitly since you seem to be saying that the example will answer my question about the necessity of cancelling the pending order even when reversing the side.

                        As for BarsSinceEntry(), I don't think it will help until you get IN the position, which is not the case if you want to modify a limit order that has not yet been filled. Am I wrong?

                        Thirdly, I am noticing a funny behavior in OnOrderUpdate(): I put in the following code in my OnOrderUpdate():

                        Print(ToDay(Time[0]) + ": " + order);//debug

                        and it seems that the Time[0] doesn't work correctly in backtest case. Checkout the output, where it is clear that in some cases, the date reported is today, rather than the historical date:

                        20071229: Order='NT-00000/Back101' Name='Sell short' State=PendingSubmit Instrument='$EURUSD' Action=SellShort Limit price=1.3878 Stop price=0 Quantity=1 Strategy='RSITRAD' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='9aa163bb538f44f986c4ca4f8771ea70' Gtd='12/1/2099 12:00:00 AM'
                        20071229: Order='NT-00000/Back101' Name='Sell short' State=Accepted Instrument='$EURUSD' Action=SellShort Limit price=1.3878 Stop price=0 Quantity=1 Strategy='RSITRAD' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='9aa163bb538f44f986c4ca4f8771ea70' Gtd='12/1/2099 12:00:00 AM'
                        20071229: Order='NT-00000/Back101' Name='Sell short' State=Working Instrument='$EURUSD' Action=SellShort Limit price=1.3878 Stop price=0 Quantity=1 Strategy='RSITRAD' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='9aa163bb538f44f986c4ca4f8771ea70' Gtd='12/1/2099 12:00:00 AM'
                        20070917: Order='NT-00000/Back101' Name='Sell short' State=Filled Instrument='$EURUSD' Action=SellShort Limit price=1.3878 Stop price=0 Quantity=1 Strategy='RSITRAD' Type=Limit Tif=Gtc Oco='' Filled=1 Fill price=1.3878 Token='9aa163bb538f44f986c4ca4f8771ea70' Gtd='12/1/2099 12:00:00 AM'
                        20071229: Order='NT-00003/Back101' Name='Sell short' State=PendingSubmit Instrument='$EURUSD' Action=SellShort Limit price=1.41183821372071 Stop price=0 Quantity=1 Strategy='RSITRAD' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='1335ef3a7a2c45a7bd72a2c4ed0afb83' Gtd='12/1/2099 12:00:00 AM'
                        20071229: Order='NT-00003/Back101' Name='Sell short' State=Accepted Instrument='$EURUSD' Action=SellShort Limit price=1.41183821372071 Stop price=0 Quantity=1 Strategy='RSITRAD' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='1335ef3a7a2c45a7bd72a2c4ed0afb83' Gtd='12/1/2099 12:00:00 AM'
                        20071229: Order='NT-00003/Back101' Name='Sell short' State=Working Instrument='$EURUSD' Action=SellShort Limit price=1.41183821372071 Stop price=0 Quantity=1 Strategy='RSITRAD' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='1335ef3a7a2c45a7bd72a2c4ed0afb83' Gtd='12/1/2099 12:00:00 AM'
                        20070925: Order='NT-00003/Back101' Name='Sell short' State=Filled Instrument='$EURUSD' Action=SellShort Limit price=1.41183821372071 Stop price=0 Quantity=1 Strategy='RSITRAD' Type=Limit Tif=Gtc Oco='' Filled=1 Fill price=1.41183821372071 Token='1335ef3a7a2c45a7bd72a2c4ed0afb83' Gtd='12/1/2099 12:00:00 AM'

                        Comment


                          #13
                          When you are in the OnOrderUpdate() method you are not guaranteed to be in sync with the bars series object. Time[0] is synced with the bars series so is not effective in the OnOrderUpdate() method. You want to use the .Time property. So maybe something like order.Time
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            Thanks Josh, I find that the current OnOrderUpdate() lacking in 2 respects:

                            1. Regardless of whether OnOrderUpdate() is in sync with the bars series object, at the time OnOrderUpdate() is called, you are nevertheless in some kind of bar or tick, right? All I am asking is that the reported time is wrong with regard to the latest bar. My assertion is that even if I had run the backtest against 1990 data (if one were available), the Time[0] in OnOrderUpdate() would report today 2007--in some cases--you can see from the printout that you get the timestamp right in some cases. This appears like a bug, wouldn't you agree?

                            2. The order.Time is the latest time the order was modified. I need the time when the order was placed. So I once again ask you: does NT really not cancel an order when a new order is placed, and if so does the original order placement time change?

                            -Henry

                            Comment


                              #15
                              1) I can't comment on this but will have development take a look at expected behaviour.

                              2) The question can be answered differently depending on the context. What I can says is that NT has one order object that it manages for a unique order ID. If an order is changed, we still maintain the same orderId, what the broker gateway does is likely a cancel/replace but this is transparent to NinjaTrader. If you need the time the order is placed you can best take the time property of the IOrder object you get back when placing the order and hold that in a local variable.
                              RayNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by AttiM, 02-14-2024, 05:20 PM
                              11 responses
                              184 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by fernandobr, Today, 09:11 AM
                              1 response
                              3 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by timmbbo, Today, 08:59 AM
                              1 response
                              3 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by KennyK, 05-29-2017, 02:02 AM
                              2 responses
                              1,281 views
                              0 likes
                              Last Post marcus2300  
                              Started by itrader46, Today, 09:04 AM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Working...
                              X