Z-Score with Buy & Sell Signals

Steversteves アップデート済   
This is my open-source indicator of z-score with buy and sell indicators.
I see there are other z-score indicators, I just am particular about how I like my z-scores calculated and so decided to make my own and add buy and sell signals to help guide me. And I figured I could share it openly here!

What is a Z-Score

A z-score is a statistical measures of the distance, in standard deviations, a value is from its given mean. It is expressed as a standard deviation (or SD). The further a value (in this case, a stock) is from their mean, the more likely a regression to the mean is possible (i.e. a return to the average). So if a stock is trading at 3 standard deviations away from its mean, then we can anticipate it wanting to regress back towards 1 to 0 standard deviations from its mean (i.e. sell off back to a value that brings it closer to that SD).
The inverse is true if it is trading below.

Z-Scores and Stocks
Stocks, like everything in nature, like to trade between -1 and +1 SD away from its mean. Anything above this, we can interpret that there is "stress" on the stock. Anything over 2.50 is tremendous stress on the stock and we can anticipate that it will want to revert to its mean in the near future and bring that value down to at least 1, ideally between the -0.5 and 0.5 range.
Please note, I set the standard VERY high for the indicator to issue a buy and sell signal (</= -2.50 and >/=2.50). Lately with the volatility, stocks have been entering these ranges frequently and so there have been plenty of signals, but traditionally in a stable environment you may not get these signals. I set the bar extremely high because I want to avoid false buy and sell signals (you will still get them though, nothing is perfect!). So the value in this indicator is in interpreting the actual z-score itself, so please be sure you understand exactly what the Z-score is (see the description above).

How the indicator works
The indicator works by calculating the average Z-Score between a stocks high and low. This indicator will present the average deviation a stock has from its high and low average. The higher the Z-Score, the more "overbought" the stock is. The lower the z-score, the more "oversold" the stock is. It uses the previous 500 candles worth of data to calculate its SMA and its Standard deviation in order to calculate the z-score.

Anytime a stock trades 2.50 SDs or more above or below its mean, you will be presented with a Buy or Sell signal, as generally, statistically speaking, after something has travelled 2.50 SDs aware from its mean, there is an increased probability of a reversion happening.

You can use this indicator to determine whether the stock is trading within normal parameters or not and to help you in your analysis as to whether or not a stock could be shorted or longed.

I personally like this for swing trading on the 1 hour chart; however, this can be used on any time from 1 minute to 1 hour. It also allows you to track a stocks progress in its reversion to the mean.

Examples of it in Use:

Gold ETF (ARCA: GLD) on 1 minute

Dow Jones ETF (ARCA: DIA) on 1 minute (my favourite Stock!)

SPY ETF (ARCA: SPY) on 1 hour chart

This is not meant to be placed as a sole and single strategy. It should be used in COJUNCTION with your other strategies to help you make a determination.
No indicator is infallible and should never be relied on 100%!

Please let me know your questions/comments/experiences/recommendations below!

Thanks everyone!

Updated the indicator!

Due to the popularity of this indicator, I decided to make some adjustments to make it even more functional.

What's new?

How buy and sell is signaled:

Buy and sell is now signaled based on historic reversal points instead of just a hard value.

Identification of reversal areas:

The indicator now identifies areas where an equity is trading in "extreme" zones, whether they be overly high (overbought) or overly low (oversold). This is shown with the border. A stock that is overbought will show an orange border area (see below):

And a stock that is oversold will show a green border area (see below):

Histogram Chart:

The chart was changed into a histogram style in order for you to visualize divergences easier and reversal points easier.

Hope you enjoy!
Please check out the tutorial video here.


TradingViewの精神に則り、このスクリプトの作者は、トレーダーが理解し検証できるようにオープンソースで公開しています。作者に敬意を表します!無料で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。 お気に入りに登録してチャート上でご利用頂けます。