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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      155 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      90 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      137 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      130 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      107 views
      0 likes
      Last Post CarlTrading  
      Working...
      X