using System; using System.Drawing; using WealthLab; using WealthLab.Indicators; using TASCIndicators; using Community.Indicators;namespace WealthLab.Strategies { public class ReversingMACDSequel : WealthScript { protected override void Execute() { // Reversing MACD HideVolume(); RevEngMACDSignal r = RevEngMACDSignal.Series( Close,12,26,9,false ); PlotSeries( PricePane, r, Color.Blue, LineStyle.Dashed, 2 ); // MACD and MACD signal DataSeries macd = MACD.Series( Close ); DataSeries macdSignal = MACDEx_Signal3.Series( Close,12,26,9 ); DataSeries macdHist = MACDEx_Histogram.Series( Close,12,26 ); ChartPane MACDPane = CreatePane( 50, true, true ); PlotSeries( MACDPane, macd, Color.Blue, LineStyle.Solid, 2 ); PlotSeries( MACDPane, macdSignal, Color.Red, LineStyle.Solid, 2 ); PlotSeries( MACDPane, macdHist, Color.Teal, LineStyle.Histogram, 2 ); for(int bar = r.FirstValidValue; bar < Bars.Count; bar++) { if( CrossOver( bar, macdSignal, macd ) ) SetBackgroundColor( bar, Color.FromArgb( 30, Color.Green ) ); if( CrossUnder( bar, macdSignal, macd ) ) SetBackgroundColor( bar, Color.FromArgb( 30, Color.Red ) ); if (IsLastPositionActive) { if( macdbar > 0 ) SellAtStop( bar+1, LastPosition, rbar ); } else { if( macdbar < 0 ) BuyAtStop( bar+1, rbar ); } } } } }