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

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 Rapine Heihei, 04-23-2024, 07:51 PM
          2 responses
          30 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by Shansen, 08-30-2019, 10:18 PM
          24 responses
          942 views
          0 likes
          Last Post spwizard  
          Started by Max238, Today, 01:28 AM
          0 responses
          9 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by rocketman7, Today, 01:00 AM
          0 responses
          4 views
          0 likes
          Last Post rocketman7  
          Started by wzgy0920, 04-20-2024, 06:09 PM
          2 responses
          28 views
          0 likes
          Last Post wzgy0920  
          Working...
          X