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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        650 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        370 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        577 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X