Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adjusting stop loss order...

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

    Adjusting stop loss order...

    In my strategy, when I enter a trade I get the results from OnOrderUpdate() and I set my initial stop loss order there. Like so:


    TrailingStop = 8;
    SetStopLoss(strOrder, CalculationMode.Price, order.AvgFillPrice - (TrailingStop * TickSize), true);


    Now when I get so many ticks in profit I want to move my stop loss up to eg: 4 ticks.

    Where would I do this? in OnPositionUpdate() ?

    #2
    OnPositionUpdate() is only called if there has been a change in your position.

    If the condition you're looking for is 4 ticks, you'd want to do this in OnBarUpdate()

    Code:
    if(Close[0] >= order.AvgFillPrice + (4 * TickSize)
    // SetStopLoss @ desired price
    Please have a look at the following sample which shows how to accomplish this:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Ok, thanks for the link. However, the script uses "Position.AvgPrice" but your example in this thread uses "order.AvgFillPrice". I believe it should be Position.AvgPrice, correct?

      Comment


        #4
        I was just quoting your code.

        If you want it based off your entire position, use the Position.AvgPrice.

        If you want it off that specific order, use order.AvgPrice
        MatthewNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        673 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        379 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        111 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        577 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        582 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X