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 CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    34 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    129 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    183 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    94 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    138 views
    0 likes
    Last Post cmoran13  
    Working...
    X