Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Moving the stop loss with price movement

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

    Moving the stop loss with price movement

    Dear Support,

    I am trying to create a simple stop loss code. But for some reason I am not able to see the modified stop loss.

    My initial stop loss is 6 point above VMA (Variable moving average), but if the price moves 10 points favorably I want to move the stop loss to Position Avg Price. For some reason I see the initial stop loss on the chart but not the modified one even though the price has moved more than 10 points.

    if (Position.MarketPosition == MarketPosition.Short)
    SetStopLoss(CalculationMode.Ticks, (Instrument.MasterInstrument.Round2TickSize(VMA(vm a1,vma1vol)[0]+ 24*TickSize)));
    else if (Close[0] < Position.AvgPrice - 40 * TickSize)

    SetStopLoss(CalculationMode.Price, Position.AvgPrice);

    Can you please guide me?
    Many Thanks.

    #2
    Hello,

    This should work based on some quick tests here. Are you running on Calculate Bar Close true or false? If this is set to true, the Stop Loss would not be set to the AvgPrice until you receive more than 10 points and the bar has closed.

    If you run this on Calculate on Bar Close = false, do you see this work?
    MatthewNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    61 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    149 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    99 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    286 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X