Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error in reading cash balance from IB

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

    Error in reading cash balance from IB

    Dear ninjatraders,

    I am a program newbie and am currently developing a test code for the automated trading using NT7 and IB TWS. But when I tested it with my active account in IB, it does not read my account info (cash balance). More details are following.


    The Problem

    1. When I run the code (the whole code below) in backtesting, it works well with the "DefaultAccountSize".
    2. However, in the live trading with IB TWS, the code does not read my account balance and the strategy still works with the DefaultAccountSize.


    I appreciate any comments for this problem.

    Thank you very much.

    Best regards,
    CUK.

    --------------------------------------------------
    Last edited by hhyang95; 03-11-2016, 02:52 PM.

    #2
    Hello,

    Thank you for the question.

    This would be directly associated with the way that GetAccountValue() works. If we look in the help guide in its description it shows this method returns either the account value or during historical bars the value of 0.

    In backtests this would be the same, a 0 value would be reported.

    The expected result when running live would be to show the account balance. I did try your code and placed a Print() statement in your TradeSize int like the following:

    Code:
    private int TradeSize
    {
         get
         {
               double gav = GetAccountValue(AccountItem.CashValue);
    	   Print(gav);
    I was using the Sim101 account on Live data and I did see 0 values as the script ran through historical which is expected, upon the condition becoming true I did see my account balance printed to the Tools -> Output Window.

    I wanted to double check that you are seeing the balance from IB reported in the Accounts tab in NinjaTrader correct?

    Also what version of TWS are you using? this can be found when you start IB on the splash screen. The supported version is 944.3, if you are using a different version this could be the cause.

    I look forward to being of further assistance. .

    Comment


      #3
      Dear Jesse,

      I do see my IB account info in the Account tab in NT7 (latest version), and I checked that my TWS version is 944.3.

      I still don't understand how my strategy fails in reading the IB cash value during live trading.

      I can send you my strategy script via email if you are willing to test it in your sim account.

      Thank you so much for your help.

      Best regards,
      cuk

      Comment


        #4
        Hello,

        Thank you for the offer.

        If you could send that to me to platformsupport @ ninjatrader.com and reference ticket 1231807 I would appreciate that.

        I look forward to being of further assistance.

        Comment


          #5
          Dear Jesse,

          I sent my code to you.

          Thanks for your help.

          Best regards,
          cuk

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 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
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X