Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

30 min trailing stops

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

    30 min trailing stops

    Hi,

    I am developing a strat where the stop is based on the high or low of the previous bar on a rollling basis, so to say that every 30 minutes when a new bar starts, I want the stop to be bought to the high or low of the now previous bar,

    does anyone have any tips/ advice / the code to do this already,

    Thanks in advance,

    Regards,


    Dan

    #2
    Hello,
    If you set SetStopLoss() within OnBarUpdate() the strategy will modify the Stop Loss every time OnBarUpdate() is called and if you set the double value for the StopLoss() to High[1] or Low[1] it will move the stop to the High or Low of the previous bar everytime it is called.
    I have provided a sample below:
    if(ConditionForEntry) && Position.MarketPosition == MarketPosition.Flat)
    {
    EnterLong();
    SetStopLoss(CalculationMode.Price, Low[1]);
    }
    if(Position.MarketPosition == MarketPosition.Long)
    SetStopLoss(CalculationMode.Price, Low[1]);
    More information can be found on the SetStopLoss() method at the following link: http://ninjatrader.com/support/helpG...etstoploss.htm

    Please let us know if you have any further questions.
    Cody B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    24 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    115 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    69 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    225 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    411 views
    0 likes
    Last Post CaptainJack  
    Working...
    X