• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.


No announcement yet.

Partner 728x90


Stop Loss initialized but not sent to ameritrade

  • Filter
  • Time
  • Show
Clear All
new posts

    Stop Loss initialized but not sent to ameritrade

    I have a custom strategy running on NT8(64) Trading US Stocks. Please Help

    It had a parameter box to put in my own stop loss in Dollar value such as 50 = $50 stop loss. Also a time limit to sell the stock which ever hits first.

    On demo and simulation is works just fine, but in live trading connected to tdameritrade the stop loss order seems to be generated on ninja and not being sent to ameritrade.

    The stop is generated as an oco order.

    There is no pending or open order on the ameritrade side.

    Attached are screen shots showing the order initialized on ninja but not really sent. So stop losses are going right past the number I put in. Entering orders are working and time limit sell is working so there's no problem with the connection to ameritrade.

    here is some of the code for the stop loss.

    TraceOrders = false;
    RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
    StopTargetHandling = StopTargetHandling.PerEntryExecution;
    BarsRequiredToTrade = 20;
    TimeInForce = TimeInForce.Day;

    IsInstantiatedOnEachOptimizationIteration = true;
    Offset = 10;

    else if (State == State.Configure)

    SetStopLoss("",CalculationMode.Currency, StopLoss,false);

    if ( trailstop==false && stoploss ==false &&BarsSinceEntryExecution() >= MinutestoClose )

    // Set 4
    if (trailstop==false && stoploss ==false && BarsSinceEntryExecution() >=MinutestoClose )
    Attached Files

    Hello usstocks,

    Thank you for your post and welcome to the NinjaTrader Support Forum!

    The Order State Initialized would indicate the order was not sent to the connected brokerage technology. You can find out more on the Order States at the following link: https://ninjatrader.com/support/help...efinitions.htm

    Please send me your log and trace files so that I may look into what occurred. You can do this by going to the Control Center-> Help-> Mail to Platform Support. Ensuring 'Log and Trace Files' is checked will include these files. This is checked by default.

    Please list 'ATTN: Patrick H' in the subject line and reference this thread in the body of the email.

    I look forward to assisting you further.
    Patrick H.NinjaTrader Customer Service


      I tried my script on interactive broker and it works, fine. does this mean ameritrade has a problem with accepting the stop loss order? could it be something with the quotes? enteries and exits with ameritrade work.


        Hello usstocks,

        Thank you for your patience.

        The issue is a limitation with TD Ameritrade and the way that NinjaTrader submits Stop losses.

        TD Ameritrade has a limitation where all orders in an OCO grouping must be received at the same time and does not allow for orders placed at different times to use the same OCO ID.

        Because of this, TD Ameritrade will not accept an order that uses an OCO ID if no other orders are submitted with the same OCO ID. (There can't be a single order placed with that OCO ID. If an OCO ID is used, there has to be a grouping)

        The issue is that NinjaTrader places Stop Losses submitted manually or with SetStopLoss() with an OCO ID.

        To prevent the issue, in the script use Exit orders instead of SetStopLoss() or alternatively, also use a profit target (which would be grouped with the OCO ID and allow for the orders to be accepted).

        Please let me know if this does not resolve your inquiry.
        Chelsea B.NinjaTrader Customer Service


        Latest Posts


        Topics Statistics Last Post
        Started by ksarin, Today, 12:39 PM
        3 responses
        Last Post NinjaTrader_PatrickG  
        Started by ttodua, Today, 12:03 PM
        1 response
        Last Post NinjaTrader_ChelseaB  
        Started by tomtr27, Today, 11:35 AM
        1 response
        Last Post NinjaTrader_ChelseaB  
        Started by Uregon, Today, 07:30 AM
        2 responses
        Last Post bltdavid  
        Started by Induna, 02-20-2020, 05:38 AM
        4 responses
        Last Post NinjaTrader_Kate