Log in to see Cloud of Tags

Wealth-Lab Wiki

TASC 2012-12 | Using VIX To Forecast The S&P 500 (Gardner)

RSS

Traders' Tip text

Counting how many times a DataSeries was above/below another DataSeries (e.g. a moving average) can be performed using the SeriesIsAbove/SeriesIsBelow indicators available in our "Community Indicators" library. Considering this, when building Wealth-Lab 6 code for this month's trading strategy we decided to concentrate on the pure charting side of things. Situations when the VIX's Low price was staying above or below its moving average for 11 trading sessions straight were highlighted in bluish and reddish color (see Figure 1).

Image

Figure 1. Daily chart of SPY (SPDR S&P 500) with VIX overlay illustrating Trent Gardner’s approach.

The additional library is available for download to Wealth-Lab customers from our site www.wealth-lab.com ("Extensions" section). To avoid copy/paste, we suggest that Wealth-Lab users would download the code of the trading strategy (see below) by simply clicking the "Download" button in Wealth-Lab's "Open Strategy" dialog (Figure 2).

Image

Figure 2. How to download trading strategies in Wealth-Lab 6.

WealthScript Code (C#)


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

namespace WealthLab.Strategies { public class Gardner12_2012 : WealthScript { protected override void Execute() { Bars vix = GetExternalSymbol( "^VIX", true ); SMA vixSma = SMA.Series( vix.Low, 50 ); SeriesIsAbove sa = SeriesIsAbove.Series( vix.Low, vixSma, 1); SeriesIsBelow sb = SeriesIsBelow.Series( vix.Low, vixSma, 1);

for (int bar = GetTradingLoopStartBar(vixSma.FirstValidValue); bar < Bars.Count; bar++) { if (IsLastPositionActive) { if( sa[bar] >= 11 ) { for( int i = bar; i > bar-11; i-- ) SetBackgroundColor( i, Color.FromArgb( 30, Color.Blue ) ); SellAtMarket( bar+1, LastPosition ); } } else { if( sb[bar] >= 11 ) { for( int i = bar; i > bar-11; i-- ) SetBackgroundColor( i, Color.FromArgb( 30, Color.Red ) ); BuyAtMarket( bar+1 ); } } } HideVolume(); ChartPane psb = CreatePane( 30, false, true ); ChartPane vixPane = CreatePane( 50, false, true); PlotSymbol( vixPane, vix, Color.Silver, Color.Silver); PlotSeries( vixPane, vixSma, Color.Red, LineStyle.Solid, 1 ); PlotSeries( psb, sa, Color.Blue, LineStyle.Histogram, 2 ); PlotSeries( psb, sb, Color.Red, LineStyle.Histogram, 2 ); DrawHorzLine( psb, 11, Color.Blue, LineStyle.Dashed, 1 ); } } }

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.