Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

A Sell stop order placed at XXXX has been ignored since the stop price is greater ..

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

    A Sell stop order placed at XXXX has been ignored since the stop price is greater ..

    A Sell stop order placed at '26/02/2011 0:00:00' has been ignored since the stop price is greater than or equal to close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy.
    If possible I would like to handle this by catching an exception and sending a market order instead.

    Can I do this, and if so where in the code should I catch the exception? I place the stop order in a method that I call in OnBarUpdate().

    Thanks.

    #2
    Hello AnotherTrader,

    Thank you for your post.

    This is a historical message, so it only appears on historical data. In real-time the order would be rejected. You would just want to ensure the sell stop price is less than the close and the buy stop price is greater than the close, so something along the lines of the following to be used as the price for your stop orders:
    Code:
    Math.Min(Close[0] - TickSize, yourStopPrice) // For sell stops
    Math.Max(Close[0] + TickSize, yourStopPrice) // For buy stops
    Please let me know if I may be of further assistance.

    Comment


      #3
      Same problem here, but I can't seem to get it fixed:

      My output =

      11/02/2016, 08:22:02 Flat. currentStop = 0
      2/11/2016 8:22:06 AM Entered internal PlaceOrder() method at 2/11/2016 8:22:06 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='oLLA1' FromEntrySignal=''
      11/02/2016, 08:22:06 Long Lime Arrow 1 @ 161.755
      11/02/2016, 08:22:06 * LLA1 = Filled
      11/02/2016, 08:22:06 * execution.Order = Order='NT-00245/Sim101' Name='oLLA1' State=Filled Instrument='$GBPJPY' Action=Buy Limit price=0 Stop price=0 Quantity=1 Strategy='LiSL231' Type=Market Tif=Gtc Oco='' Filled=1 Fill price=161.755 Token='178a5f610b3c4cf98d55904ba08e69a0' Gtd='12/1/2099 12:00:00 AM'
      11/02/2016, 08:22:06 * oLLA1.AvgFillPrice = 161.755
      11/02/2016, 08:22:06 initialStop = 161.56
      11/02/2016, 08:22:06 Limit = 161.53
      11/02/2016, 08:22:06 Close = 161.755

      2/11/2016 8:22:02 AM Entered internal PlaceOrder() method at 2/11/2016 8:22:02 AM: BarsInProgress=1 Action=Sell OrderType=StopLimit Quantity=1 LimitPrice=161.53 StopPrice=161.56 SignalName='Stop loss order' FromEntrySignal='oLLA1'
      **NT** A Sell stop order placed at '2/11/2016 8:22:06 AM' has been ignored since the stop price is greater than or equal to close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy.
      2/11/2016 8:22:02 AM Ignored PlaceOrder() method at 2/11/2016 8:22:02 AM: Action=Sell OrderType=StopLimit Quantity=1 LimitPrice=161.53 StopPrice=161.56 SignalName=Stop loss order' FromEntrySignal='oLLA1' Reason='Invalid order price, please see log tab'
      11/02/2016, 08:22:06 SLOrder placed @ = 161.56 - Stop = 161.56 Limit = 161.53
      11/02/2016, 08:22:07 $ $ $ Open PnL: -85.000000000008
      **NT** Error on calling 'OnBarUpdate' method for strategy 'LiSL231/e9234e3840684e5d8c06c0a151f5acbc': Object reference not set to an instance of an object.
      2/11/2016 8:22:07 AM CancelAllOrders: BarsInProgress=0
      2/11/2016 8:22:07 AM CancelAllOrders: BarsInProgress=1
      Seems to me the Stop IS smaller than the price of the current bar

      My code =

      Code:
      protected override void OnExecution(IExecution execution)
              {    
                  if (oLLA1 != null && execution.Order == oLLA1 && execution.Order.OrderState == OrderState.Filled)
      
                  {   Print(Time[0].ToString("dd/MM/yyyy") + ",  " + Time[0].ToString("HH:mm:ss")+  " * LLA1 = " + oLLA1.OrderState);
                      Print(Time[0].ToString("dd/MM/yyyy") + ",  " + Time[0].ToString("HH:mm:ss")+  " * execution.Order = " + execution.Order);
                      Print(Time[0].ToString("dd/MM/yyyy") + ",  " + Time[0].ToString("HH:mm:ss")+  " * oLLA1.AvgFillPrice = " + oLLA1.AvgFillPrice);
                      
                      // Set initial StopLoss
                      [COLOR=Red]initialStop        = Math.Min (execution.Order.AvgFillPrice - 195 * TickSize, Close[0]-TickSize);
                      Limit = Math.Min (initialStop - 30 * TickSize, Close[0]-TickSize);[/COLOR]
                      Print(Time[0].ToString("dd/MM/yyyy") + ",  " + Time[0].ToString("HH:mm:ss")+  " initialStop = " + initialStop);
                      Print(Time[0].ToString("dd/MM/yyyy") + ",  " + Time[0].ToString("HH:mm:ss")+  " Limit = " + Limit);
                      Print(Time[0].ToString("dd/MM/yyyy") + ",  " + Time[0].ToString("HH:mm:ss")+  " Close - TickSize = " + Close[0]);
                      exitStopLimit    = ExitLongStopLimit(1, true, execution.Order.Quantity, Limit, initialStop , "Stop loss order", "oLLA1");
                      Print(Time[0].ToString("dd/MM/yyyy") + ",  " + Time[0].ToString("HH:mm:ss")+  " SLOrder placed @ = " + initialStop +" - Stop = " + initialStop + " Limit = " + Limit);
                  
                  }
      The lines in red here are supposed to mitigate the problem, no ??

      Comment


        #4
        Hello Spinn,

        Thank you for your post.

        Your code is correct in that the current bar (Close[0]) would give us the minimum value needed when compared against Close[0]. However, in Historical data the order's in the backtest are submitted to the next bar. That next bar may not have the price level needed.

        You could check for this with Close[-1]. Keep in mind this will only work on historical bars as you can look forward on the historical bars but not on real-time bars.

        Comment


          #5
          I adjusted the code, but sadly the problem persists.
          I even did a complete reboot (helped me before on a few occasions), but to no avail.


          Code:
          // Set initial StopLoss
                          initialStop        = Math.Min (execution.Order.AvgFillPrice - 195 * TickSize, [COLOR=Red][B]Close[-1][/B][/COLOR]-TickSize);
                          Limit = Math.Min (initialStop - 30 * TickSize, [B][COLOR=Red]Close[-1][/COLOR][/B]-TickSize);
          11/02/2016, 08:22:02 Flat. currentStop = 0
          2/11/2016 8:22:06 AM Entered internal PlaceOrder() method at 2/11/2016 8:22:06 AM: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='oLLA1' FromEntrySignal=''
          11/02/2016, 08:22:06 Long Lime Arrow 1 @ 161.755
          11/02/2016, 08:22:06 * LLA1 = Filled
          11/02/2016, 08:22:06 * execution.Order = Order='NT-00245/Sim101' Name='oLLA1' State=Filled Instrument='$GBPJPY' Action=Buy Limit price=0 Stop price=0 Quantity=1 Strategy='LiSL231' Type=Market Tif=Gtc Oco='' Filled=1 Fill price=161.755 Token='8937bc554d0f48e19eaaf17759d5f5e1' Gtd='12/1/2099 12:00:00 AM'
          11/02/2016, 08:22:06 * oLLA1.AvgFillPrice = 161.755
          11/02/2016, 08:22:06 initialStop = 161.56
          11/02/2016, 08:22:06 Limit = 161.53
          11/02/2016, 08:22:06 Close - TickSize = 161.755
          2/11/2016 8:22:02 AM Entered internal PlaceOrder() method at 2/11/2016 8:22:02 AM: BarsInProgress=1 Action=Sell OrderType=StopLimit Quantity=1 LimitPrice=161.53 StopPrice=161.56 SignalName='Stop loss order' FromEntrySignal='oLLA1'
          **NT** A Sell stop order placed at '2/11/2016 8:22:06 AM' has been ignored since the stop price is greater than or equal to close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy.
          2/11/2016 8:22:02 AM Ignored PlaceOrder() method at 2/11/2016 8:22:02 AM: Action=Sell OrderType=StopLimit Quantity=1 LimitPrice=161.53 StopPrice=161.56 SignalName=Stop loss order' FromEntrySignal='oLLA1' Reason='Invalid order price, please see log tab'
          11/02/2016, 08:22:06 SLOrder placed @ = 161.56 - Stop = 161.56 Limit = 161.53
          11/02/2016, 08:22:07 $ $ $ Open PnL: -85.000000000008
          **NT** Error on calling 'OnBarUpdate' method for strategy 'LiSL231/00d47e6423f34fb28bb3e68a611f1cf7': Object reference not set to an instance of an object.
          2/11/2016 8:22:07 AM CancelAllOrders: BarsInProgress=0
          2/11/2016 8:22:07 AM CancelAllOrders: BarsInProgress=1
          EDIT: I inspected even closer and found out that this happened at a time where there was a lot of movement on the pair in a short period of time. In this particular instance price fell over 300 Ticks in a mere 11 seconds. Maybe the order is just being skipped over. Would there be a way to shortcut this in a safe way ?? (besides setting the stop waaay lower ??)
          Last edited by Spinn; 08-31-2016, 09:03 AM.

          Comment


            #6
            Hello Spinn,

            Thank you for your response.

            You would need to verify that your order's price would not be invalid based on the current bar (0) and the next bar (-1). Checking the High and Low of those bars to be certain.

            Comment


              #7
              Hello Spinn,

              I adjusted the code, but sadly the problem persists.
              There is a problem with the NT rule for Historic Stops. See here

              The existing rule incorrectly uses Close[0] as proxy for 'current price'.
              But assuming you are placing a stop at OnBarUpdate() ie at the start of a new bar then the correct proxy for 'current price' is Bars.GetOpen(CurrentBar+1) definitely not Close[-1].
              Last edited by DaveE; 10-21-2016, 10:04 AM.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by AnnBarnes, Today, 12:17 PM
              0 responses
              1 view
              0 likes
              Last Post AnnBarnes  
              Started by Lopat, 03-05-2023, 01:19 PM
              4 responses
              166 views
              0 likes
              Last Post Sam2515
              by Sam2515
               
              Started by f.saeidi, Today, 12:14 PM
              0 responses
              2 views
              0 likes
              Last Post f.saeidi  
              Started by giulyko00, Today, 12:03 PM
              0 responses
              4 views
              0 likes
              Last Post giulyko00  
              Started by AttiM, 02-14-2024, 05:20 PM
              12 responses
              213 views
              0 likes
              Last Post DrakeiJosh  
              Working...
              X