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 argusthome, 03-08-2026, 10:06 AM
    0 responses
    74 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    45 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    26 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    32 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    62 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X