Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stoploss on multiple positions

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

    Stoploss on multiple positions

    I've got a multi instrument strategy. How can I set stoploss for all positions. Something like:
    if(unrealized PNL on all positions reaches daily stoploss)
    {
    CoverAll;
    }

    #2
    Hello nysetrader,
    Thanks for writing in and I am happy to assist you.

    The SetStopLoss method will put stop loss bot all the instruments.

    For example if your primary instrument is ES 06-12 and the secondary instrument is NQ 06-12 and if you place the entry order as
    Code:
    EnterLong(0, 1, "0");
    EnterShort(1, 1, "1");
    and if you place your stop as

    Code:
    SetStopLoss(CalculationMode.Ticks, 8);
    then the Set method will place stop for both the instruments.

    You can get the unrealized PnL from the Position class.

    Code:
    Positions[0].GetProfitLoss(Close[0], PerformanceUnit.Currency) //returns unrealized pnl for primary instrument
    Positions[1].GetProfitLoss(Close[0], PerformanceUnit.Currency)  //returns unrealized pnl for secondary instrument.



    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      So there is no method for total ProfitLoss on all instruments?

      Comment


        #4
        Hello nysetrader,
        There is no supported way to retrieve the total PnL.

        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          I'm also using a multi instrument strategy but want to set the stop losses independently. If I put a SetStopLoss command in the initialize section without tags, both instruments use the same stop. I have my ES entries/targets tagged with ES and NQ entries/targets tagged as "NQ". I thought I could use two SetStopLoss commands in the initilize section as:
          Code:
          SetStopLoss("ES", CalculationMode.Price, ESstoploss, false);
          SetStopLoss("NQ", CalculationMode.Price, NQstoploss, false);
          However, this approach seems to mess up targets and stops. Is there another approach I should consider?

          Comment


            #6
            Hello Tdschulz,
            To assist you further may I know what codes you are using to send the Entry orders?

            I look forward to assisting you further.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              EnterLong(1, "ES");

              Comment


                #8
                Hello Tdschulz,
                Thanks for the confirmation.

                In a multi-series strategy you have to define for which bar series the entry order is meant for. Please use the following overload to submit an entry order in multi-series strategy which lets you do choose the bars series.
                Code:
                EnterLong(int barsInProgressIndex, int quantity, string signalName)


                Please let me know if I can assist you any further.
                JoydeepNinjaTrader Customer Service

                Comment


                  #9
                  I was using BarsInProgress to select the correct instrument. My Entries were all fine. I made the change anyway and still I have issues on my SetStopLoss.
                  Code:
                  protected override void Initialize()
                          {
                            	
                  			SetStopLoss("ES", CalculationMode.Price, stoploss0, false);
                  			SetStopLoss("NQ", CalculationMode.Price, stoploss1, false);
                  EntriesPerDirection = 20; 
                      		EntryHandling = EntryHandling.AllEntries; 
                  			TraceOrders =true;
                  			Add(instrument2, PeriodType.Range, range2);
                  CalculateOnBarClose = true;
                  protected override void OnBarUpdate()
                  	{
                  if	(BarsInProgress == 0)
                  
                  			{
                                  EnterShort(0, 1, "ES");
                  		SetProfitTarget("ES", CalculationMode.Ticks, Target2);

                  Comment


                    #10
                    I think the problem is in CalculationMode.Price. I'm using a cash amount, not percent, ticks, or price. How do I associate a position stop loss with a cash amount?

                    Comment


                      #11
                      Hello Tdschulz,
                      To set a stop based on a cash value please use the below code
                      Code:
                      SetStopLoss(100);
                      The above will place a stop for $100.

                      Please let me know if I can assist you any further.
                      JoydeepNinjaTrader Customer Service

                      Comment


                        #12
                        I have a multi-instrument strategy and I would like each instrument to have a different stoploss amount. How can I differentiate the stoplosses?

                        Comment


                          #13
                          Hello Tdschulz,
                          Unfortunately the cash value method is available for the primary series only.

                          I will forward your feature request to development for future consideration.

                          Please let me know if I can assist you any further.
                          JoydeepNinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by sjsj2732, Yesterday, 04:31 AM
                          0 responses
                          36 views
                          0 likes
                          Last Post sjsj2732  
                          Started by NullPointStrategies, 03-13-2026, 05:17 AM
                          0 responses
                          287 views
                          0 likes
                          Last Post NullPointStrategies  
                          Started by argusthome, 03-08-2026, 10:06 AM
                          0 responses
                          287 views
                          0 likes
                          Last Post argusthome  
                          Started by NabilKhattabi, 03-06-2026, 11:18 AM
                          0 responses
                          133 views
                          1 like
                          Last Post NabilKhattabi  
                          Started by Deep42, 03-06-2026, 12:28 AM
                          0 responses
                          95 views
                          0 likes
                          Last Post Deep42
                          by Deep42
                           
                          Working...
                          X