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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        50 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        22 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        16 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        22 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        23 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X