Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Brandon H.NinjaTrader Customer Service

    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 popecapllc, 08-09-2023, 07:42 PM
      11 responses
      1,872 views
      0 likes
      Last Post tradgrad  
      Started by morrnel, 05-12-2024, 06:07 PM
      7 responses
      106 views
      1 like
      Last Post tradgrad  
      Started by mmike, Yesterday, 10:33 PM
      0 responses
      4 views
      0 likes
      Last Post mmike
      by mmike
       
      Started by Pole123, Yesterday, 06:02 PM
      0 responses
      8 views
      0 likes
      Last Post Pole123
      by Pole123
       
      Started by samish18, Yesterday, 05:27 PM
      0 responses
      5 views
      0 likes
      Last Post samish18  
      Working...
      X