• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 Aporshnev, Today, 11:11 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Started by bc90803, Today, 11:24 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Heath  
    Started by hincal, Today, 10:07 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_RyanS  
    Started by MIKEALV1975, Yesterday, 07:30 AM
    4 responses
    18 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by shawn9876, Today, 09:07 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_Clayton  
    Working...
    X