Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetAtmStrategyStopTargetOrderStatus()

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

    GetAtmStrategyStopTargetOrderStatus()

    When using an ATM strategy with one stop loss and one profit target, what name does NT assign to the profit target and the stop loss? I tried using "Profit target" and "Stop loss" with the sample code from the ATM help section. But I don't get a print out in the output window.

    What is the proper syntax to use the Order State of the stops or targets as a boolean?

    if(ordersS[i, 2]=="Filled")
    do something


    **NT** Disabling NinjaScript strategy 'RangerATM/0963d0cf7e0542e0a0af9e066925e3b1'
    **NT** Enabling NinjaScript strategy 'RangerATM/0963d0cf7e0542e0a0af9e066925e3b1' :
    **NT** GetAtmStrategyMarketPosition() method error: Missing atmStrategyId parameter

    Code:
      protected override void OnBarUpdate()
            {
    					atmStrategyId = GetAtmStrategyUniqueId();
    					orderId = GetAtmStrategyUniqueId();
    			string[,] ordersS = GetAtmStrategyStopTargetOrderStatus("Stop loss", atmStrategyId);
     
        // Check length to ensure that returned array holds order information
        if (ordersS.Length > 0)
        {
            for (int i = 0; i < ordersS.GetLength(0); i++)
             {
                  Print("Average fill price is " + ordersS[i, 0].ToString());
                  Print("Filled amount is " + ordersS[i, 1].ToString());
                  Print("Current state is " + ordersS[i, 2].ToString());
             }
        }
    
    	
    		string[,] ordersT = GetAtmStrategyStopTargetOrderStatus("Profit Target", atmStrategyId);
     
        // Check length to ensure that returned array holds order information
        if (ordersT.Length > 0)
        {
            for (int i = 0; i < ordersT.GetLength(0); i++)
             {
                  Print("Average fill price is " + ordersT[i, 0].ToString());
                  Print("Filled amount is " + ordersT[i, 1].ToString());
                  Print("Current state is " + ordersT[i, 2].ToString());
             }
        }
    			
    			
            }
    Last edited by ThatManFromTexas; 03-28-2011, 01:32 PM.

    #2
    Hello,

    NinjaTrader uses the following names for the first stop loss and target of an ATM strategy:

    Target1
    Stop1


    To check this you can use orders tab, name column for these orders.


    What is the proper syntax to use the Order State of the stops or targets as a boolean?

    if(ordersS[i, 2]=="Filled")
    do something
    Correct - There's no OrderState type returned for this, so have to check for the string.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the quick reply!

      Comment


        #4
        Originally posted by NinjaTrader_RyanM View Post
        Hello,

        NinjaTrader uses the following names for the first stop loss and target of an ATM strategy:

        Target1
        Stop1


        To check this you can use orders tab, name column for these orders.




        Correct - There's no OrderState type returned for this, so have to check for the string.
        I get this in the output window.

        *NT** Error on calling 'OnBarUpdate' method for strategy 'Test/192635a7eb7a4de5a7fb3a27ad935d12': Index was outside the bounds of the array.



        on this code. Any suggestions?

        Code:
        string[,] ordersS = GetAtmStrategyStopTargetOrderStatus("Stop1", atmStrategyId);
         
            // Check length to ensure that returned array holds order information
            if (ordersS.Length > 0)
            {
                for (int i = 0; i < ordersS.GetLength(0); i++)
                 {
                    Print("Current state is " + ordersS[i, 2].ToString());
        			
        			if(ordersS[i, 2]=="Filled")
        			tsbtnBuy.Text = "Buy Range";
        			tsbtnBuy.BackColor = Color.Green;
        			
                 }
            }
        
        	
        		string[,] ordersT = GetAtmStrategyStopTargetOrderStatus("Target1", atmStrategyId);
         
            // Check length to ensure that returned array holds order information
            if (ordersT.Length > 0)
            {
                for (int i = 0; i < ordersT.GetLength(0); i++)
                 {
                    Print("Current state is " + ordersT[i, 2].ToString());
        			
        			if(ordersT[i, 2]=="Filled")
        			tsbtnBuy.Text = "Buy Range";
        			tsbtnBuy.BackColor = Color.Green;
                 }
            }

        Comment


          #5
          To track down what is happening, add Try - Catch blocks to your code. This will indicate what what object you're accessing that is causing the exception.

          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            Thanks for the suggestion!

            Comment


              #7
              Originally posted by NinjaTrader_RyanM View Post
              Hello,

              NinjaTrader uses the following names for the first stop loss and target of an ATM strategy:

              Target1
              Stop1


              To check this you can use orders tab, name column for these orders.




              Correct - There's no OrderState type returned for this, so have to check for the string.
              Is that, Target1 or TARGET1? Stop1 or STOP1 ?

              Comment


                #8
                You can use either of those or even tArGeT1 and it should find the order.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_RyanM View Post
                  You can use either of those or even tArGeT1 and it should find the order.
                  Is this the proper syntax:

                  string[,] Sorders = GetAtmStrategyStopTargetOrderStatus(Stop1, orderId);

                  or should it be

                  string[,] Sorders = GetAtmStrategyStopTargetOrderStatus("Stop1", orderId);


                  From the Output Window:

                  **NT** GetAtmStrategyStopTargetStatus() method error: AtmStrategyId '' does not exist or is already in terminated state
                  **NT** GetAtmStrategyStopTargetStatus() method error: AtmStrategyId '' does not exist or is already in terminated state


                  Code:
                  private string	Stop1				= string.Empty;
                  
                  string[,] Sorders = GetAtmStrategyStopTargetOrderStatus(Stop1, orderId);
                  
                  if (Sorders.Length > 0)
                      {
                          for (int i = 0; i < Torders.GetLength(0); i++)
                           {
                                Print("Filled amount is " + Sorders[i, 1].ToString());
                                Print("Current state is " + Sorders[i, 2].ToString());
                  			
                  			if(Sorders[i, 2].ToString()=="Filled")
                  			{
                  					 Print("Do Something " )
                  			
                  			}
                  			
                           }
                      }

                  Comment


                    #10
                    You actually need the atmStrategyId.

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

                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #11
                      Thank You!

                      Comment


                        #12
                        How do you know when to use "Quotation Marks"?

                        string[] entryOrder = GetAtmStrategyEntryOrderStatus("orderId");

                        If(GetAtmStrategyMarketPosition(atmStrategyId) == Cbi.MarketPosition.Flat)
                        Do Something

                        AtmStrategyChangeEntryOrder(0,price, orderId);

                        Comment


                          #13
                          Use quotation marks when you're checking a literal string. Don't use quotation marks when you're checking a variable. For guidance on this specific to Atm strategy, please see the sample provided. If you're looking for help with an ATM method that is not included in the sample, check the help guide for an example on its usage.
                          Ryan M.NinjaTrader Customer Service

                          Comment


                            #14
                            **NT** GetAtmStrategyStopTargetStatus() method error: OrderName 'Stop1' does not exis

                            Hello,

                            I've run into the same issue receiving the GetAtmStrategyStopTargetStatus() method error. This existing thread helped but I am still running into an issue.

                            The problem -

                            It appears that the GetAtmStrategyStopTargetStatus() method is unable to locate the "Stop1" variable. Here is an excerpt from the OutPut window:

                            **NT** GetAtmStrategyStopTargetStatus() method error: OrderName 'Stop1' does not exist

                            Here is the applicable snippet

                            (in the variables section I have): private string Stop1 = string.Empty;


                            (in the OnBarsUpdate section I have):

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

                            // Check length to ensure that returned array holds order information
                            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());
                            }
                            }

                            I'd appreciate any pointers you can give me.
                            Last edited by NinjaTrader_PatrickH; 05-15-2015, 10:29 AM. Reason: Removed link assembly per Forum upload rules.

                            Comment


                              #15
                              Hello,

                              Thank you for providing the example, unfortunately this is exported as a compiled assembly.

                              Please export as just the .cs file or a uncompiled zip and I will be able to view the code to assist with this.

                              I look forward to being of further assistance.
                              JesseNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by doihaveto13, Today, 05:45 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post doihaveto13  
                              Started by giulyko00, 04-24-2024, 12:03 PM
                              9 responses
                              43 views
                              0 likes
                              Last Post giulyko00  
                              Started by memonic, Yesterday, 01:23 PM
                              2 responses
                              25 views
                              0 likes
                              Last Post memonic
                              by memonic
                               
                              Started by merc410, Today, 03:41 AM
                              2 responses
                              16 views
                              0 likes
                              Last Post merc410
                              by merc410
                               
                              Started by sugalt, 04-30-2024, 04:02 AM
                              2 responses
                              13 views
                              0 likes
                              Last Post sugalt
                              by sugalt
                               
                              Working...
                              X