TASC 2012-08 | Sector Rotation Model (Siligardos)

Modified on 2014/01/07 11:28 by Eugene — Categorized as: TASC Traders Tips

Traders' Tip text

The WealthScript code to produce the SRMind oscillator is given below. Wealth-Lab customers should create and update a DataSet with the Sector ETF symbols and then click any symbol in any DataSet to run the script. Solidly positive for virtually every day 2012, the SRMind oscillator appears to suggest that the S&P 500’s recent setback to the 200-day moving average (Figuire 1) will be just that – a setback, despite the fundamental backdrop of Europe’s expanding crisis.


Image
Figure 1. SRMind oscillator atop the S&P 500 index, which recently tested the 200-day moving average.


Tip: Don't copy! Instead, use the Strategy Download feature in the Strategy Explorer (Ctrl+O)

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

namespace WealthLab.Strategies { public class SRMind : WealthScript { StrategyParameter _lookback; StrategyParameter _maPeriod; public SRMind() { _lookback = CreateParameter("Lookback Period", 75, 20, 200, 5); _maPeriod = CreateParameter("MA Period", 200, 50, 200, 25); } protected override void Execute() { int lbp = _lookback.ValueInt; DataSeries xly = GetExternalSymbol("XLY", true).Close; // Consumer Discretionary DataSeries xlf = GetExternalSymbol("XLF", true).Close; // Financial DataSeries xle = GetExternalSymbol("XLE", true).Close; // Energy DataSeries xlu = GetExternalSymbol("XLU", true).Close; // Utilities DataSeries xlp = GetExternalSymbol("XLP", true).Close; // Consumer Staples DataSeries bear = (ROC.Series(xle, lbp) + ROC.Series(xlu, lbp) + ROC.Series(xlp, lbp)) / 3d; DataSeries bull = (ROC.Series(xly, lbp) + ROC.Series(xlf, lbp)) / 2d; DataSeries srm = 100 * (bull - bear); srm.Description = "SRMind"; ChartPane srmPane = CreatePane(40, true, true); PlotSeriesOscillator(srmPane, srm, 0, 0, Color.LightGreen, Color.LightPink, Color.Black, LineStyle.Solid, 1); DataSeries sma = SMA.Series(Close, _maPeriod.ValueInt); PlotSeries(PricePane, sma, Color.Blue, LineStyle.Solid, 2); } } }