Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Size based on risk

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

    Size based on risk

    Was wondering if NinjaScript (6.5 or 7) has any built in features that would make it easy to set the quantity traded based on the stop loss.

    For example: my trade system uses a different sized stop based on the trade it's taking. I would like it to make it so that all sized stops risk the same Dollar Amount. So if I chose to risk $1000 on a trade in the S&P eminis it would trade 2 contracts if the stop was 10 points in size and 10 contracts if the stop was 2 points in size etc...

    I can think of some ways to manually code this but wanted to make sure there wasn't a faster way before I program it in.

    #2
    Hi shazzmoe,

    Unfortunately there is no built in method that does this. You will need to custom program it.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I wrote up the following and it should do what I want it to do but I'm not sure the syntax for converting a double to an int. (I know there is no reason to convert it to ticks first that was just me trying to see if it would cast properly)

      Code:
      protected int setQuantity(double stop){
                  int ticks = stop *4;
                  int q;
                  if(useDollar){
                      q = DollarAmt/(ticks * 12.5);
                      return q;
                  }
                  else
                      return Quantity;
              }

      Comment


        #4
        To cast it to an int you could do this.

        someInt = (int) someDouble;
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        67 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        36 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        59 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        62 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        53 views
        0 likes
        Last Post CarlTrading  
        Working...
        X