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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    115 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    161 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    83 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    127 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    87 views
    0 likes
    Last Post PaulMohn  
    Working...
    X