Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Getting error when calling GetAtmStrategyStopTargetOrderStatus

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

    Getting error when calling GetAtmStrategyStopTargetOrderStatus

    Hi,

    When I call GetAtmStrategyStopTargetOrderStatus, I get the following error.
    'GetAtmStrategyStopTargetOrderStatus' method error: Order name 'Target1' is invalid
    GetAtmStrategyStopTargetOrderStatus' method error: Order name 'Stop1' is invalid



    protected override void OnBarUpdate()
    {
    if(!PerformTakePosition())
    {
    if (!isAtmStrategyCreated)
    return;


    if (orderId.Length > 0)
    {
    string[] status = GetAtmStrategyEntryOrderStatus(orderId);

    if (status.GetLength(0) > 0)
    {

    if (status[2] == "Filled" || status[2] == "Cancelled" || status[2] == "Rejected")
    {
    orderId = string.Empty;
    }

    PrintTargetOrderStatus();
    PrintStopOrderStatus();



    }
    }
    else if (atmStrategyId.Length > 0 && GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
    atmStrategyId = string.Empty;
    }

    }

    void PrintTargetOrderStatus()
    {

    if (string.IsNullOrEmpty(atmStrategyId) || string.IsNullOrEmpty(orderId))
    return;

    Print("-----------Target status------------");

    string[,] orders = GetAtmStrategyStopTargetOrderStatus("Target1", atmStrategyId);

    for (int i = 0; i < orders.GetLength(0); i++)
    {
    Print("Average fill price is " + orders[i, 0].ToString());
    Print("Filled amount is " + orders[i, 1].ToString());
    Print("Current state is " + orders[i, 2].ToString());
    }
    }

    void PrintStopOrderStatus()
    {
    if (string.IsNullOrEmpty(atmStrategyId) || string.IsNullOrEmpty(orderId))
    return;

    Print("-----------Stop status------------");

    string[,] orders = GetAtmStrategyStopTargetOrderStatus("Stop1", atmStrategyId);

    if (orders.Length > 0)
    {

    for (int i = 0; i < orders.GetLength(0); i++)
    {
    Print("Average fill price is " + orders[i, 0].ToString());
    Print("Filled amount is " + orders[i, 1].ToString());
    Print("Current state is " + orders[i, 2].ToString());
    }
    }
    }

    #2
    Hello bosajin, thanks for your question.

    This error can come up if the stop or target have not been submitted at the time you call this method. Can you confirm the entry order status before calling this to see if the problem will be resolved:
    https://ninjatrader.com/support/help...rderstatus.htm

    I look forward to hearing from you.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi ChrisL,

      this is output of my log.
      status of entry order is Working.


      -----------Order Status------------
      The entry order average fill price is: 0
      The entry order filled amount is: 0
      The entry order order state is: Working
      -----------Target status------------
      'GetAtmStrategyStopTargetOrderStatus' method error: Order name 'Target1' is invalid





      Comment


        #4
        Hello bosajin, thanks for your reply.

        If the order is Working then it has not filled yet. If you call the StopTargetOrder status after the entry order is filled then they should work.

        Kind regards.
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Stephen Trading, Today, 12:27 PM
        0 responses
        1 view
        0 likes
        Last Post Stephen Trading  
        Started by DTSSTS, Today, 09:59 AM
        2 responses
        25 views
        0 likes
        Last Post DTSSTS
        by DTSSTS
         
        Started by localappleseed, Today, 10:12 AM
        4 responses
        13 views
        0 likes
        Last Post localappleseed  
        Started by stewarco, Today, 09:47 AM
        2 responses
        6 views
        0 likes
        Last Post stewarco  
        Started by koganam, Today, 09:20 AM
        5 responses
        26 views
        0 likes
        Last Post NinjaTrader_PatrickG  
        Working...
        X