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 ); } } }