Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error on trailing stop - order above market price reject!

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

    Error on trailing stop - order above market price reject!

    Hello everybody,

    I'm having the same problem that most users who try to use a trailing stop experience, which is the damn order being rejected because the price was posted above the market.

    Is there any objective and straightforward solution to solve this problem, since tripling the stop loss size does not solve it when the price comes against the trailing stop?

    Awaiting designation of a support technician to send trace route information and print/videos of errors and messages.

    Cheers!​

    #2
    Hello EvergreenGain,

    If this is the managed approach, use the isLiveUntilCancelled bool parameter as true, and place the exit only when the entry has filled and when modifying the price. (Don't re-submit on each new bar to keep it alive)
    Below is a link to the ProfitChaseStopTrailExitOrdersExample which demonstrates trailing with isLiveUntilCancelled as true.


    Ensure the price calculated for exit order is a valid price. A sell stop must be below the bid, a buy stop must be above the ask.

    Below is a link to a forum post with sample code.
    Hi I have a sellshort StopLimit order that i change if unfilled. I tick below the last bar's low. I keep getting the stop price can't be changed above the market but the price value it quotes ( the one I want) is below the market. Currently I am on the simulated feed. I appreciate in real market situations this could happen
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      If there's one thing I respect more than the tool itself in NT8, it's that support, especially your ChelseaB.

      As always insightful in interpreting the user's problem and suggesting a solution. My consideration and eternal thanks!!!

      But I wanted to confirm with you about the specific solution. Is this the one below?

      // trigger the trail action when the current price is further than the set distance to the stop loss

      if (TrailStopLoss &&stopLoss != null && (stopLoss.OrderState == OrderState.Accepted || stopLoss.OrderState == OrderState.Working) &&
      Close[0] > currentSlPrice + StopLossDistance * tickSizeSecondary)

      {
      currentSlPrice = Close[0] - StopLossDistance * tickSizeSecondary;
      ExitLongStopMarket(1, true, entryOrder.Quantity, currentSlPrice, "stop loss", entryOrder.Name);

      }


      Below, I'm sharing the code part of my trailing stop logic:


      case MarketPosition.Long:

      if (previousPrice == 0)
      {
      stopPlot = Position.AveragePrice - stopLossTicks * TickSize; // initial stop plot level
      }

      // Once the price is greater than entry price+ breakEvenTicks ticks, set stop loss to plusBreakeven ticks
      if (Close[0] > Position.AveragePrice + breakEvenTicks * TickSize && previousPrice == 0)
      {
      initialBreakEven = Position.AveragePrice + plusBreakEven * TickSize;
      SetStopLoss(CalculationMode.Price, initialBreakEven);
      previousPrice = Position.AveragePrice;
      stopPlot = initialBreakEven;
      }
      // Once at breakeven wait till trailProfitTrigger is reached before advancing stoploss by trailStepTicks size step
      else if (previousPrice != 0 ////StopLoss is at breakeven
      && GetCurrentAsk() > previousPrice + trailProfitTrigger * TickSize )
      {
      newPrice = previousPrice + trailStepTicks * TickSize; // Calculate trail stop adjustment
      SetStopLoss(CalculationMode.Price, newPrice); // Readjust stoploss level
      previousPrice = newPrice; // save for price adjust on next candle
      stopPlot = newPrice; // save to adjust plot line

      }​
      ​​

      Comment


        #4
        Hello EvergreenGain,

        As you are using SetStopLoss() you can disregard the information about using isLiveUntilCancelled.

        Ensure that you are resetting SetStopLoss() when flat to a valid price (or number of ticks) before placing a new entry, as demonstrated in the ProfitChaseStopTrailSetMethodsExample on line 103.

        Ensure that your newPrice is a valid price below the bid.

        newPrice = previousPrice + trailStepTicks * TickSize; // Calculate trail stop adjustment

        if (newPrice >= GetCurrentBid())
        newPrice = GetCurrentBid() - TickSize.​

        SetStopLoss(CalculationMode.Price, newPrice)​
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          ChelseaB,

          Look up for my update!!! It's working very nicely now!

          // Once at breakeven wait till trailProfitTrigger is reached before advancing stop loss by trailStepTicks size step

          else if (previousPrice != 0) // StopLoss is at breakeven

          {
          if (GetCurrentBid() > previousPrice + trailProfitTrigger * TickSize)
          {
          newPrice = previousPrice + trailStepTicks * TickSize; // Calculate trail stop adjustment
          if (newPrice >= GetCurrentBid()) // Ensure newPrice is below the current ask
          newPrice = GetCurrentBid() - TickSize;

          SetStopLoss(CalculationMode.Price, newPrice); // Readjust stoploss level
          previousPrice = newPrice; // save for price adjustment on next candle
          stopPlot = newPrice; // save to adjust plot line
          }

          I hope that support ticket can help another!

          Thank you so much again.

          Cheers!

          Comment


            #6
            ChelseaB,

            It was too good to be true. Now the error refers to the OCO order, according to the attached screen prints.

            Any suggestion to solve the problem?

            Wouldn't it be some configuration on the platform? I looked through all the tickets and didn't find a plausible solution.



            Attached Files

            Comment


              #7
              Hello EvergreenGain,

              The profit target and stop loss use OCO.

              The stop loss was rejected because this was a sell order with the stop price equal to or above the current bid.

              The profit target was rejected because it was using the same OCO ID as the stop loss, and the stop loss was rejected.

              OCO is One-Cancels-Others. When an OCOID is used on an order, this will cause any other orders using the same OCOID to be cancelled when the order fills, is rejected, or is cancelled.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by gustavobp, Today, 03:15 AM
              0 responses
              5 views
              0 likes
              Last Post gustavobp  
              Started by gustavobp, Today, 03:00 AM
              0 responses
              5 views
              0 likes
              Last Post gustavobp  
              Started by nicbizz, Today, 02:14 AM
              0 responses
              5 views
              0 likes
              Last Post nicbizz
              by nicbizz
               
              Started by Ringer13, Today, 01:59 AM
              0 responses
              7 views
              0 likes
              Last Post Ringer13  
              Started by NINZAMANA, 02-06-2025, 09:03 AM
              2 responses
              24 views
              0 likes
              Last Post Fertryd2  
              Working...
              X