Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                558 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                324 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                101 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                545 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                547 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X