SwissQuantTrader

Two sided mean deviation Indicator [SQT]

Description
The indicator aims at detecting up and down moves that deviate substantially from their respective means. The up and down means are calculated separately taking the last N up or down candles into account (Use N candles). Based on these means the upper and lower bounds are calculated by adding or subtracting the distributions standard deviation (Sigma bounds), multiplied by a user specified factor. After a substantial move, the bounds will either decay sharply to their mean after N up or down candles have passed (Decay: equally weighted) or gradually (Decay: age weighted, weight can be adjusted in the Pine script). The equally weighted decay is meant to model persistent memory whereas the age weighted decay models fading memory of the market over the last N up or down candles. The upper and lower bounds constitute the shaded area. The signal line is simply an EMA with length 3 of the sum of the last 3 percentage changes. These values can be adjusted from the Pine script directly.
Intended use
The signal line leaving the shaded area indicates a substantial move away from the respective mean under the given parameters. This might be interpreted as a signal for the price to revert back to it's mean during the following candles (mean reversion).
Markets
The indicator may be used on any timeseries that is expected to have mean reverting behaviour. Development was done on BTCUSD.P using 5 minute candles.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?