Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Accessing informations of closed trades in a strategy

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

    Accessing informations of closed trades in a strategy

    Hi,

    i have created a strategy and i need to access informations about closed trades.
    could you confirm that :
    - SystemPerformance.AllTrades.Count is the number of closed trades taken by the strategy
    - to access informations about the last (most recent) trades, i can use SystemPerformance.AllTrades[tradeCounter-1] because the array index starts from 0 (not 1)

    - when i see 13 trades on the strategy analyzer and AllTrades.Count retirns 13, i try to access AllTrades[12] and i get an error and i do not understand why ...

    Thank you for your help


    #2
    Hello rht5692,

    Thanks for your post.

    Yes, SystemPerformance.AllTrades.Count returns the number of all trades generated by a strategy.

    SystemPerformance.AllTrades: https://ninjatrader.com/support/help.../alltrades.htm

    To get the last trade of the TradeCollection, SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1] could be used in a script. To get the first trade of the TradeCollection, SystemPerformance.AllTrades[0] could be used.

    An example of getting the last trade and the first trade from the SystemPerformance.AllTrades TradeCollection could be found in the sample code on the help guide page linked below.

    TradeCollection: https://ninjatrader.com/support/help...collection.htm

    When you mention "i get an error", what exactly does the error report?

    I look forward to assisting further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hi, i have retested the same strategy today and every thing is ok. I can retrieve the data of the first and last trade. Thank you for your help.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Yesterday, 05:17 AM
      0 responses
      79 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      146 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      79 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      52 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      58 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X