Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Submit and Cancel Entry Orders using Managed Approach?

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

    Submit and Cancel Entry Orders using Managed Approach?

    Howdy--

    I'm looking to place an entry order at X after price has hit Y price, but then cancel the entry order sitting at X if price falls below Z. For instance, in a long scenario, when price hits 161 I want to place a long limit order at 170 so that if price travels to 170 the long order is entered (along with OCO profit and stop orders set via SetProfitTarget() and SetStopLoss()). However, if price never reaches 170 but instead hits 155, I want to cancel the long limit order (and the associated OCO profit and stop orders associated with the entry order) and start waiting for my next signal.

    Is there a way to use the Managed Approach to place and then cancel the entry, profit and stop orders if the "bail" price is hit?

    I have found the NT Strategy example whereby I use the Unmanaged Approach to cancel the orders (using CancalOrder()), however at this point I'd like to use NT7's Managed Approach until I get a bit more comfortable with the parts and pieces of automated order management.

    Does anyone have any ideas?

    At this point I have set the TimeInForce within the Initialize() method as:

    Code:
    TimeInForce			= Cbi.TimeInForce.Gtc;
    However, perhaps I should be renewing the orders at the end of each bar, in which case if the "bail" price is hit I just wouldn't renew the orders?

    Thanks for your help, I REALLY appreciate it.

    All best,

    Aventeren
    Last edited by aventeren; 05-26-2014, 09:21 PM.

    #2
    Aventeren, both ideas are valid, the CancelOrder() method would be available in the managed approach as well, so you could submit the intial entry via liveUntilCancelled for example an then monitor price for the bail level. Or you would just not renew orders if they expired and the condition to continue trying to get a fill is not valid anymore. If you want the order to persist across a few bars to allow for a fill, I would implement the CancelOrder approach as it would be less order submission plus likely an improved q position for the order.

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Aventeren, both ideas are valid, the CancelOrder() method would be available in the managed approach as well, so you could submit the intial entry via liveUntilCancelled for example an then monitor price for the bail level. Or you would just not renew orders if they expired and the condition to continue trying to get a fill is not valid anymore. If you want the order to persist across a few bars to allow for a fill, I would implement the CancelOrder approach as it would be less order submission plus likely an improved q position for the order.
      Thanks, Bertrand.

      I was thinking about my breakout strategy a bit more last night, and I realized on my example that if I would be be placing a long limit order with a priceEntry of 170 when the signal was generated at 161, that my order would be filled at or near 161, as the limit order would be well above where price was currently trading, so the order would fire immediately, which is not what I want. I'm looking for price to confirm to me that it can hit 170 before entering long. So really I want to be placing a Stop Limit Market order (SLM) at 170 when the 161 signal price has been hit (I think). Is it possible to place SLM order programmatically?

      Thanks,

      Aventeren

      Comment


        #4
        Originally posted by aventeren View Post
        Thanks, Bertrand.

        I was thinking about my breakout strategy a bit more last night, and I realized on my example that if I would be be placing a long limit order with a priceEntry of 170 when the signal was generated at 161, that my order would be filled at or near 161, as the limit order would be well above where price was currently trading, so the order would fire immediately, which is not what I want. I'm looking for price to confirm to me that it can hit 170 before entering long. So really I want to be placing a Stop Limit Market order (SLM) at 170 when the 161 signal price has been hit (I think). Is it possible to place SLM order programmatically?

        Thanks,

        Aventeren
        Yes. EnterStopLimit(...).

        Comment


          #5
          Originally posted by koganam View Post
          Yes. EnterStopLimit(...).
          Thanks, koganam; so on a EnterLongStopLimit() order, what would I use for the "double limitPrice" and "double stopPrice" values given my example of the long signal generated at 161, the desired entry at 170 and the bail price at 155? My gut would tell me that I would use 170 as the limitPrice, but what about the stopPrice?

          Here is the EnterStopLimit() documentation for future readers:

          EnterLongStopLimit()

          Definition
          Generates a buy stop limit order to enter a long position.


          Method Return Value

          An IOrder read-only object that represents the order. Reserved for experienced programmers, additional information can be found within the Advanced Order Handling section.


          Syntax
          EnterLongStopLimit(double limitPrice, double stopPrice)
          EnterLongStopLimit(double limitPrice, double stopPrice, string signalName)

          EnterLongStopLimit(int quantity, double limitPrice, double stopPrice)

          EnterLongStopLimit(int quantity, double limitPrice, double stopPrice, string signalName)


          The following method variation is for experienced programmers who fully understand Advanced Order Handling concepts.


          EnterLongStopLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, double stopPrice, string signalName)


          Parameters

          signalName
          User defined signal name identifying the order generated. Max 50 characters.

          limitPrice
          The limit price of the order.

          stopPrice
          The stop price of the order.

          quantity
          Entry order quantity.

          liveUntilCancelled
          The order will NOT expire at the end of a bar, but instead remain live until the CancelOrder() method is called or its time in force has been reached.

          barsInProgressIndex
          The index of the Bars object the order is to be submitted against. See the BarsInProgress property. This determines what instrument the order is submitted for.

          Examples

          protected override void OnBarUpdate()
          {
          if (CurrentBar < 20)
          return;

          // Only enter if at least 10 bars has passed since our last entry
          if (BarsSinceEntry() > 10 && CrossAbove(SMA(10), SMA(20), 1))
          EnterLongStopLimit(High[0] + 2 * TickSize, High[0], "SMA Cross Entry");
          }

          Tips (also see Overview)

          · If using a method signature that does not have the parameter quantity, the order quantity will be taken from the quantity value set in the strategy dialog window when running or backtesting a strategy

          Comment


            #6
            So I've done a bit more digging, and it seems like I might want to use EnterLongStop(). Again, using my simple example where my long signal was generated at 161 and my desired entry price is 170, it seems like I would use 170 as the value for the "double stopPrice" in the EnterLongStop() order.

            What do you guys think?

            Here is the NT Documentation:

            EnterLongStop()

            Definition
            Generates a buy stop order to enter a long position.

            Method Return Value

            An IOrder read-only object that represents the order. Reserved for experienced programmers, additional information can be found within the Advanced Order Handling section.

            Syntax
            EnterLongStop(double stopPrice)
            EnterLongStop(double stopPrice, string signalName)

            EnterLongStop(int quantity, double stopPrice)

            EnterLongStop(int quantity, double stopPrice, string signalName)

            The following method variation is for experienced programmers who fully understand Advanced Order Handling concepts.

            EnterLongStop(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double stopPrice, string signalName)

            Parameters

            signalName
            User defined signal name identifying the order generated. Max 50 characters.

            stopPrice
            The stop price of the order.

            quantity
            Entry order quantity.

            liveUntilCancelled
            The order will NOT expire at the end of a bar, but instead remain live until the CancelOrder() method is called or its time in force has been reached.

            barsInProgressIndex
            The index of the Bars object the order is to be submitted against. See the BarsInProgress property. This determines what instrument the order is submitted for.

            Examples

            protected override void OnBarUpdate()
            {
            if (CurrentBar < 20)
            return;

            // Only enter if at least 10 bars has passed since our last entry
            if (BarsSinceEntry() > 10 && CrossAbove(SMA(10), SMA(20), 1))
            EnterLongStop(GetCurrentAsk() + TickSize, "SMA Cross Entry");
            }

            Tips (also see Overview)

            · If using a method signature that does not have the parameter quantity, the order quantity will be taken from the quantity value set in the strategy dialog window when running or backtesting a strategy

            Comment


              #7
              170 would be your stop value to activate the order Aventeren, it would just depend on which order type you then want to use for the actual entry, market or limit. Limit giving you the option to spec a price and try to get a price improvement over the stop trigger (at the risk to be left out).

              Comment


                #8
                Originally posted by NinjaTrader_Bertrand View Post
                170 would be your stop value to activate the order Aventeren, it would just depend on which order type you then want to use for the actual entry, market or limit. Limit giving you the option to spec a price and try to get a price improvement over the stop trigger (at the risk to be left out).
                Thanks, Bertrand. So in the case of the EnterLongStopLimit() order type, you are saying that I would use 170 for both the "double limitPrice" and "double stopPrice" parameters?

                Or are you saying that I would use 170 as the "double stopPrice" parameter using the EnterLongStop() order type?

                Comment


                  #9
                  Stopprice would be the same for both, it's the stop portion trigger of the order that activates either your market or limit order. Only in the later case would then of course be a limit price needed.

                  To get familiar I would suggest placing a few orders for example on our simulator to see the differences so you can make a pick then for your scenario.

                  Comment


                    #10
                    Originally posted by NinjaTrader_Bertrand View Post
                    Stopprice would be the same for both, it's the stop portion trigger of the order that activates either your market or limit order. Only in the later case would then of course be a limit price needed.

                    To get familiar I would suggest placing a few orders for example on our simulator to see the differences so you can make a pick then for your scenario.
                    So if I were to use EnterLongStopLimit(), there would not be any repercussions to using 170 as both the "double limitPrice" and "double stopPrice" parameter values?

                    I'm just about to start testing, but wanted to make sure I understood as much as I could before I got going.

                    Thanks for your help.

                    Comment


                      #11
                      That's correct in understanding.

                      Here's an overview over all order types - http://www.ninjatrader.com/support/f...ead.php?t=3271

                      Comment


                        #12
                        Originally posted by NinjaTrader_Bertrand View Post
                        That's correct in understanding.

                        Here's an overview over all order types - http://www.ninjatrader.com/support/f...ead.php?t=3271
                        Thanks for the link--super helpful. I think I'm going to run initial testing using EnterLongStopLimit() with 170 as both my limitPrice and stopPrice.

                        Thanks!

                        Comment


                          #13
                          Originally posted by aventeren View Post
                          So if I were to use EnterLongStopLimit(), there would not be any repercussions to using 170 as both the "double limitPrice" and "double stopPrice" parameter values?

                          I'm just about to start testing, but wanted to make sure I understood as much as I could before I got going.

                          Thanks for your help.
                          You monitor price until it passes your trigger price, then you place the EnterLongStopLimit at the price that you want, with Stop and Limit the same.

                          Code:
                          if (Close[0] >= 160.00) EnterLongStopLimit(170.00, 170.00);

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          628 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          359 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          105 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          562 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          568 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X