OPEN-SOURCE SCRIPT

Kalman Filter Trend Breakers

Kalman filter is a recursive algorithm that has been invented in the 1960s to track a moving target, remove any noisy measurements of its position and predict its future position.

In trading, KF might be a good replacement for a moving average, as it reacts to price changes in a different way. Not only it follows price direction, but can also track the velocity of price changes. This specific behaviour of KF is used in this indicator to track changes in trends.

Trend is characterized by price moving directionally, however, any trend comes to pause or complete stop and reversal, as the price changes more slowly (a trend fades into a sideways movement for a while) or the price movement changes direction, thus making a reversal.

This indicator detects the points where such changes occur (trend breaker points), and produces signals, which serve as points of current trend pausing or reversing. By applying different settings for KF calculation, you can produce less or more signals that indicate change in trend character, and either detect only significant trends changes, or less and shorter trends changes as well.

The signals do not differentiate the exact type of a trend change (it can be a brief trend pause followed by a continuation, as well as a complete reversal). However, once you are in a trend, the significant velocity change indicates a change in trend structure. In this sense, trend breaker signals should not be followed blindly, and can be used only as trend (and position) exit confirmations, but not the entry contrarian confirmations.

For better visual representation, you can use chart signals attached to bars, and additionally a vertical gradient which shows significant trend velocity change.

Disclaimer