Building A Better Trend Filter

About the Author Jeff Swanson

Jeff is the founder of System Trader Success - a website and mission to empowering the retail trader with the proper knowledge and tools to become a profitable trader the world of quantitative/automated trading.

follow me on:
  • Mark says:

    Hi Jeff,

    I have an easy question and (maybe) a harder question.

    First, you write “The number of shares is scaled based upon a 20-day ATR calculation.” I’m trying to rectify that with $1000 risk/trade. Was the stop ATR(20) and then # shares = $1000 / ATR(20)?

    Second, what are your thoughts about taking redundant signals in backtesting? Suppose the exit for SMA Cross Only were a 5-bar stop and on Days 1, 3, and 5 you got crosses. Typically, redundant signals aren’t included and you would backtest just one open position at a time but can this introduce bias? When should or should these not be included in backtesting analysis and how do they potentially factor into position sizing when making the transition from strategy to system?


    • Hello Mark,

      1) Yes, that’s how the number of shares was determined.

      2) Not sure what you mean by redundant signals in backtesting. Do you mean scaling into/out-of trades?

      • Mark says:

        Redundant signals are subsequent trade signals that occur when a position (in the same direction) has already been taken. For example, if I’m looking for a close above yesterday’s upper Bollinger Band then I might see this on three consecutive days. Typically, backtests wouldn’t include the redundant signals. I just wonder how NOT including them could possibly skew the results. On different occasions, I’ve considered arguments for and against including the redundant signals (how one would trade them in the context of a system is then another question altogether).

        What are your thoughts?

        • Redundant signals, pyramiding or scaling into a trade can be a legitimate way to trade. It all depends upon how you wish to trade. By deciding not to take redundant signals during backtesting, one is not skewing the results. You are simply making a choice not to trade redundant signals, thus those redundant signals are invalid during backtesting. In short they are not part of the plan thus, they are legitimately ignored.

          If you do decide to take redundant signals you will find you need to adjust your risk so that each open position risks no more than your maximum per determined limit. From a coding standpoint, this can complicate the code.

          • Mark says:

            This is not a case of “trade like you backtest.” While you would take the redundant signals for backtesting purposes, you would still trade one position at a time.

            Let me borrow an example from the options world. Many options trades are placed X days to expiration (DTE). To backtest this, you could take 12 trades per year * many years to get a decent sample. If we take 30 as an example, there’s nothing special about 30 DTE. What you really want to backtest is the strategy rather than when the trade is placed. Therefore, you could take the same approach and apply it with 40 DTE, 39 DTE, 38 DTE, 37 DTE, 36 DTE, … 20 DTE, etc. Now, instead of having 12 trades per year in the backtest, you have over 200, perhaps, or maybe every single day of the year. It’s not that in practice you would actually place a trade every single day of the year but rather you’re trying to flush out the arbitrary.

            Any thoughts?

          • Mark, I think I see what you’re saying now. If I understand you correctly and you are simply using a variable to change the days to DTE, I don’t see how this is any different from testing any other trading variable. You have a given trading system and when a setup occurs, the system can trade X days to DTE. This input value (‘X’) can be tested over a range of 1-30 which should be done to test for stability over that range. I think this is a valid test. A poor test result would show dramatic changes between neighboring values. I hope I understood you correctly.

  • Rob says:

    Max intraday drawdown doubles. Do you have concerns about that?

    • That could be an issue. It would need more investigation. In the article I was demonstrating entry techniques thus, the example code does not have stops so, that might be the first item you would need to add.

  • […] Building A Better Trend Filter [System Trader Success] […]

  • >