TASC 2008-07 | Leader Of The MACD (Siligardos)

Modified on 2010/09/12 11:20 by Eugene — Categorized as: TASC Traders Tips

Programming "complex" divergences in Wealth-Lab 6 is not complex and can be accomplished in different ways (for example, see February Traders' Tip "Trading Divergences"). Here we present an alternative approach that identifies a divergence between price and the "Leader of the MACD" when it fails to confirm a highest high, in its turn, creating a lower peak. (To save space, the rules are for short trades but reversing them is pretty easy.)

Figure 1. Illustrating on a short trade in Sugar futures, the "Leader of the MACD" helps spot a complex bearish divergence.

Strategy Code

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

namespace WealthLab.Strategies { public class LeaderOfMACD : DataSeries { public LeaderOfMACD ( Bars bars ) : base(bars,"Leader of the MACD") { EMACalculation cm = EMACalculation.Modern; EMA ema12 = EMA.Series( bars.Close, 12, cm ); EMA ema26 = EMA.Series( bars.Close, 26, cm ); DataSeries Indicator1 = ema12 + EMA.Series( bars.Close - ema12, 12, cm ); DataSeries Indicator2 = ema26 + EMA.Series( bars.Close - ema26, 26, cm );

for (int bar = FirstValidValue; bar < bars.Count; bar++) this[bar] = Indicator1[bar] - Indicator2[bar]; } public static LeaderOfMACD Series( Bars bars ) { LeaderOfMACD _LeaderOfMACD = new LeaderOfMACD( bars ); return _LeaderOfMACD; } }