Repainting indicators and offsets

Most of indicators only use past candles when being computed. In example, in order to compute an SMA(20) at a candle X we'll use use 20 candles, from X-19 to X. That's a natural kind of behavior for a lot of indicators. However, some indicators differ from that in a big way. In order to compute a value for a candle X, these special indicators will also use candles "from the future", after X. I.e., X+1 or X+2. There's really no good name for that, but that is one example of a broader universe of "repainting indicators".

Screenshot from 2024-05-07 17-07-20.png
Figure 1: when computing SMA(20) at candle X, it only uses candles which are "in the past" from X (all the candles in the orange box).

Why some indicators repaint

Indicators like that are not new. ZigZag or Bill Williams Fractal are two good old examples. The Fractal indicator marks local extremum points which dominate over 2 candles to the left from them and to the right from them. When you talk real time trading, "to the right" from the current candle means "in the future". The Fractal indicator can never generate a point sooner than after 2 candles since the extremum point (i.e., Highest High) originally emerges. Which means that in real time, Fractal points always emerge "in the past" (2 candles ago for a standard version of Fractals).

Screenshot from 2024-05-07 17-10-00.png
Figure 2: in order to identify a Fractal point at X, this indicator also uses candles X+1 and X+2. When trading in real time, these do not exist yet when X is "the last candle".

By design, some indicators need data "from the future" in order to be computed. It's very important to be aware whether the indicator you're using is doing that when using it. If it is, that does not render it useless, but definitely demands some special approaches.

Why repainting indicators can be dangerous

While these indicators are good legitimate tools for some scenarios, using them in a way which ignores their nature is dangerous, I.e., it's easy to backtest a strategy which buys at Williams Fractal Low and then sells 2 candles after. Guess what happens. By the very definition, Fractal Low is the lowest point surrounded by 2 highest points at both sides. So a strategy like that will be very much profitable. The caveat here is that when trading in real time, you can never buy at a Fractal point because Fractal indicator can never give a signal on the "current candle". It always gives signals which 2 candles deep in the past.

On TrendSpider, we mark these indicators with a special flag, so that when you use them anywhere (Scanner, Alerts, Strategy Tester, Smart Checklist etc) you would be at least aware of that aspect. In general, we strongly advise one to learn about the indicators they are going to trade off, for as much as possible.

How to backtest repainting indicators

If you want to use an indicator like that in a strategy, then as a rule of a thumb, you should never use the "last value" of this indicator in your conditions. Any time you use then indicator's value, you should refer to "X candles ago" (along with the counterpart of a condition, if applicable). "X candles ago" should be equal to the amount of candles after which the indicator's value has stabilzied and won't change. In example, for classic Williams Fractal, X would be 3.

May 23, 2024

Contact Us

Not finding what you're looking for? Contact Us Directly