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 NRITV, Today, 01:15 PM
    2 responses
    6 views
    0 likes
    Last Post NRITV
    by NRITV
     
    Started by frankthearm, Today, 09:08 AM
    7 responses
    31 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Started by maybeimnotrader, Yesterday, 05:46 PM
    5 responses
    26 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by quantismo, Yesterday, 05:13 PM
    2 responses
    19 views
    0 likes
    Last Post quantismo  
    Started by adeelshahzad, Today, 03:54 AM
    5 responses
    33 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Working...
    X