Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simple Account Value

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

    Simple Account Value

    Part 1:
    I've spent just over 4 hours now searching and testing methods of getting the current accounts cashValue and save it as a local variable to calculate how many shares to purchase with 10% of that cashValue. I have finally found what appears correct however I want to confirm it.

    Print(NinjaTrader.Cbi.Globals.Accounts[0].GetAccountValue(AccountItem.CashValue, Currency.Unknown).Value);

    I connected to Sim101, opened a chart, and run a test strategy that only Printed this value and it returned what Sim101 account listed as Cash Value. Is this the proper method of doing this?

    Part 2:
    I've tried many variations of only using GetAccountValue(AccountItem.CashValue) as is documented however when run as above on Sim101 the Printed value is always 0. Example Statement: Print(GetAccountValue(AccountItem.CashValue));
    Why is this?

    I can add both of these statements to the same strategy and the first returns a proper value and the second still returns 0.

    Part 3:
    I've also found odd discrepancies when specifying the currency. I added both of the below lines to a blank strategy as above, run it on the Sim101 account and the first Print statement returns the Sim101's account cash value but the second Print statement returns 0.

    Print(NinjaTrader.Cbi.Globals.Accounts[0].GetAccountValue(AccountItem.CashValue, Currency.Unknown).Value);
    Print(NinjaTrader.Cbi.Globals.Accounts[0].GetAccountValue(AccountItem.CashValue, Currency.UsDollar).Value);

    Why is this?

    Thanks in advance,
    Joe
    Last edited by antrux; 06-10-2016, 06:18 PM.

    #2
    Hello antrux,

    Thank you for writing in.

    You can simply call the GetAccountValue() method and pass AccountItem.CashValue as a parameter to obtain the cash value of the account the strategy is running on: https://ninjatrader.com/support/help...countvalue.htm

    Please note that a value of 0 is returned on historical bars when using the documented method above. Once your strategy is running in real-time, the method will return the current cash value of the account the strategy is running on.

    I would not be able to explain the behaviors you're seeing with the undocumented methods you have specified for obtaining the cash value, but I do see from a previous post from one of our forum users that you'll want to be using Currency.Unknown rather than specifying a specific currency: http://ninjatrader.com/support/forum...38&postcount=8

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      So maybe a dumb question but how is someone suppose to properly test a strategy without running on a live trading account? It seems fair enough to ask that one should be able to Connect to Simulated Data Feed, create a new chart of XYZ, apply a written strategy to it, and verify the results. Doesn't NT see the Sim101 account, see that is has a cashValue, and then return it? Why not?

      Doing this is not a backtest it's according what I know thus far the same thing as live trading except it's trading against fictional broker account and fictional data. No?

      Comment


        #4
        Hello antrux,

        Thank you for your response.

        On Historical Data whether you are running a backtest, running on the Sim101 account on realtime data, or on your live account, will still result in 0. There is no account values held historically and therefore the information is not available to pull.

        If you want to track values on historical tests then you would create your own variables and track them in the code manually.

        Comment


          #5
          Ok, however I guess I'm not understanding the differences between a live Sim101 account and say a live TDA account.

          I can understand the no data on historical bars because obviously something would have to store an initial value and that values history in order to do so hence self tracking.

          In Zack's earlier reply and else where it only states that the requirement for use is real time trading. If Sim101 offers a simulated real time trading then why would it not work there too?

          Comment


            #6
            Hello antrux,

            Thank you for your response.

            You are not wring in that a Simulation account would be similar to a live account. The factor here is that in testing either a simulation or live account you would still not have access to the account values over the historical data. Therefore only the real-time trades on real-time data have access to this information.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by judysamnt7, 03-13-2023, 09:11 AM
            4 responses
            57 views
            0 likes
            Last Post DynamicTest  
            Started by ScottWalsh, Today, 06:52 PM
            4 responses
            36 views
            0 likes
            Last Post ScottWalsh  
            Started by olisav57, Today, 07:39 PM
            0 responses
            7 views
            0 likes
            Last Post olisav57  
            Started by trilliantrader, Today, 03:01 PM
            2 responses
            20 views
            0 likes
            Last Post helpwanted  
            Started by cre8able, Today, 07:24 PM
            0 responses
            9 views
            0 likes
            Last Post cre8able  
            Working...
            X