Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtesting strategies with trailing stops

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

    Backtesting strategies with trailing stops

    What is the cleanest way to use trailing stops in a strategy (and backtest it) given that:
    - the strategy is based on the 5 minute Bars
    - the function SetTrailStop() works only on a tick by tick basis
    - the data provider only provides historical 1 minute data

    I think the best is to use a multi-bars strategy (primary bars = 1 minute, secondary bars = 5 minutes) with a stop loss updated every minute to trail the profit.
    Or do you think otherwise?

    #2
    That could be one approach that would work.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your reply Josh. What are the other alternatives?

      Comment


        #4
        You could just use SetTrailStop(). Whatever information it has it will use. In backtesting if you are on 5 min bars it will not have the full granularity of a 5min bar trail stop, but if the price is breached it will stop you out.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          My very limited experience with NT shows that the use of this function with 5 minutes bars can imply inaccurate results. For instance, let's say we have this 5-minute bar OHLC = { 100;101;95;96} with a buy @ 96.5 et trailing stop of 2 full points. My backtest results have shown something like this:

          Buy Limit @ 96.5 => (filled)
          SetTrailStop(2.0) => (sell order filled @ 99)??? for a magical profit of 2.5

          Due to the lack of information it's not possible to conclude whether the trailing stop could have been triggered at a price of 95 to 99 or simply not triggered.

          That's why I think SetTrailStop() should only be used on a tick by tick basis as stated in the user guide.

          Comment


            #6
            It can be used anywhere. Whether it is as accurate as possible is not going to be the case if you just don't have intrabar information.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            637 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            366 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            107 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            569 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            572 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X