Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to check if stop loss is placed?

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

    How to check if stop loss is placed?

    Hallo.
    I have a problem with strategy for Hong Kong futures. Because they have the lunch break which starts in the middle of my bar ( I am using 10 minutes bar start from 9:45 but lunch break begun 12:30) sometimes strategy is mixed up and do not place stop orders for open position. This is a little complicated why it happens sometimes, but I think there is now way to resolve this problem at all. I will be satisfied if the strategy can monitor stop orders and if such thing happened place stop order on a bar close.
    My strategy using IOrder method. Stop loss is placed ExitLongStopLimit() but in this emergency situation any stop loss method is OK.

    Generally, my question is how to check if any open position exists without stop loss and place stop loss if it happened ??
    Rgds
    Czarek

    #2
    Hi Czarek, with the IOrder object you can check for the different order states, what you want for your Stop order is 'accepted' (= nonnative order on the broker's server or simulated) or 'working' (= working on the exchange).

    This reference sample might be helpful for you - http://www.ninjatrader-support2.com/...ead.php?t=7499

    Comment


      #3
      Bertrand.
      I check the log and I found that the sop order have been canceled. Canceled reason is 'Order would cross related resting order (202)'
      Could you tell me something more about possible reason of order cancellation ??
      Rgds
      Czarek.

      Comment


        #4
        This error codes comes directly from your broker, so I would suggest checking with them, it seems like there was already a resting stop order submitted so the additional one was cancelled.

        Comment


          #5
          Bertrand.
          I am trying to place the ExitStopLimit() order again if original order is canceled. The order is ignored. Reason='There already is a matching, terminal exit order in place'
          Can you help me to explain what does it means and how to resolve this problem ?
          Czarek

          Comment


            #6
            How do you determine the order is cancelled? The output suggests you already have a stop order placed - can you please post your code so we can take a look? Thanks!
            Last edited by NinjaTrader_Bertrand; 02-11-2009, 12:27 PM.

            Comment


              #7
              Hallo.
              I Cancell stop order manually, because you said that the cancellation request came from broker.
              OnOrderUpdate I check the status if is canceled
              Code:
                protected override void OnOrderUpdate(IOrder order)
              if (stopOrderLong1 != null && order.OrderState == OrderState.Cancelled && order.Filled == 0)
                    {
                        stopLong1Cancell=true;
                     stopOrderLong1 = null;
                     Print( Time[0] + " zmianaStopLongCancell = " + stopLong1Cancell.ToString());
                    }
              Furthermore, if I cancel the stop order I see that variable stopLong1Cancell change state to true.
              Than OnBarUpDate I try to place stop order again.
              Code:
              if (Position.MarketPosition == MarketPosition.Long && Close[0]>= firstEntryLong - averageTicks*stop* TickSize/100 &&stopOrderLong1 == null && stopLong1Cancell==true)
                 {
                  stopOrderLong1 = ExitLongStopLimit(firstEntryLong -1- averageTicks*stop* TickSize/100 ,firstEntryLong - averageTicks*stop* TickSize/100, "MyStopLong1", ""); 
                 }
              Than order is ignored
              Mabe I should to replace cancelled order OnOrderUpDate method??

              Rgds
              Czarek

              Comment


                #8
                Czarek,

                Please try submitting with a different string name.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Josh.
                  I place stop order in OnOrderUpDate
                  Code:
                     }
                     if (Position.MarketPosition == MarketPosition.Long && Close[0]>= firstEntryLong - averageTicks*stop* TickSize/100 &&stopOrderLong1 == null && stopLong1Cancell==true)
                     {
                      stopOrderLong5 = ExitLongStopLimit(firstEntryLong -1- averageTicks*stop* TickSize/100 ,firstEntryLong - averageTicks*stop* TickSize/100, "MyStopLong5", "");
                       stopLong1Cancell=false;
                       stopOrderLong5 = null;
                              }
                  Order is placed but is cancel on Close[0]. How keep this order longer ?

                  Czarek

                  Comment


                    #10
                    Czarek, if your order expires you can use this overload and set liveUntilCancelled to true -

                    Code:
                    ExitLongStopLimit([COLOR=#0000ff]int[/COLOR] [I]barsInProgressIndex[/I], [COLOR=#0000ff]bool[/COLOR] [I]liveUntilCancelled[/I], [COLOR=#0000ff]int[/COLOR] [I]quantity[/I], [COLOR=#0000ff]double[/COLOR] [I]limitPrice[/I],[COLOR=#0000ff]double[/COLOR] [I]stopPrice[/I],[COLOR=#0000ff]string[/COLOR] [I]signalName[/I],[COLOR=#0000ff]string[/COLOR] [I]fromEntrySignal[/I])
                    Please also review this link here - http://www.ninjatrader-support.com/H...rHandling.html

                    Comment


                      #11
                      Thanks a lot guys. Now works well.
                      Czarek

                      Comment


                        #12
                        Good job Czarek, great to hear it works well!

                        Comment


                          #13
                          Hallo.
                          Looks like not so great job :-)) A new problem came. I have this message in log: Error on calling the 'OnOrderUpdat' method for strategy 'MHI'. More than 100 subsequent user events. What does it mesans and where a possible problem is?
                          Czarek.

                          Comment


                            #14
                            Hi Czarek, have you tried running the strategy with TraceOrders = true in the Initialize? Please check the output window then for any insight into what might cause this...in addition please see this thread where a similar issue was discussed - http://www.ninjatrader-support2.com/...ead.php?t=9844

                            Thanks!

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            633 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            364 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
                            567 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