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

Obtain information from the result of my strategy

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

    Obtain information from the result of my strategy

    Hi,

    I need to keep an account in my strategy, how many times I reached the 1st Tarjet and how many times the 2nd, you have some example of how to do this.

    Thank you very much for your help, greetings, Alejandro.

    #2
    Hello Alejandro,

    So I can best answer your question, could you please provide more information on what you're looking to do with the account in your strategy? I'm not sure I understand your question exactly.

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      My strategy operates with 2 objectives, the 1st to 10 ticks and the second to 20 ticks, when testing it with historical information, I want to see on the screen how many times I had reached my 1st Tarjet (10 ticks) and how many times I reached the 2nd tajet (20 ticks).

      Thank for your help, regards, Alejandro.

      Comment


        #4
        Hello ahrt|,

        With the strategy you could add something like the following,

        Code:
        private int ptCounter;
        Code:
        protected override void OnOrderUpdate(IOrder order)
        		{
        			
        			if((order.Name == "Profit target") && order.OrderState == OrderState.Filled)
        			{
        				ptCounter++;
        			}
        			Print("ptCounter"+ptCounter.ToString());
        
        		}
        Which will add 1 to the ptCounter variable each time a profittarget is filled. If you compare this to the Number of Winning Trades output of the SA, you'll see they are roughly the same, meaning you may be able to just go off the # of winning trades if you only have a profit target and stop loss.

        Please let us know if you need further assistance.
        Attached Files
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          Thank You for your help

          Comment


            #6
            Thanks for the example Alan,

            I need to know when an operation is stop, the price at which the stop is executed,
            You could send me an example.

            Thanks, Alejandro

            Comment


              #7
              Hello ahrt|,

              To do this you would need to set up a similar if statement I provided before, however you would need to change the order name in the if statement. I would suggest printing order.Name.ToString(), having the strategy make trades and place stop losses, so that you can see in the output window what name you would check for.

              To get the average fill price you could use order.AverageFillPrice from within OnOrderUpdate.

              Please OnOrderUpdate section of our helpguide,


              Please let us know if you need further assistance.
              Alan P.NinjaTrader Customer Service

              Comment


                #8
                Thanks Alan

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by maybeimnotrader, Yesterday, 05:46 PM
                4 responses
                23 views
                0 likes
                Last Post maybeimnotrader  
                Started by frankthearm, Today, 09:08 AM
                6 responses
                25 views
                0 likes
                Last Post frankthearm  
                Started by adeelshahzad, Today, 03:54 AM
                5 responses
                33 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by stafe, 04-15-2024, 08:34 PM
                7 responses
                32 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by merzo, 06-25-2023, 02:19 AM
                10 responses
                824 views
                1 like
                Last Post NinjaTrader_ChristopherJ  
                Working...
                X