Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Break even

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

    Break even

    I seem not being able to find an answer...


    I have N opened positions with:

    Code:
            String uniqueName = Time[0].ToString();
    	EnterLongStop  (1, High[0]+ TickSize,uniqueName );
    	SetStopLoss(uniqueName,CalculationMode.Price,Low [0] - TickSize,true );


    My question is how to change stop loss value to be break even plus 1 for all opened orders once price reaches same risk value?

    #2
    Hello,

    Thanks for your post.

    If I have read correctly, your strategy places many individual orders and that you want to individually adjust each one.

    In basic terms, what you would need to do is to retain the unique name created along with the entry price for each order, check each order against the current price to test if your risk value is reached and then change the SetStopLoss value for the associated unique name to the BE+1 level.

    To get the actual entry price for each one you would need to use iorders where the information is exposed: http://www.ninjatrader.com/support/h...tml?iorder.htm

    With the "N" number of iorders you could set your logic to go through each iorder checking the current price to the fill price in the iorder and then reissue the setstoploss for the unique named entry when appropriate.

    Here is a link to a reference code using iorders in the managed approach: http://www.ninjatrader.com/support/f...ead.php?t=7499

    Processing a number of iorders can be made a bit easier through the use of list processing. Here is a link to a thread where that is discussed related to iorders: http://www.ninjatrader.com/support/f...highlight=list

    Comment


      #3
      Originally posted by NinjaTrader_Paul View Post
      Hello,

      Thanks for your post.

      If I have read correctly, your strategy places many individual orders and that you want to individually adjust each one.

      In basic terms, what you would need to do is to retain the unique name created along with the entry price for each order, check each order against the current price to test if your risk value is reached and then change the SetStopLoss value for the associated unique name to the BE+1 level.

      To get the actual entry price for each one you would need to use iorders where the information is exposed: http://www.ninjatrader.com/support/h...tml?iorder.htm

      With the "N" number of iorders you could set your logic to go through each iorder checking the current price to the fill price in the iorder and then reissue the setstoploss for the unique named entry when appropriate.

      Here is a link to a reference code using iorders in the managed approach: http://www.ninjatrader.com/support/f...ead.php?t=7499

      Processing a number of iorders can be made a bit easier through the use of list processing. Here is a link to a thread where that is discussed related to iorders: http://www.ninjatrader.com/support/f...highlight=list
      Right, so if I define:

      Code:
      List<IOrder> ordersList = new List<IOrder>();
      And in OnBarUpdate:

      Code:
              IOrder entryOrder =EnterLongStop  (1, High[0]+ TickSize,uniqueName );
      	ordersList.Add(entryOrder);
      	SetStopLoss(uniqueName,CalculationMode.Price,Low [0] - TickSize,true );
      And then:
      Code:
       foreach (var order in ordersList)
                  {
                      double stopEntry =order.StopPrice;
                  }
      So is this correct? If so, how to get the related stop loss price to determine the new value of stop loss (1R:1R) when BE+1?

      Comment


        #4
        Hello fwz123,

        Thank you for your response.

        You could just assign specific IOrder objects and call their value order.AvgFillPrice plus TickSize for Breakeven plus 1.

        Comment


          #5
          Originally posted by NinjaTrader_PatrickH View Post
          Hello fwz123,

          Thank you for your response.

          You could just assign specific IOrder objects and call their value order.AvgFillPrice plus TickSize for Breakeven plus 1.
          Hi Patrick,


          I'm not sure I follow, I just need to set the stop loss be Breakeven plus 1 when the current price equals the old value.

          Example: long entry at 100, stop loss 96

          So the risk is 4.

          I want to move the stop loss to 100 + 1 when the price is 104 (100 plus the risk 4)

          How can I do this with IOrder?

          Comment


            #6
            Hello,

            Thanks for your reply.

            You would use the iOrders AvgFillPrice as the price to compare to the current price to determine if you can change the stoploss to the desired BE+1.

            So you would need to loop through each iorder and pull the iorder's AvgFillPrice and test if the current price meets your criteria and if it does then reissue the SetStopLoss with the iorder's unique name and the iorder's AvgFillPrice + 1 * TickSize.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            633 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            364 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            105 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            567 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            568 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X