Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Issue with Stop Loss Triggering Order Rejection

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

    Issue with Stop Loss Triggering Order Rejection

    I'm using the Market Replay connection, and am getting the following issue. I attached a screen capture.

    When I open a long or short order, I also set a profit target and a stop loss. I set the profit target and stop loss after getting confirmation that the entershort/enterlong order was filled (e.g., via onOrderUpdate). I leverage Position.AvgPrice to set the profit/stop orders.

    I'm currently using 1000 units to enter the order.

    Occassionally, the stop loss order will get rejected. This happens when I attempt to set a stop loss above the current price (for a long), or below the current price (for a short). If the rejection happens, it's usually after one or more trades.

    The strange thing is that this doesn't happen all the time -- e.g., I have pairs that I'm backtesting with where this never happens. I also check that the stop is right relative to the Close[0] price before I set it.

    Unfortunately when the order is rejected, the strategy exits. The following is output in my log file:

    **NT** Strategy 'mpUltimateTrend/362797a6599f4a7dbebf5f025bd43922' submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.
    **NT** Disabling NinjaScript strategy 'mpUltimateTrend/362797a6599f4a7dbebf5f025bd43922'


    Here is the code where I set the stop for a short position. It's call in OnOrderUpdate after validating that the position filled. "stopLoss" is a parameter in pips set in the strategy GUI (it's set to -1 if I don't want a stop loss), and "openPositionName" is a global variable set and then used as a parameter to EnterShort or EnterLong:

    private void setShortTrailStop()
    {
    double myStop = 0;

    if (stopLoss != -1)
    {
    myStop = Position.AvgPrice + (stopLoss * TickSize);

    if (Close[0] < myStop)
    {
    SetStopLoss(openPositionName, CalculationMode.Price, myStop, false);
    Print(Instrument.FullName + " " + Time[0] + ": Short Stop set to " + myStop);

    } else {
    Print(Instrument.FullName + " " + Time[0] + ": NOT SET! Attempted stop of " + myStop);
    }
    }
    }

    I haven't tested whether this will happen live. I attached a screen capture of three instances where this happened. Also when this happens, I never get the "NOT SET Print" condition printed in my log file -- e.g., the Close[0] check works, and the "Short Stop set" is outputted.

    Any thoughts on what may be happening would be appreciated. Thanks in advance.
    Attached Files

    #2
    micprice,

    Please send in your log and trace files to support.

    Help -> Mail to platform support

    Put Attn Cal and reference this thread in the body
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Cal - I just sent the message.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by timko, Today, 06:45 AM
      1 response
      7 views
      0 likes
      Last Post gaz0001
      by gaz0001
       
      Started by Waxavi, 04-19-2024, 02:10 AM
      3 responses
      41 views
      0 likes
      Last Post gaz0001
      by gaz0001
       
      Started by Max238, Today, 01:28 AM
      2 responses
      26 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Started by Shansen, 08-30-2019, 10:18 PM
      25 responses
      949 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by JonesJoker, 04-22-2024, 12:23 PM
      8 responses
      44 views
      0 likes
      Last Post JonesJoker  
      Working...
      X