Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is it possible to set this specific bet size automatically?

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

    Is it possible to set this specific bet size automatically?

    I want to make a trade in which a stop loss is automatically applied (depending on numerous factors like volatilty etc). but lets say the stop loss for a trade is at 5% below my entry.
    Is it possible to to automatically select a bet size that if my trade goes the wrong way and the stop loss at 5% is hit, i only lose 2% of my equity (my whole account value)?

    Hopfully i eplained this well enough, if not, please let me know and i try to provide more detail and/or an example.

    #2
    Hi Voodoo:
    I don't think it's a good practice, if your maximum risk is 2% of your account, you CAN'T HAVE A MAJOR STOP.
    I recommend that you set up your stop loss correctly.

    Comment


      #3
      Hi VoodooDog,
      I will not comment on what you should do or not. I assume, we are all adults here. One size doesn't fit all in trading.
      This type of "FlexQuantity" can of course be calculated automatically in NinjaScript (not in StrategyBuilder).
      The calculation is not awfully complex. I neglect slippage and commission here to keep things simple.
      Let's assume, the instrument you want to buy trades at 100. To risk 5%, implies a stop at 95, i.e. a max. loss of 5 per unit.
      Now, if you have an account balance of let's say 10,000 at that time, a risk of 2% per trade translates into 200.
      Thus, if you wanted to trade at constant 2% risk, you could buy 40 units: 200 (account risk) / 5 (per unit) = 40.
      Since you need to run this calculation before you enter, you will need to apply a bit of cushion (e.g. round down the number of shares calculated), but that's the concept.
      Happy coding and happy backtesting.
      NT-Roland

      Comment


        #4
        Originally posted by NT-Roland View Post
        Hi VoodooDog,
        I will not comment on what you should do or not. I assume, we are all adults here. One size doesn't fit all in trading.
        This type of "FlexQuantity" can of course be calculated automatically in NinjaScript (not in StrategyBuilder).
        The calculation is not awfully complex. I neglect slippage and commission here to keep things simple.
        Let's assume, the instrument you want to buy trades at 100. To risk 5%, implies a stop at 95, i.e. a max. loss of 5 per unit.
        Now, if you have an account balance of let's say 10,000 at that time, a risk of 2% per trade translates into 200.
        Thus, if you wanted to trade at constant 2% risk, you could buy 40 units: 200 (account risk) / 5 (per unit) = 40.
        Since you need to run this calculation before you enter, you will need to apply a bit of cushion (e.g. round down the number of shares calculated), but that's the concept.
        Happy coding and happy backtesting.
        NT-Roland
        ah right, i can code everything related to my strategy in c#, right? so literally _everything_ is possible, thats amazing.
        thanks for the intel

        Comment


          #5
          Hello VoodooDog,

          This would require a custom calculation in an unlocked script to calculate an integer to use for the quantity.


          To get the account cash value:
          Account.Get(AccountItem.CashValue);


          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          37 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          64 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X