Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get number of entries the strategy has established?

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

    How to get number of entries the strategy has established?

    Hi,

    My strategy uses multiple entries per direction. Is there any simple way to obtain the exact number of entries the strategy has made at any given time?

    Thank you.

    #2
    While there isn't a built in method to call, you can do this with custom variable tracking.

    Depending on the type of script you're working with you could either increment the variable each time an enter method was called or each time on execution completely filled the order.

    Info on using OnExecution if you're doing advanced order handling: http://www.ninjatrader.com/support/h...nexecution.htm

    You would then reset or decrease the variable as exit orders were filled. This part would be easier with on execution but you could probably get something to work by monitoring market position or trade performance in OnBarUpdate()



    Let me know if I can further assist.
    LanceNinjaTrader Customer Service

    Comment


      #3
      Or if you're looking for just a count of all trades taken you can use this

      LanceNinjaTrader Customer Service

      Comment


        #4
        If I decide to go with OnExecution, how do I know that the order is completely filled? Looks like it generates multiple executions.

        Comment


          #5
          Hello,

          You can use something like this

          if (execution.Order.OrderState != OrderState.PartFilled)
          {
          //when the final share/lot is filled this will be true
          }

          See the example found here for how this is used in a script
          The OnOrderUpdate() and OnExecution() methods are reserved for experienced programmers. Instead of using Set() methods to submit stop-loss and profit target orders, you can submit and update them manually through the use of IOrder and IExecution objects in the OnOrderUpdate() and OnExecution() methods. The OnOrderUpdate()


          Let me know if I can further assist.
          LanceNinjaTrader Customer Service

          Comment


            #6
            I don't use IOrder and IExecution objects to submit orders. Can I still use OnExecution just for the purpose of obtaining the number of entries my strategy has made?

            Comment


              #7
              If you're using signal names with your entries/exits you could probably catch the name and evaluate accordingly

              execution.Name


              That being said I would suggest the usage of IOrders if you plan on monitoring advanced handling in OnExecution()

              To clarify are you trying to get the total number of trades taken total? Or are you trying to find out the largest number of trades taken at once?
              LanceNinjaTrader Customer Service

              Comment


                #8
                I need to know the exact number of completely filled orders (entries) at any given time. For example: if I set Entries per direction = 10 and my strategy entered Long position 3 times, I need to obtain the number 3. The problem is that if I use something like "if (execution.Order.OrderState != OrderState.PartFilled)" is returns true for each of multiple executions (within each order) so I cannot increment the variable each time OnExecution is called.
                Last edited by dmitry75; 08-15-2013, 12:42 PM.

                Comment


                  #9
                  Is an order that has been closed out still something you want to monitor?
                  If not then the OnExecution() with IOrder route is probably your best bet.

                  A while back I created a strategy that I needed to determine the number of active open orders (entries with different prices) that were filled. Once they each stopped out I would reset the value

                  To do this I increased the counter when an order was fully filled in OnExecution and when the orders were stopped out I decreased the counter in OnExecution as well.

                  If you're not worried about partial fills you could do this in OnBarUpdate by increasing it each time the entry order is called.

                  Then you would need to check if you're currently flat, if you were flat you would know to reset the counter. This would only work if each your entries were exited at the same time.

                  Otherwise I think you would have to track this in OnExecution()

                  I'll leave this open to see if anyone else has other suggestions.
                  LanceNinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by dmitry75 View Post
                    I need to know the exact number of completely filled orders (entries) at any given time. For example: if I set Entries per direction = 10 and my strategy entered Long position 3 times, I need to obtain the number 3. The problem is that if I use something like "if (execution.Order.OrderState != OrderState.PartFilled)" is returns true for each of multiple executions (within each order) so I cannot increment the variable each time OnExecution is called.
                    In that case you pretty much must use IOrders, so that you can track exactly what happens to each order. Verify your order action results by using OnPositionUpdate().

                    Comment


                      #11
                      Lance, thank you for your prompt responses. I decided to use IOrders and it works nicely.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      647 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      369 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      108 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      572 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      573 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X