Mean Deviation Detector - Throw Out All Other Indicators

I set out this morning to create a script that searches out price moves that went too far too fast relative to historical pricing, given that such situations often result in the most profitable trading opportunities. I came up with the mean deviation detector. This script should be used as a means of judging how far a price is trading, in percent terms, from it's "average trading zone".

This is extremely helpful in a couple scenarios.

First, it can be used to judge a move's volatility relative to it's previous volatility . Put simply, a 5% move in the stock of Coca Cola is a lot more meaningful than a 5% move in the stock of Tesla , and the detector puts moves into historical (visual) perspective.

Second, the indicator can be used in real time as a means of determining when the chances of mean reversion are high or low. Extreme values are unsustainable and often lead to EITHER A.) price mean reversion or B.) time mean reversion. Put simply, prices either went too far and are due to fall back to a historical mean, or they need more time to digest a potentially new pricing zone.

Without getting too deep into volume profile analysis, the MDD can be a simple way of telling that a stock has moved into an "air pocket", where prices will either come back to the previous volume node (price mean reversion) or set up shop in a new, uncharted area (time mean reversion).

An extreme value doesn't always mean a trading opportunity, but it means that something interesting is happening in the stock / instrument.

I use this indicator to help me trade covered calls. Lots of high yielding weekly opportunities are stocks that have moved too far too fast, and I like to use this indicator as a means of either a.) scooping up stocks that have gotten beat up from a historical mean perspective & have likely seen the risk already "beaten" out of them, or to b.) stay away from stocks that have a very high chance of price correcting lower. In situations where I say that the risk has been "beaten" out of something, it doesn't mean that the stock won't continue to fall, it simply means that the degree and acceleration of the fall has peaked and that risk premiums in selling options will / should easily pay for continued losses. In the event that it's a price correction and not a time correction, you also increase your bat rate because you get auto-liquidated at a max profit. It's a really valuable tool in my kit.

You can also feel free to put a Keltner Chanel overlay onto the MDD to filter out noise, identify "extreme" values, and place mean reversion trades if you expect price mean reversion is likely, if you want to use this as the basis of a proper trading strategy. For a high extreme value, you could sell short term OTM call spreads, for example.

The MDD is adaptable to your own trading style & preferences.

Follow me on twitter!
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.


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?