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

Exporting backtest multiple instrument positions updates

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

    Exporting backtest multiple instrument positions updates

    Hello,

    I'm running the Strategy Analyzer to backtest an Instrument List of around 400 stocks. I need to be able to export each and every trade of this backtest to Excel. I know how to program in C# and I was thinking to export it to CSV files. Is there a way to export one line with the total trade summary like?

    Instrument, Open Time, Close Time, Open Price, Close Price, Qty, Strategy Name, Entry Name, Exit Name (Stoploss or Profit Target), MAE, MFE etc?

    Can I use some kind of OnPositionUpdate method for this?

    Thanks!

    #2
    Hello siroki,

    Thank you for your post.

    SystemPerformance holds all trades and trade performance data generated by a strategy. You may check the last trade from SystemPerformance in OnPositionUpdate. StreamWriter could then be used to write the text to a file. Please refer to the attached sample strategy to see how this may be done.

    Here are some Help Guide links with more information.

    SystemPerformance - https://ninjatrader.com/support/help...erformance.htm

    OnPositionUpdate - https://ninjatrader.com/support/help...tionupdate.htm

    StreamWriter - https://ninjatrader.com/support/help...o_write_to.htm

    Please let us know if we may further assist.
    Attached Files
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply. Good to know that SystemPerformance is my way to go. I'm not quite sure how to use it though. I'm seeing very limited documentation. If you can provide me a sample how to (for example) retrieve realized P&L for that trade, that's be very helpful.

      Kind regards,

      Comment


        #4
        Never mind. I already understand that TradeCollection is a collection and should be accessed using [] .. For example SystemPerformance.AllTrades[0].MaeCurrency.

        Thanks! This is perfect!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rtwave, 04-12-2024, 09:30 AM
        5 responses
        37 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by funk10101, Today, 12:02 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by GLFX005, Today, 03:23 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by nandhumca, Yesterday, 03:41 PM
        1 response
        13 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by The_Sec, Yesterday, 03:37 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X