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

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 cre8able, Today, 01:16 PM
      2 responses
      9 views
      0 likes
      Last Post cre8able  
      Started by chbruno, 04-24-2024, 04:10 PM
      3 responses
      48 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by samish18, Today, 01:01 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by WHICKED, Today, 12:56 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by WHICKED, Today, 12:45 PM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X