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 Barry Milan, Yesterday, 10:35 PM
    5 responses
    16 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by DanielSanMartin, Yesterday, 02:37 PM
    2 responses
    13 views
    0 likes
    Last Post DanielSanMartin  
    Started by DJ888, 04-16-2024, 06:09 PM
    4 responses
    12 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by terofs, Today, 04:18 PM
    0 responses
    11 views
    0 likes
    Last Post terofs
    by terofs
     
    Started by nandhumca, Today, 03:41 PM
    0 responses
    8 views
    0 likes
    Last Post nandhumca  
    Working...
    X