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. ​
      Gaby V.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Pointtoni, Yesterday, 11:41 PM
      0 responses
      7 views
      0 likes
      Last Post Pointtoni  
      Started by DayTradingDEMON, Yesterday, 02:10 PM
      2 responses
      20 views
      0 likes
      Last Post DayTradingDEMON  
      Started by Marble, 03-20-2025, 05:00 AM
      7 responses
      34 views
      0 likes
      Last Post Marble
      by Marble
       
      Started by laketrader, 03-10-2025, 07:20 AM
      6 responses
      59 views
      0 likes
      Last Post laketrader  
      Started by clintonbullocks15, Yesterday, 07:47 PM
      0 responses
      5 views
      0 likes
      Last Post clintonbullocks15  
      Working...
      X