Log in to see Cloud of Tags

Wealth-Lab Wiki

TASC 2013-11 | Reversing MACD: The Sequel (Dough)

RSS

Traders' Tip text

In this issue, author Johnny Dough shares a new tool with the readers: an indicator that anticipates the price when MACD crosses above or below its signal line one bar ahead. It complements the Reverse MACD indicator from the January 2012 issue.

The Reversed MACD Signal indicator is included in the latest version of our TASCIndicators library, allowing Wealth-Lab users to apply it to their charts and strategies, either coded in C# directly or built with the help of the GUI-based Strategy Wizard. In addition, author provides the formulas for reverse functions for MACD indicator based on simple moving averages (SMA) rather than the traditional exponential ones (EMA). They could be found too in the TASCIndicators library. To start using it, please install the TASC Magazine Indicators library from the Extensions section of our website if you haven't done so, or apply the update directly using Wealth-Lab's Extension Manager. In both cases, don't forget to restart Wealth-Lab.

The Strategy code below illustrates its application in Wealth-Lab, buying at stop at the reverse-engineered price when a bullish MACD is crossing above its signal line, and exiting if the opposite criteria has been met after the MACD has turned bearish. Applying the idea to the short side is equally easy: simply reverse the rules. Copy/paste the included Strategy's C# code or simply let Wealth-Lab do the job: in “Open Strategy” dialog, click “Download” to get this strategy's code, as well as many other strategies contributed by the Wealth-Lab community.

Image

Figure 1. A Wealth-Lab 6 chart illustrating the application of the RevEngMACDSignal indicator. Crossovers and crossunders of MACD and its signal line are highlighted in greenish and reddish (respectively).


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( macd[bar] > 0 ) SellAtStop( bar+1, LastPosition, r[bar] ); } else { if( macd[bar] < 0 ) BuyAtStop( bar+1, r[bar] ); } } } } }

Eugene
Wealth-Lab team
www.wealth-lab.com

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.


ScrewTurn Wiki. Some of the icons created by FamFamFam.