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 jerminedop, Today, 12:18 AM
        0 responses
        5 views
        0 likes
        Last Post jerminedop  
        Started by cnzaxtoil, Yesterday, 11:38 PM
        0 responses
        4 views
        0 likes
        Last Post cnzaxtoil  
        Started by cnzaxtoil, Yesterday, 11:37 PM
        0 responses
        3 views
        0 likes
        Last Post cnzaxtoil  
        Started by sukhob, Yesterday, 04:27 PM
        1 response
        14 views
        0 likes
        Last Post zacharydw00  
        Started by Bmnaiorwsd, Yesterday, 07:52 PM
        0 responses
        4 views
        0 likes
        Last Post Bmnaiorwsd  
        Working...
        X