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 GLFX005, Today, 03:23 AM
      0 responses
      1 view
      0 likes
      Last Post GLFX005
      by GLFX005
       
      Started by XXtrader, Yesterday, 11:30 PM
      2 responses
      11 views
      0 likes
      Last Post XXtrader  
      Started by Waxavi, Today, 02:10 AM
      0 responses
      6 views
      0 likes
      Last Post Waxavi
      by Waxavi
       
      Started by TradeForge, Today, 02:09 AM
      0 responses
      12 views
      0 likes
      Last Post TradeForge  
      Started by Waxavi, Today, 02:00 AM
      0 responses
      2 views
      0 likes
      Last Post Waxavi
      by Waxavi
       
      Working...
      X