In “Within The Volatility Band” in this issue, author Sylvain Vervoort continues with his fourth installment in his seven-part series. This month, he focuses on using historical price movements to define price volatility and builds price bands using those numbers. His price volatility is found by using a common technical analysis statistic, average true range. For thinkorswim users, we have created a strategy in our proprietary scripting language, thinkScript. You can adjust the parameters of the strategy within the Edit Studies window to fine tune the periods calculated.
A sample chart is shown in Figure 3.
Figure 3: THINKORSWIM. Here is an example of a strategy implemented in thinkorswim based on Sylvain Vervoort’s article in this issue. The strategy is based on average true range and uses historical price movements to define price volatility. It builds price bands using those numbers.
- From TOS charts, select Studies → Edit studies
- Select the Studies tab in the upper left-hand corner
- Select “New” in the lower left-hand corner
- Name the study (such as “VolatilityBand”)
- Click in the script editor window, remove “addOrder(Order Type.BUY_AUTO, no);” and paste in the following code:
input price = hlc3; input averageLength = 8; input volatilityLength = 13; input deviationFactor = 3.55; input lowBandAdjust = 0.9; def typical = if price >= price then price - low else price - low; def deviation = deviationFactor * Average(typical, volatilityLength); def devHigh = ExpAverage(deviation, averageLength); def devLow = lowBandAdjust * devHigh; def medianAvg = ExpAverage(price, averageLength); plot MidLine = Average(medianAvg, averageLength); plot UpperBand = ExpAverage(medianAvg, averageLength) + devHigh; plot LowerBand = ExpAverage(medianAvg, averageLength) - devLow; LowerBand.SetDefaultColor(GetColor(1)); MidLine.SetDefaultColor(GetColor(7)); UpperBand.SetDefaultColor(GetColor(0)); AddOrder(OrderType.BUY_AUTO, close > UpperBand, name = "VolatilityBandLE", tickcolor = GetColor(0), arrowcolor = GetColor(0)); AddOrder(OrderType.SELL_AUTO, close < LowerBand, name = "VolatilityBandLE", tickcolor = GetColor(1), arrowcolor = GetColor(1));