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 CarlTrading, Yesterday, 11:51 AM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, Yesterday, 11:48 AM
    0 responses
    23 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-25-2026, 09:53 PM
    0 responses
    30 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 03-25-2026, 09:51 PM
    0 responses
    18 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 03-23-2026, 11:13 AM
    0 responses
    24 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X