Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtesting retrieve losses / profit from simulated account

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

    Backtesting retrieve losses / profit from simulated account

    Hi

    I understand that one has to make their own calculations for accountsize when doing backtest against a simulated account. Is there any way to retrieve profit or losses when exiting the trades?

    WBH

    #2
    Hello WBH,

    Thank you for your note.


    To find the profit/loss of a completed trade use the Trade object as shown in the examples in the help guide to which I've linked below.
    http://www.ninjatrader.com/support/h.../nt7/trade.htm

    To find the unrealized profit/loss of open positions use Position.GetProfitLoss(marketPrice, performanceUnit). Below is a link to the help guide on GetProfitLoss.
    http://www.ninjatrader.com/support/h...profitloss.htm

    To find the realized profit/loss for all closed positions use the TradesPerformance collection. For example: Performance.RealtimeTrades.TradesPerformance.Curre ncy.
    Below is a link to the help guide on TradesPerformance.
    http://www.ninjatrader.com/support/h...erformance.htm


    Please let me know if this does not resolve your inquiry.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello leocrespo,

      I disagree that the Performance collection with AllTrades (and not RealtimeTrades) does not work historically.

      Attached I have provided a test strategy that prints the profit of each trade to the Output window as the position updates using the Performance collection. I am receiving prints after each trade in the Output window. Can you demonstrate that this script does not work correctly on your end?

      As I understand this, the original question was about the account value with GetAccountValue which is not available historically. So the account information would have to be calculated with code based on the performance of each trade.
      http://ninjatrader.com/support/helpG...countvalue.htm
      Attached Files
      Chelsea B.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