#System '********************************************************************** '* VIX Timing System (VIXTIME) '* by Ryan Olson '* October,2012 '* '* Adapted from Technical Analysis of Stocks and Commodities '* December 2012 '* '* Summary: '* '* This system uses a 50 period simple moving average of the VIX index (vAvg). '* Signals are generated when there are 11 concecutive bars above or below the vAvg. '* For more information see "Using VIX to Forecast The S&P 500", in the December 2012 '* edition of Technical Analysis of Stocks and Commodities. '* '* Parameters: '* '* nUpCount= Counts number of closing bars above vAvg '* '* nDnCount = Counts number of closing bars below vAvg '* '* vAvg= Identifies the Simple Moving Average of the $VIX '* '* vCls= Identifies the close price of the $VIX '* '* Plot= Plots the vAvg price on price chart '* '* Counter= Changes the number of bars required for long/short postions '* '******************************************************************** #PARAM "Periods", 50, 1, 50 #PARAM "Counter", 11, 1, 20 Dim nUpCount as Integer = 0 Dim nDnCount as Integer = 0 Dim vAvg as Integer Dim vCls as Single 'Get close and Simple Moving Average of $VIX vCls = GetClose("$VIX") vAvg = SMA(GetClose("$VIX"), Periods) 'Long Position If vCls <= vAvg then nUpCount += 1 Else nUpCount = 0 End If If nUpCount = Counter then signal = LongSignal End If 'Short Postion If vCls >= vAvg then nDnCount += 1 Else nDnCount = 0 End If If nDnCount = Counter then Signal = ShortSignal End If SetScales(0,100) Plot("Vix", vCLS) Plot("MA", vAVG)