Wealth-Lab Wiki

API ChartStyles Community Components Community Indicators IndexDefinitions Knowledge Base Misc Optimizers Pending Deletion PosSizers Providers Standard Indicators TASC Traders Tips TASCIndicators Tutorial Videos Visualizers
RSS

Navigation


Quick Search
»
Advanced Search »


TASC 2012-01 | Reversing MACD (Dough)

RSS

Traders' Tip text

Wouldn't it be cool to anticipate the price when MACD crosses above or below zero and act upon that - one bar ahead? The Strategy code below, based on Johnny Dough's article in this issue, allows Wealth-Lab users to backtest the concept.

The idea is to buy at stop at the reverse-engineered price when the MACD is crossing zero from below and to exit if the opposite criteria has been met. Although we're putting long trades in focus, it's equally easy to apply the idea to the short side as well: simply reverse the rules.

Image

Figure 1.A Wealth-Lab Developer 6.2 chart showing the price equivalent to the Reversed MACD crossing the zero line using Daily data of AAPL (Apple Inc.) The bluish line showing the reversed MACD is constructed using its traditional settings (Close price, periods: 12 and 26).


We've saved you from the trouble of creating the Reversed MACD DataSeries by including it in the TASCIndicators library. Before you can start charting the data series or utilizing it in your strategies, be they coded in C# or built with the help of the GUI-based Strategy Wizard, 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.

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.

WealthScript Code (C#)


using System;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using TASCIndicators;

namespace WealthLab.Strategies { public class ReversingMACD : WealthScript { protected override void Execute() { DataSeries macd = MACD.Series( Close ); ChartPane MACDPane = CreatePane( 30, true, true ); PlotSeries( MACDPane, macd, Color.Red, LineStyle.Solid, 1 ); DrawHorzLine( MACDPane, 0, Color.Blue, LineStyle.Dashed, 1 ); // Reversing MACD RevEngMACD r = RevEngMACD.Series( Close,12,26 ); PlotSeries( PricePane, r, Color.Blue, LineStyle.Dashed, 2 );

for(int bar = r.FirstValidValue; bar < Bars.Count; bar++) { if (IsLastPositionActive) { if( macd[bar] > 0 ) SellAtStop( bar+1, LastPosition, r[bar] ); } else { if( macd[bar] < 0 ) BuyAtStop( bar+1, r[bar] ); } } } } }

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.

Used under license from FMR Corp. Copyright 2008 FMR Corp. All rights reserved.


ScrewTurn Wiki. Some of the icons created by FamFamFam.