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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      45 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      31 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Working...
      X