Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

the account balance in the back test

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

    the account balance in the back test

    I want to adjust the trade quantity based on either the account balance or the realized profit/loss. Here is my code

    Account myAccount = Account.All.First(t => t.Name == "Sim101");
    AcctBalance = myAccount.Get(AccountItem.NetLiquidation, Currency.UsDollar);
    RealizePL = myAccount.Get(AccountItem.RealizedProfitLoss, Currency.UsDollar);

    However, during the back test, the account balance is constant and the realized profit/loss is zero. How to track these two numbers during the back test?​

    #2
    I believe the reason for this is because during a backtest, the account it not named "Sim 101". Mine shows the account is named "Playback101".

    Comment


      #3
      Hello Playdc,

      Thank you for your post.

      There is no account used when backtesting a strategy in the Strategy Analyzer so you will see a value of zero print out when calling Account.Get() on any value.

      This is because there is no backtest account in the Strategy Analyzer to get this information from. The Strategy Analyzer simply runs the strategy on historical data to see how that strategy might have worked on that past data.

      You could consider using the Playback connection which does use an account (Playback101) when testing the script instead. ​

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      80 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X