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

Investing a percentage of the whole account

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

    Investing a percentage of the whole account

    Hello

    what do I have to do, that NT uses each trade 10% of the actual Cash available instead of a fixed quantity?

    For example I invest with a capital of 10'000 1'000 in the first trade. I close it with 1'000 win. In the next trade, it shall invest 1'100 and so on.

    How do I do this (with rounding down, so max. 10% of the total cash investing)?

    Thanks in advance

    Sepp

    #2
    Strangely, NT doesn't support this out of the box. You have to handle your own account size calculations and calculate a position size based on the account size using custom code. Hopefully, this is something we'll see supported out of the box in NT 7.x. Lots of us would like to see a few basic built-in position sizing algorithms that you can apply to any strategy, and then ability to write your own algorithm and apply it to any strategy, similar to WealthLab, etc.

    Comment


      #3
      Ok, I see... for the custom code it would look like: Quantity X
      X = AccountSize/CurrentPrice. But how do I get the actual account size? I mean the account size where win and loss of the trades before are already calculated. Is there any command like this?

      Regards,

      Sepp

      Comment


        #4
        You don't have built-in access to your broker's exact account size in NT 6.5. You would need to start your strategy with some kind of parameter that specifies the current account size, and then you write code to manually update the account size after each trade (using stuff like Performance.AllTrades.TradesPerformance.Currency.C umProfit and Position.GetProfitLoss, etc.). If you search these forums for "+position +size +percent +algorithm" and some similar variations, you'll find several discussions on this topic.

        Comment


          #5
          Thank you for your help.
          My problem is actually, that EnterShort/Long() needs an int as quantity, which is an absolute number. But I have to insert a double parameter, which changes after each OnBarUpdate(). Is there any possibility to enter a quantity, which varies depending on the total AccountSize?

          Regards,

          Sepp

          Comment


            #6
            Sepp, you could set order quantity 'by account' - http://www.ninjatrader-support.com/H...AStrategy.html

            BertrandNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Bertrand View Post
              Note that the AccountSize property doesn't reflect your actual brokerage account size (it isn't available in NT 6.5) and does not update as trades complete to reflect any gains/losses. AccountSize is only a static property you input in your strategy parameters to specify a fixed maximum position size, not one based on a dynamic/changing account size. To position size based on a % of a real or virtual account size that grows or shrinks as trades complete, you have to take your gain/loss and add it to your starting balance from when the strategy started. For details, see my test case here:
              Support for the development of custom automated trading strategies using NinjaScript.

              Comment


                #8
                But this also gets a double parameter. What I need is a int parameter, that reflects my actual accountsize, for that I can enter it in the EnterShort() command.

                Comment


                  #9
                  MasterSepp, unfortunately you can't access your live account stats in NinjaTrader 6.5 - this will be added for 7 - http://www.ninjatrader.com/webnew/NT7/NinjaTrader7.html

                  New Account Access
                  We added methods to get access to live brokerage account values such as cash balance. This is dependant on the broker and the level of information they provide if any.
                  BertrandNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by TraderBCL, Today, 04:38 AM
                  2 responses
                  10 views
                  0 likes
                  Last Post TraderBCL  
                  Started by martin70, 03-24-2023, 04:58 AM
                  14 responses
                  105 views
                  0 likes
                  Last Post martin70  
                  Started by Radano, 06-10-2021, 01:40 AM
                  19 responses
                  606 views
                  0 likes
                  Last Post Radano
                  by Radano
                   
                  Started by KenneGaray, Today, 03:48 AM
                  0 responses
                  4 views
                  0 likes
                  Last Post KenneGaray  
                  Started by thanajo, 05-04-2021, 02:11 AM
                  4 responses
                  471 views
                  0 likes
                  Last Post tradingnasdaqprueba  
                  Working...
                  X