Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

AccountItem.CashValue question

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

    AccountItem.CashValue question

    Regarding Account.Get(AccountItem.CashValue, Currency.Euro)

    Say I am using Sim1 account denominated in Euro

    Account.Get(AccountItem.CashValue, Currency.Euro)
    Account.Get(AccountItem.CashValue, Currency.UsDollar)

    I noticed that these two calls return the same value which is the $ value It seems like the second parameter does not affect anything

    Is that expected?

    #2
    Hello onb1,

    Thank you for your note.

    The case example I can find in the help guide of using Currency.UsDollar or Currency.Euro is in reference to checking the master instrument, for example at the following link,


    I would not expect using Currency.Euro would convert your account balance to euros, as this would suggest the parameter would pull live currency data rather than just be used to compare the instruments FX.

    If you see a case in the helpguide or a sample which suggests this would convert the account balance, please let us know.

    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      I would not expect using Currency.Euro would convert your account balance to euros, as this would suggest the parameter would pull live currency data rather than just be used to compare the instruments FX.
      Agree, I don't expect to see that either.

      My question is this
      The call to Get has two inputs - the item and currency. I could not find any explanation why the second parameter is needed and what is it used for. Thought you might be able to shed light on that.

      Account.Get(AccountItem.CashValue, Currency.Euro)

      Comment


        #4
        Hello onnb1,

        This is not documented. What is it you are trying to accomplish exactly?

        I look forward to your reply.
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          We are position sizing based on account cash value.
          As you noted, we need to convert a set risk that is in the account currency to the currency pair traded in order to calculate the position size for the market traded.

          When working with the Get api, I noticed that the second parameter is there but doesn't do anything. I wanted to confirm this

          Comment


            #6
            Hello onnb1,

            I wrote a sample which would be pretty easy to modify so that it converts the account size to another currency. You would need to adjust xAccountSize by euros.

            Please see attached.

            Please let us know if you have any questions.
            Attached Files
            Alan P.NinjaTrader Customer Service

            Comment


              #7
              Alan,

              Is there no way to get the Total PnL without having to keep track of it myself in the OnPositionUpdate() method?

              I am expecting something like:

              Code:
              PositionAccount.GetTotalProfitLoss(PerformanceUnit.Currency, Price);
              But I haven't seen anything like this.

              I would like to get the value described in this documentation under "Understanding Accounts Tab --> Total Pnl":



              The issue is that my base class cannot derive from the strategy class, and thus I cannot (and shouldn't have to) override the OnPositionUpdate() method. Please let me know if there is a NinjaScriptBase object that contains the account details I'm looking for.

              Comment


                #8
                Hello jflaggs,

                The sample I provided includes what you’re looking for if you do not enable the backtest bool.

                I would also suggest downloading the addon at the following link, Addon Framework for how to get PL outside of a strategy.



                Please let us know if you need further assistance.
                Alan P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by fitspressoburnfat, Today, 04:25 AM
                0 responses
                2 views
                0 likes
                Last Post fitspressoburnfat  
                Started by Skifree, Today, 03:41 AM
                1 response
                4 views
                0 likes
                Last Post Skifree
                by Skifree
                 
                Started by usazencort, Today, 01:16 AM
                0 responses
                1 view
                0 likes
                Last Post usazencort  
                Started by kaywai, 09-01-2023, 08:44 PM
                5 responses
                603 views
                0 likes
                Last Post NinjaTrader_Jason  
                Started by xiinteractive, 04-09-2024, 08:08 AM
                6 responses
                23 views
                0 likes
                Last Post xiinteractive  
                Working...
                X