Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Percent of equity allocation for stocks

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

    Percent of equity allocation for stocks

    I have a system that trades stocks where I would like to allocate a fixed percentage of equity to each new trade that my system triggers. Does anyone know how to do this? Thanks

    #2
    Hello johnls101,

    You are wanting to modify an existing strategy to allow the strategy to increase the number of contracts (quantity) for the trade as each new trade is placed, is this correct?

    In the order submission call, use an int variable. Any time you want to increase the contract quantity increment the variable.

    For example:
    In #region Variables:
    int myQuantity = 1;

    if (/* conditions to enter trade */)
    {
    EnterLong(myQuantity);
    }

    if (/* conditions to increment quantity */)
    {
    myQuantity++;
    }
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea

      Thank you for replying and looking at my request. However, what I am trying to achieve is very much more basic.

      As an example, if I had $100,000 total equity, and I had worked out through backtesting that I should allocate 10% equity to each trade, the number of shares would need to be adjusted such that the number of shares x share price <= $10K. I figure that I could subtract the modulus after dividing $10K by the share price to get the highest number of whole shares that would sum to less than $10K. Once I had 10 different trades running (each of 10%), all additional potential trades would fail to initiate until one or more 10% bundle of shares were sold, and more equity freed up.

      Unfortunately I don't know how to find what my total equity is and how to allocate 10% to any given share - that is, in an automated way. I am sure that this must have been worked out as equity allocation is such a fundamental requirement for trading shares, but I haven't been able to find it as yet.
      Last edited by johnls101; 06-23-2016, 04:40 AM.

      Comment


        #4
        Hello johnls101,

        When backtesting in NinjaTrader 7, I am not aware of any way to get the account cash balance in your strategy.

        You could manually create an input that allows you to type in a value of what the cash balance is and then make calculations from there.

        Then you would need to write a calculation that calculates how many contracts to place for each order and then use the outcome of that calculation as the quantity amount.

        In the Strategy Analyzer, there is the ability to 'Set order quantity' to 'by account size' and set the Account size to a manually entered value. Then NinjaTrader will automatically set the contract size for all orders to the max amount of contracts that can be purchased for the given entered account size.
        Below is a link to the help guide on the Strategy Analyzer. Please see the section 'Understanding backtest properties'.
        http://ninjatrader.com/support/helpG...a_strategy.htm
        Last edited by NinjaTrader_ChelseaB; 06-23-2016, 07:48 AM.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea

          Thanks for the reply.

          My major need is implementation (i.e. live trading) rather than back testing as I am using other platforms to back-test.

          Please let me know if I have misinterpreted you. However, from what I understand from what you have written, it seems there is no regular or systematic way of managing equity in relation to position size with NinjaTrader. If this is the case, this is a glaring deficiency and should be corrected for both backtesting and live trading. Surely this is not the case?

          What happens normally with Ninja in backtesting on say the S&P 500? Does one just test a strategy on 100 shares of everything and is there very heavy weighting of the results towards expensive shares? Is it even feasible to test against the S&P 500? In my experience equity allocation and position size is at least as important as the buy and entry prices to establish system viability.

          As I expect total equity to grow relatively slowly in the system I am looking at, in live trading I am thinking that I could approximate equity allocation with a user defined variable for equity that I could alter every few days. I could also define the percentage of equity as a user defined variable and the number of shares for each entity would then be derived as the allocated equity divided by the Close. Is this the way to go when trying to do this live, or is there a more systematic way of doing this? I have a link to Interactive Brokers.

          I will see how I go with this and get back to you but I would very much appreciate any other input or suggestions you have.
          Last edited by johnls101; 07-06-2016, 12:25 AM.

          Comment


            #6
            Hello johnls101,

            The quantity for each contract would be managed by the logic in your script.

            Each programmer may want to write the logic differently. All control of the logic of the strategy is handled with the code within the strategy.
            You could use a set quantity for all trades. You could use a slowly increasing quantity as the trades progress. This would all depend on what is written into the strategy to do.

            I am also happy to submit a feature request on your behalf to add functionality that would cause NinjaTrader to automatically adjust the contract size of each trade based on a percentage of the account equity size. It is up to the NinjaTrader Development department to decide when and if any request will be implemented.
            Would you like to submit this feature request (or one similar)?

            When running a strategy in realtime, it is possible to query the account size using GetAccountValue().
            http://ninjatrader.com/support/helpG...countvalue.htm
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks Chelsea

              I would very much like you to submit this as a request on my behalf. From experience the profitability of trend following systems, in particular, seems to increase as percentage equity is increased, and then collapses if this is exceeded. Understanding this is basic to system design. The fact that Ninja has not addressed this suggests that it leaves its customers vulnerable.

              There are lots of other ways of addressing position sizing, but a simple percentage of equity is absolute bare minimum. NinjaTrader would do well to look at a whole module on position sizers, but percentage of equity is a basic entrance-level requirement and should be systematised.

              As part of the approach, it would be highly desirable to get access to a data series for cumulative equity. When dealing with hundreds of stocks, this can get quite complicated. For instance, should one wait until the end of each day to sum up equity (probably best), or sum it continuously as each share is processed (easier to design, and perhaps one way of obtaining end of day equity anyway).

              Thanks Chelsea
              Last edited by johnls101; 06-29-2016, 03:38 PM.

              Comment


                #8
                Hi johnls101,

                I've submitted a feature request on your behalf to increase the contract quantity as a percentage of the equity as the equity increases and decrease as the equity decreases.

                This request is being tracked with ID #SFT-289. It is up to the NinjaTrader Development to decide when and if a feature request will be implemented.

                We do highly value your feedback. Please let me know of any other suggestions or requests you may have.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Would you also mind submitting a request to track equity as a data series ?

                  Comment


                    #10
                    Hello johnls101,

                    I've submitted a feature request to track the equity in a dataseries.

                    Once I have a tracking ID for this I will post this in this thread.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi johnls101,

                      The request to track the equity curve is being tracked with ID# SFT-283.

                      Please let me know if you have any other requests you would like me to submit.
                      Chelsea B.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by jclose, Today, 09:37 PM
                      0 responses
                      5 views
                      0 likes
                      Last Post jclose
                      by jclose
                       
                      Started by WeyldFalcon, 08-07-2020, 06:13 AM
                      10 responses
                      1,413 views
                      0 likes
                      Last Post Traderontheroad  
                      Started by firefoxforum12, Today, 08:53 PM
                      0 responses
                      11 views
                      0 likes
                      Last Post firefoxforum12  
                      Started by stafe, Today, 08:34 PM
                      0 responses
                      11 views
                      0 likes
                      Last Post stafe
                      by stafe
                       
                      Started by sastrades, 01-31-2024, 10:19 PM
                      11 responses
                      169 views
                      0 likes
                      Last Post NinjaTrader_Manfred  
                      Working...
                      X