Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

GetAtmStrategyEntryOrderStatus() method error: Order ID does not exist

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

    GetAtmStrategyEntryOrderStatus() method error: Order ID does not exist

    Hi,

    I'm working on a strategy that uses CreateOrder() and ChartTrader ATM Strategy to put in a limit order. I want to cancel this order if it still hasn't been filled after a bar has passed.

    This is how I create the order:

    Code:
    Order order = chartTraderAccount.CreateOrder();
    NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrategy(atmStrategy, order);
    entryATMOrder = order;
    Print("Take trade order id " + entryATMOrder.OrderId + " state " + entryATMOrder.OrderState.ToString());
    This code print out the order id and confirmed that it was Submitted.

    Then later in OnBarUpdate

    Code:
    if (entryATMOrder != null)
    {
       string[] entryOrder = GetAtmStrategyEntryOrderStatus(entryATMOrder.OrderId);
       Print("Entry array length " + entryOrder.Length);
    }


    The above code would print out the error: GetAtmStrategyEntryOrderStatus() method error: Order ID does not exist

    What am I missing?

    Thanks.
    Last edited by mrgreentrading; 05-21-2024, 08:31 PM.

    #2
    Hello mrgreentrading,

    Welcome to the NinjaTrader forums!

    If this is a strategy, it would be suggested to use AtmStrategyCreate() to create the order.


    The orderID string supplied to AtmStrategyCreate() would also be supplied to GetAtmStrategyEntryOrderStatus().

    You can also detect an order updating from the Account.OrderUpdate event.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thank you Chelsea. Looking over the example, it seems that I need to pass in the name of the strategy template that I want to use. I want to pass in whatever template I have at the moment in the chartTrader, and not hardcode it. How can I get that?

      Comment


        #4
        Hello mrgreentrading,

        That I am aware of, the selected active Atm in the drop-down is not going to provide an ID you can use for this method.

        However to answer your question you can use the ChartTraderControlATMStrategySelector automationID to find the chart trader atm selector.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by samish18, Today, 04:59 PM
        0 responses
        3 views
        0 likes
        Last Post samish18  
        Started by oneybuchi2, Today, 03:48 PM
        0 responses
        7 views
        0 likes
        Last Post oneybuchi2  
        Started by Graci117, 06-19-2024, 01:39 PM
        6 responses
        54 views
        0 likes
        Last Post Graci117  
        Started by farawayz, Today, 01:20 PM
        0 responses
        11 views
        0 likes
        Last Post farawayz  
        Started by rjm1903, Today, 01:10 PM
        0 responses
        6 views
        0 likes
        Last Post rjm1903
        by rjm1903
         
        Working...
        X