Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can backtest return NUMBER of open positions?

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

    Can backtest return NUMBER of open positions?

    Position.MarketPosition is great at telling me whether my current backtest position(s) are flat, long, or short. However, what is the best way to find out how many longs, and how many short positions are currently in the Position?

    Thanks much,
    -Shuli

    #2
    Position.Quantity tells you your single net position quantity and you cannot have multiple opposing open positions in the same account. Perhaps you are looking for a tabulation of previous trades?
    Last edited by whitmark; 11-23-2008, 03:03 AM.
    whitmark
    NinjaTrader Ecosystem Vendor - Whitmark Development

    Comment


      #3
      Not necessarily a tabulation of previous trades, just the count for now. In other words...

      If the backtest currently has the following 3 Long positions open

      Long 10,000 units
      Long 20,000 units
      Long 30,000 units

      Then, Position.Quantity will report 60,000. But I am more interested in the number of positions (in this case = 3).

      Thanks for your response whitmark, I do appreciate it much.

      -Shuli

      Comment


        #4
        If each 10K quantity is due to a separate order being placed (and confirm filled), you would have to increment a counter each time an order is placed to maintain a count and deduct from it when exits are processed.

        If the each 10K quantity is due to a partial fill and you want to count each fill, you would need to implement a counter in the OnExecution() method using advance order management for which there is a reference example on the forum. I am not aware of an existing method that would return the value you are looking for without you doing it yourself programmatically. NinjaTrader support may have additional insight to share on this.

        Whitmark
        Last edited by whitmark; 11-23-2008, 04:53 AM.
        whitmark
        NinjaTrader Ecosystem Vendor - Whitmark Development

        Comment


          #5
          Whitmark is correct. You will need to run your own counters. Alternatively, you could try using the Trades collection class to get the information you want.
          Josh P.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          571 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          331 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
          549 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          549 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X