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 argusthome, Yesterday, 10:06 AM
        0 responses
        14 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        11 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        9 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        4 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        31 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X