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 argusthome, 03-08-2026, 10:06 AM
    0 responses
    79 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
    29 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
    66 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X