Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Recommended Way to Get Live Account Balance History

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

    Recommended Way to Get Live Account Balance History

    I have added some functionality to size down on an automated strategy based on current drawdown. This is straightforward in backtesting because I keep track of the account balance by adding NetProfit to some default starting balance and then can do intraday and end of day drawdown calculations using that balance.

    What is the best/recommended way to do something similar for live/real-time trading? Is there a way to programmatically get a running history of the account balance? I can probably get the cumulative net profit in similar fashion using SystemPerformance.RealTimeTrades.TradesPerformance .NetProfit, but for that to work I need to know the original starting balance and I don't see how to do that.

    I should also mention that this is an intraday strategy and I tend to restart each morning, so keeping track of this in the runtime process like the backtest affords isn't a viable solution.

    Code:
                    if (State == State.Historical)
                    {
                        if (SystemPerformance.AllTrades.Count > 0)
                        {
                            double netProfit = SystemPerformance.AllTrades.TradesPerformance.NetProfit;
                            AccountBalance = 100000 + netProfit;
                            PeakAccountBalance = Math.Max(PeakAccountBalance, AccountBalance);
                            Drawdown = AccountBalance - PeakAccountBalance;
                            DrawdownPct = Drawdown / PeakAccountBalance;
                            if (USE_COMPOUNDING == false)
                            {
                                DrawdownPct = Drawdown / 100000;
                            }
                            MaxDrawdown = Math.Min(Drawdown, MaxDrawdown);
                            MaxDrawdownPct = Math.Min(DrawdownPct, MaxDrawdownPct);
    
                            if (Bars.IsLastBarOfSession)
                            {
                                MaxClosingDrawdown = Math.Min(Drawdown, MaxClosingDrawdown);
                                MaxClosingDrawdownPct = Math.Min(DrawdownPct, MaxClosingDrawdownPct);
                            }
                        }
                    }​

    #2
    Hello garth,

    Thanks for your notes.

    Unfortunately, there is no historical account information available to access in NinjaScript so you would not be able to get the balance history of an account.

    If you would like, I could submit a feature request to the Development team on your behalf to request this feature which they might implement as they see fit.

    Please let me know if you would like me to submit this feature request for you.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hi Brandon,

      I do think it would be a good feature so submitting a feature request probably makes sense. I do understand that such features can take time and/or not get picked up so do you have any workaround suggestions? I know this information is available via account.ninjatrader.com so is there some API external to the NinjaTrader platform that I could hit to get the account history? Other thoughts I had were:

      1. Hard coding my starting balance and then roughly calculating the balance history by iterating over SystemPerformance.RealTimeTrades.TradesPerformance .NetProfit.
      2. Adding a manual toggle to go into "safe mode" if I see the account is in drawdown past the threshold (seems super hacky to need to do that).

      The backtesting metrics are so robust that it really is disappointing something as simple as a live account balance history isn't available, especially when real money is on the line. I'm open to any ideas you or others might have to work around this.

      Thanks,
      Garth

      Comment


        #4
        Hello garth,

        Thanks for your notes.

        I have submitted your feature request to the Development team to take into consideration. This request is being tracked under the number SFT-6042.

        As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted on the Release Notes page of the Help Guide.

        Release Notes — https://ninjatrader.com/support/help...ease_notes.htm

        That said, there is unfortunately no supported workaround available that I am aware of at this time because there is no NinjaScript access to historical account information. This means there are no methods or functions available to get historical account information such as the balance.

        This forum thread will be open for other community members to share their insights on possible workarounds for this.

        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        62 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        134 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        75 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        50 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X