Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Auto determine shares based on price

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

    Auto determine shares based on price

    Greetings,

    As an investment strategy I determine the number of shares to purchase based on a fixed percentage of my portfolio divided by the current market price.

    Example: (percentage x total portfolio) / price = #shares to purchase

    Is there a feature to specify a dollar amount in the order quantity field that will automatically determine the # shares based on the current price?

    If not, then perhaps there might be some creative way to at least display the calculated "# of shares" value associated with a symbol, somewhere else for reference purposes? I'm not familiar with NinjaScript but if it can allow simple calculations I would think a custom indicator can be built and added as a new column in the Market Analyzer window to handle this?

    Thanks!

    #2
    Change your strategy to run "by account size" in the "Set order quantity" option when you first start up your strategy.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Josh,

      As I understand it the solution you provided is for fully automated orders. My intention is to use this feature with manual or semi-auto (ATM) orders. My hope is after selecting an instrument and ATM strategy in the order bar the qty field is automatically updated according to the formula mentioned previously.

      The next best solution would be to have a custom column in the Market Analyzer, with the calculated qty's for each instrument row that I can reference when manually entering an order.

      Are either of these solutions possible?

      Thanks!

      Comment


        #4
        Still waiting for a response if there is a means to have the "quantity" field auto determine shares based on price using manual orders but I figured out the next best thing...

        I made a simple custom indicator that calculates the shares based on last price and portfolio size as an input, then included it as a column in the Market Analyzer. Now I can easily reference the desired share quantity for each symbol when manually placing an order. It would be awesome if I could somehow link that column to the order entry quantity field when selecting a symbol row.

        Comment


          #5
          Pardon the delay. To do what you want is just a matter of custom programming based off of AccountSize. You want to keep track of PnL to determine your most recent buying power given a certain starting account size. Then run your logic to determine what quantity you want to submit at.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            I would like to change several of my strategies from purchasing a fixed number of shares to trading a number of shares based on the dollar value of the position. Let's say I want to always initiate positions with $5000. worth of stock -- how do I do that? Poking around the message boards gives me the feeling that "by account size" is involved -- can I do that in some way as an edit rather that having to re-create the strategies? Can you point me to the step-by- step process? I don't know how to do programming. Thx.

            Comment


              #7
              You will most likely need to adjust programming. "By account size" will not necessarily work because after the first trade your account size is no longer $5000.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Hmm, maybe I'm off base by thinking that's the starting point. It's not that I want to put the whole account into a trade. It's that I want to trade several different systems (eventually automatically) with the same $ position in each system -- say 3 $5000. positions in a $25K account. How can I do this? Hopefully without having to write code since I don't know how.

                Comment


                  #9
                  This would indeed require some custom coding, please take a look at this thread here - http://www.ninjatrader-support2.com/...t=12252&page=2

                  Accessing brokerage account values is not supported in NinjaTrader 6.5, but it will be in our upcoming NinjaTrader 7 release.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    So in the strategy setup if I "Set order quantity" "by strategy" where do I
                    build that specification into the strategy? I want something like:
                    number of shares = 5000/last price

                    Comment


                      #11
                      If you set it "By strategy" it takes whatever you are submitting your order quantity at. You build it anywhere you want. When you call EnterLong() you specify the quantity you want to buy.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        So the line reads:
                        EnterLong(Shares, "")
                        Where Shares is listed on the User Defined Input page as type int, Default 100 and Min 1.
                        Where can I define the number of shares as 5000/last price? Would I have to create this as a variable which would then be accessed byt the EnterLong command??? Sorry that I don't know the code but I'm hoping to be able to blunder thru this to get what I want

                        Comment


                          #13
                          Yes you need to create a variable and set its value. You need to be outside of the Wizard for this.

                          Code:
                          Shares = 5000 / Close[0];
                          Josh P.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Brevo, Today, 01:45 AM
                          0 responses
                          3 views
                          0 likes
                          Last Post Brevo
                          by Brevo
                           
                          Started by aussugardefender, Today, 01:07 AM
                          0 responses
                          3 views
                          0 likes
                          Last Post aussugardefender  
                          Started by pvincent, 06-23-2022, 12:53 PM
                          14 responses
                          240 views
                          0 likes
                          Last Post Nyman
                          by Nyman
                           
                          Started by TraderG23, 12-08-2023, 07:56 AM
                          9 responses
                          384 views
                          1 like
                          Last Post Gavini
                          by Gavini
                           
                          Started by oviejo, Today, 12:28 AM
                          0 responses
                          6 views
                          0 likes
                          Last Post oviejo
                          by oviejo
                           
                          Working...
                          X