The double-digit declines in the market in early February over a nine day period are an example of volatile market action. Here I will illustrate how you could automatically adapt your technical indicators to price action. The idea behind this tutorial is to give you an intuitive feel for how it can be done. (See references below to my previous work in this area.)
Chart 1: The 10-day Average True Range (ATR10) in the lower panel shows the rapid expansion in ATR10 from say 200 to 600 during the 9-day sell-off in February. I want to use the expansion in ATR10 to adjust the effective look-back length used in technical analysis.
Measuring Volatility with 10-day Average True Range (ATR10)
I will use the 10-day Average True Range (ATR10) to measure market volatility, but you could use the standard deviation of closing prices, or any other measure. I will focus on the Dow Jones 30 industrials price movements since Dec 29, 2017. If you are unsure about how the Average True Range is calculated, the StockCharts documentation is here. Intuitively, the daily true range is the largest of either today's high minus low or the absolute distance from yesterday's close to today's high or low, to account for a gap higher or a gap lower today. Chart 1 shows the Dow 30 with the 10-day ATR in the lower panel. Observe how the ATR10 was relatively low during the up-trend last year, and then expanded rapidly, from about 200 to about 600 during the 9-day sell-off in early February.
Changing Effective Look-Back Length Using ATR10
I would like to use this expansion in ATR10 to shorten the length of the EMA I am using, so that the effective length of the EMA increases when ATR10 is "low” and the effective length of the EMA shortens when the ATR10 is "high". Of course, once we can adjust the effective length, we can change the response of every other technical analysis indicator. I start by plotting the ATR10, and its 20-day channel in Chart 2. So, I first calculated the ATR10, and then its highest high and lowest low values over the previous 20 days. In Chart 2, you can see that the ATR10 expanded from the bottom of the 20-day channel to the top in early January, and then stayed there through the end of the sell-off, before gradually tapering off to make a 20-day low. The advantage of this approach is that I do not have to worry about the absolute values of the ATR10.
Chart 2: The 10-day Average True Range (ATR10) is shown along with its highest-high and lowest-low values over the previous 20-days. When volatility expands, ATR10 rises to the top of its 20-day channel. Conversely, when volatility falls, ATR10 drops to the bottom of the channel, even though the value may still be higher than the previous time it was at the bottom of its 20-day channel.
Now, let us assume we want to vary the length of the look-back period, or the look-back length from 5-days to 25-days. Hence, when volatility is low, I want to use 25-days to calculate my technical indicators, and when volatility is high, I want to use 5-days to calculate my indicators, which could be moving averages or RSI, or any other indicator. To do this, I convert the data in Chart 2 in to a Range Location Oscillator i.e., the range location oscillator will be 1 when ATR10 is at the top of the channel, and 0 when the ATR10 is at the bottom of its channel (see Chart 3). This approach mimics the stochastic indicator calculation.
Chart 3: The ATR10 location within its 20-day channel from Chart 2 is converted into a range location oscillator (like the stochastic oscillator). When the ATR10 is equal to its 20-day high, the location oscillator is 1. Similarly, when the ATR10 is equal to its 20-day low, the range location oscillator is 0.
If you compare Charts 2 and 3, you will notice that near the beginning, the range location is close to zero since the ATR10 is near the bottom of its 20-day channel. As the ATR10 rises to the top of its 20-day channel, the range location rises to 1. At the right hand edge of Chart 2, the ATR10 is at or near its 20-day lows, and the range location oscillator in Chart 3 drops to zero. Thus, we have found a way to convert the ATR10 expansion and contraction within its flexible 20-day channel into a number between 0-1. You can visually check this in Chart 4 where I have superimposed Charts 2 and 3.
Chart 4: I have superimposed Charts 2 and 3 to show the connection between the range location oscillator (red line) and the location of the ATR10 (blue line) within its 20-day channel (dashed lines). When ATR10 makes new 20-day highs, the range location is 1, and conversely, when ATR10 makes 20-day lows, the range location is 0.
Converting ATR10 Range Location in 20-day Channel into Effective Length
I want to convert the range location in to effective length varying from 5 to 25 days, though you can clearly choose any look-back period you want. In Chart 5, I superimpose the ATR10 range location oscillator (from Chart 3) and the corresponding effective look back length. The two are inversely related. For example, when the red line (left-hand scale), which represents ATR10 making new highs, is at 1, the effective length (orange line, right-hand scale) is at 5 days. As the range location drifts down towards zero at the right hand half of the chart (see also Charts 1-3 above), the orange line, showing effective look back length rises to 25 days. I can use this effective look back length to drive any technical indicator, such as moving averages, RSI or price channels.
Chart 5: The range location oscillator and the effective look back length are inversely related. When one falls, the other rises. When the range location is at 1, then the ATR10 is at the top of its 20-day range, and we use 5-days as the look back length (see middle of charts). As the red line drifts towards zero (see Charts 1 and 2 above), the orange line rises slowly to the top, i.e., the effective look-back length increases.
Calculating Variable Index Dynamic Average
We know that the formula to calculate the index of an exponential moving average is 2/(Length +1), so that as the effective length changes in Chart 5, we can calculate a new index value to drive an exponential moving average. In order to make the average more responsive, we have to take a larger bite out of the new data, and conversely, when we want the average to respond slowly to new data, we take a larger bite of the older data. For example, when the effective length is 5 days, the EMA index is (2/(5+1)) or 0.333, which means we are using 1/3rd the value of the latest close to compute the EMA (large bite from new data). However, when the effective length is 25 days, the EMA index is (2/(25+1)) or 0.0769, which means we are taking a larger bite form the older data (1-0.0769=0.923).
Chart 6: We can convert the effective look-back length (blue line, left-hand scale) into the index for an exponential moving average (orange line, right-hand scale). When the effective look-back length is 5 days, the EMA weight is 0.33, taking a large bite out of new data. When the effective look-back length is 25 days, we are taking a large bite from older data.
I can now plot the daily close of the Dow 30, along with the 5-day EMA, the 25-day EMA and the variable index dynamic average (VIDYA) to show how it moves between the 5-day and 25-day EMAs as its index changes. At the left hand edge of the chart, the ATR10 is at the bottom of the range, and the VIDYA (orange line) is closer to the red dashed line (25-day EMA). As the ATR10 increases, the look-back length of the orange line begins to shorten, and it begins to approach the 5-day EMA (dashed gold line). During the sell-off, the VIDYA is exactly equal to the 5-day EMA. Then, during the market consolidation, the volatility dropped to 20-day lows, and the effective length increased to near 25-days, and the VIDYA (orange line) begins to approach the 20-day EMA (dashed red line). Thus, we have directly used market volatility (measured using ATR10) to construct an EMA that automatically behaved like a 5-day EMA during the sell-off and like a longer 25-day EMA during the consolidation. And we accomplished this automatically without any manual intervention.
Chart 7: The Variable Index Dynamic Average automatically adjusted to expansion in the ATR10 by shortening its effective length to 5-days during the sell-off, and then extending its length to 25-days during the consolidation.
Dynamic or Self-Adjusting Indicators
Since computing power is so easily available, we can make the choice to automatically change the effective look-back length using some measure of market volatility. Other ways to adjust how we display data can also be developed to connect historical market performance to visual presentation of technical analysis indicators. For example, ranking stocks using the Chande Trend Meter is way to alter their presentation in a table using some connection to price action. A third possibility is to switch from daily to intra-day data or weekly data for your analysis based on the effective look-back length. Thus, the ability to connect the effective look-back length to market volatility is a powerful idea that can simplify our trading.
I hope you have enjoyed this exploration of how to automatically adapt to market volatility, and you will subscribe to my blog using the rapid sign-up link below.
1. Tushar Chande: "Adapting Moving Averages to Market Volatility", Technical Analysis of Stocks and Commodities, Vol 10 Num 3, 1992.
2. Tushar Chande and Stanley Kroll: "Stochastic RSI and Dynamic Momentum Index", Technical Analysis of Stocks and Commodities, Vol 11, Num 5, 1993.