Using Average True Range to Measure Intraday Volatility
Post on: 16 Март, 2015 No Comment
Using Average True Range to Measure Intraday Volatility
Volatility is a measure that allows you to estimate the risk of an asset.
There are different types of volatility:
Implied volatility. This is the estimated volatility of an asset’s price.
Historical volatility. This is the realized volatility of an asset over a specific time period. It is also called the statistical volatility.
For intraday traders and those looking for an easier way to measure volatility, you can use the true range to measure intraday volatility.
The True range indicator was developed by J. Welles Wilder Jr. in the 1970’s. It is a better measure of the intraday volatility than the Range (which the difference between the session/period high and low) because the latter understates the volatility since it only measures volatility that occurs during a bar/session and ignores overnight volatility.
To fix this, the True Range uses the bar’s high, low and previous bar’s close. By combining these variables, the true range considers both the intraday and overnight part of the price’s volatility.
The true range is calculated by taking the greatest of the following variables:
- High (current bar ) less low
- High (current bar) less previous bar’s close
- Previous bar’s close less low (current bar)
Implementing the Average True Range Indicator
First, let us implement the different variables described in the previous paragraph then find which one is the greatest (true range).
a = high — low;
b = high — close[1];
To calculate the average true range (ATR), we simply apply a moving average to the true range.
d = sma(tr, 10);
This will return the 10-bar average true range.
Note that QuantShare already has a built-in function (Atr) that calculates the average true range.
Example :
d = Atr(10);
How Day Traders Measure Intraday Volatility
Let us say you are working with one-minute data and you want to calculate the intraday volatility (Average true range based on session high, low and close).
As you might have guessed, the calculation of the intraday volatility must be based on daily data.
Steps:
- Change the time frame to daily
TimeframeSet(-1);
- Restore the default time frame (one-minute data)
TimeframeRestore();
a = timeframedecompress(a);
plot(a, ATR);
There is also another way to implement the same thing. Here is the formula:
b = TimeframeApply(-1, atr(10));
b = timeframedecompress(b);
plot(b, ATR, colorGreen);
The TimeframeApply function calculates a specific series in a different time frame. It replaces the TimeframeSet and TimeframeRestore functions.
Example of Strategy Using the true range Indicator
Let us implement the following trading system:
- Buy when the intraday volatility as measured by ATR is increasing and when price crosses above 10-bar moving average
- Sell at the end of the trading session
Here is how to create a trading system:
And here is the formula that you should use to implement the above strategy:
rule1 = TimeframeApply(-1, atr(1) > ref(atr(1), 1)); // Ref: Reference previous bar’s value