Monday, April 21, 2008

MACD


MACD as charted by some software vendors.

1 comment:

. said...

inputs: FastLength( 10), SlowLength( 30), MACDLength( 5), Price(Close), Exponential(false) ;
inputs: upColor(Cyan), MaxColor(Blue), dnColor(Magenta), MinColor(Red);
variables: MyMACD( 0 ), MACDAvg( 0 ), MACDDiff( 0 ), AvDiff(0), color(white) ;

if Exponential then begin
AvDiff = xAverage(Price, FastLength) - xAverage(Price, SlowLength);
MACDDiff = xAverage(AvDiff, MACDLength);
MACDDiff = AvDiff - MACDDiff;
end else begin
AvDiff = Average(Price, FastLength) - Average(Price, SlowLength);
MACDDiff = Average(AvDiff, MACDLength);
MACDDiff = AvDiff - MACDDiff;
end;
if MACDDiff > 0 and MACDDiff > MACDDiff[1] then color = maxColor
else if MACDDiff < 0 and MACDDiff < MACDDiff[1] then color = minColor
else if MACDDiff > 0 then color = upColor
else if MACDDiff <= 0 then color = dnColor;

Plot1( MACDDiff, "MACDDiff", color ) ;
Plot2( 0, "ZeroLine" ) ;