Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unexpected order price from SetStopLoss()

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

    Unexpected order price from SetStopLoss()

    Hello NT-Support,

    My custom strategy returns the following two error messages:
    **NT** Strategy 'TestSimplifiedStrategy' submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.
    and...
    Market Replay Connection, Sell stop or sell stop limit orders can't be placed above the market. affected Order: Sell 1 Stop @ 1146,25
    Apparently the SetStopLoss() method generates an invalid SellStop order. But I can't figure out why, although I have done all the trouble shooting I can think off. (To me it looks as if the SetStopLoss() method matches stop orders for long and short trades incorrectly.)
    Could you to take a look at my code? I have attached a simplified version with comments , print statements and TraceOrders = true.

    The error will occur if you run the strategy on a 5 min ES chart in a trending market with COBC = true.

    - COBC = true.
    - Managed approach
    - Entry Orders are live until cancelled
    - SetStopLoss() and SetProfitTarget() are set in the OnExecution method
    - Cancelled and rejected entry orders are reset in OnOrderUpdate()
    - Stop- and target prices are dynamically updated in OnBarUpdate()
    - Stop- and target prices are reset in OnPositionUpdate and OnOrderUpdate() when cancelled or rejected entry orders are reset

    Best regards,
    Posedon_sthlm
    Attached Files
    Last edited by poseidon_sthlm; 09-05-2014, 03:01 AM. Reason: Improved print statments i attached strategy.

    #2
    poseidon_sthlm, for the 1146.25 stop price - which order price would instead expect here according to your calcs? Could it simply be dynamically updating the values to close to the inside market to cause the rejection? Something that would likely even be more pronounced trying to trade this script live, as delays are not factored into replay.

    I also see your using mode .Price and then not updating / resetting the Set method to an initial tick offset when you're in flat state > this should be done.

    Comment


      #3
      Thanks! A reset of the Set methods to an initial tick offset when in flat state solved the issue. I now understand how the Set method works.

      /Poseidon_Sthlm

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      55 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      142 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      160 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      96 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      276 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X