OPEN-SOURCE SCRIPT

1 Year Historical Trend Analyzer

Hey everyone!

This is a new indicator of mine. If you know me, you know I really like Z-Score and there are a lot of cool things that can be done with Z-Score, especially as it pertains to trading!
This indicator uses Z-Score but in a different way from conventional Z-Score indicators (including mine). It uses Z-Score to plot out the current 1 year trend of a stock. Now, 1 year trend is not year to date (i.e. if we are in April, it is not just looking from January to April), but instead, its taking the last 1 trading year of candle data to plot out the trend, ranges and areas of z-score math based supports and resistances.

How it works:

The indicator will look at the current timeframe you are on, whether it be daily, 1 hour, 4 hours, weekly or even monthly. It will then look back the designated amount of candles that constitute 1 trading year. These are preprogrammed into the indicator so it knows to look back X number of Candles based on Y timeframe. This will give you a standard, scaled version of the past 1 year of trading data.

From there, the indicator will calculate the MAX Z-Score (or the highest Z-Score that the stock reached over the 1 trading year) and the MIN Z-score (or the lowest Z-Score that the stock reached over the 1 trading year). It plots these as a red and green line respectively:

snapshot

It will then display the price that the MAX and MIN fall at. Keep in mind, the MAX and MIN price will change as the trading time elapses, but the Z-Score will remain the same until the stock does a lower or higher move from that z-score point.

It will then calculate the mean (average) of the Max and Min and then the mid points between the max and mean, and the min and mean. These all represent mathematical areas of support and resistance and key levels to watch when trading.

The indicator also has a table that is optional. The table can be toggled to either Auto or Manual. Auto will automatically calculate 5 Z-Score Points that are within the proximity of the annual trading range. However, you can select manual and input your own Z-Score values to see where the prices will fall based on the 1 year of data.

Some other options:

You can toggle on and off these midline support and resistance levels in the settings menu. Additionally, you can have the indicator plot actual scaled candles of the 1 year trading history. This is a great function to really see how the support and resistance works. Let’s take a look at RIVN, plotted as candles, on the 1 hour timeframe:

snapshot

In this diagram, we can see two recent points in March where the Z-Score has acted as support for the stock. If we view this in conjunction with the actual ticker, you can see these were great buy points:

snapshot

Do get this functionality, simply go into the plots menu in the settings menu and select “Plot as Candles”.

How to Use it:

While I have discussed some applications of the indicator, namely identify math supports and resistances, targets and such, there are some key things I really want to emphasize that this indicator excels at. I am going to group them for greater clarity:

All time Highs and All Time Lows:

AXP has recently been pushing ATHs. When a stock breaks an ATH or an ATL, it is said that there is no resistance or support. However, with Z-Score that is never true, there are always areas of math resistance and support. We can use this indicator to identify such areas. Let’s look at AXP:

snapshot

Using this as a reference, we can see that AXP broke out of a Z-Score resistance level and re-tested the resistance as support. It held and continued up. We can see that the next area of math resistance is at 270:

snapshot

And 234.65 is support. We would look for the ticker to hold this 234.65 line as support to continue the move up to the 270s.

Similar setup for ATLs with RIVN:

snapshot

We can see that RIVN can indeed make a new ATL because support isn’t until 7.63.

Technical Tips on How to Use:

Because this indicator uses predefined lookback periods based on timeframes, its important that you are analyzing the data with pre-market turned off. The candles are calculated with the assumption that there is no pre-market data.

As well, the lowest timeframe that can be used to get 1 year worth of data is 1 hour. Anything below 1 hour will require you to manually input a lookback length (default is 252) which will be less than 1 year. This is simply because of the limitations of candle lookbacks through Pinescript.

That is not to say that this is not effective on smaller timeframes, it is! You just need to be sure that you understand you are not looking at a year trend worth of data. You can toggle your manual lookback parameters in the settings menu.

Concluding remarks


And that’s the indicator! I know the explanation is lengthy but I really suggest you read it carefully to understand how the indicator works and how you can best use it to analyze tickers and supplement your strategy.

Thanks for reading and safe trades as always!
statisticsTrend Analysis

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 publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


For real-time updates and premium indicators, consider joining my group at: patreon.com/steversteves
Also on:

Disclaimer