Log in to see Cloud of Tags

Wealth-Lab Wiki

TASC 2013-02 | Volatility Switch (McEwan)

RSS

Traders' Tip text

In this month's issue, author Ron McEwan presents a simple, intuitive yet seemingly effective new indicator whose purpose is to act as a filter in a trading strategy, facilitating it to adapt to changing market conditions. A change from a trending mode to a mean reverting one is measured through a ratio dividing the number of bars when the Historical Volatility (HV) of the daily close price change in a given lookback period was lower or equal to today's daily ROC's HV.

To take advantage of Volatility Switch in Wealth-Lab's charts, code- and interactive rule-based strategies, all it takes is to install (or update if you haven't done that already) the TASCIndicators library from the www.wealth-lab.com site to its latest version.

To illustrate the application of the new regime filter, we created a demo system that takes entries and exits depending on the market's volatility switch state: above 0.5 it's considered choppy with a potential for mean reversion, and at or below 0.5 it's more likely to trend.

  • Entry rules

  1. If volatility switch is in trend mode, buy at market next bar when today's close crosses above the 10-day simple moving average of close price
  2. If volatility switch is in mean reversion mode, buy at market next bar when the 7-day RSI crosses above 30

  • Exit rules

  1. If volatility switch is in trend mode, sell at market next bar when today's close crosses below the 10-day simple moving average of close price
  2. If volatility switch is in mean reversion mode, buy at market next bar when the 7-day RSI crosses below 60

Image

Figure 1. Daily chart of SPY illustrating the application of a trend/mean reversion trading system powered by McEwan's Volatility Switch filter.

We ran a backtest with $10,000 per trade on 5 years of SPY's Daily data. With real world position sizing and trading costs rules applied, the simplistic system was able to beat Buy&Hold, returning a 26% net profit figure (vs. -6%), proving that the regime switch filter can become a valuable addition to a trader's arsenal. The system's C# code for Wealth-Lab can be found below:

Image

Figure 2. Chart of strategy's equity curve vs. Buy&Hold.

WealthScript Code (C#)


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using TASCIndicators;

namespace WealthLab.Strategies { public class EwanRegimeSwitchStrategy : WealthScript { private StrategyParameter paramPeriod; public EwanRegimeSwitchStrategy() { paramPeriod = CreateParameter("Period", 21, 2, 100, 1); } protected override void Execute() { int period = paramPeriod.ValueInt; VolatilitySwitch voltSwitch = VolatilitySwitch.Series( Close,period );

for(int bar = GetTradingLoopStartBar( period * 3 ); bar < Bars.Count; bar++) { bool regimeSwitchIsTrending = voltSwitch[bar] > 0.5 ? false : true; if (IsLastPositionActive) { Position p = LastPosition; if( regimeSwitchIsTrending ) { if( CrossOver( bar, Close, SMA.Series( Close,10 ) ) ) SellAtMarket( bar+1, p, "Trend exit" ); } else { if( CrossUnder( bar, RSI.Series( Close,7 ), 60 ) ) SellAtMarket( bar+1, p, "MR exit" ); } } else { if( regimeSwitchIsTrending ) { if( CrossOver( bar, Close, SMA.Series( Close,10 ) ) ) BuyAtMarket( bar+1, "Trend" ); } else { if( CrossOver( bar, RSI.Series( Close,7 ), 30 ) ) BuyAtMarket( bar+1, "Mean reversion" ); } } } ChartPane vrsPane = CreatePane( 30,true,true ); PlotSeriesOscillator( vrsPane, voltSwitch, 0.5, 0.499, Color.Coral, Color.DarkGreen, Color.Transparent, LineStyle.Solid, 1 ); HideVolume(); } } }

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.


ScrewTurn Wiki. Some of the icons created by FamFamFam.