// Downloaded From https://www.WiseStockTrader.com
Length1 = Param("Length1",10,2,40,2);
Length2 = Param("Length2",20,1,39,2);
Length3 = Param("Length3",9,1,20,1);

// The Moving Average Convergence Divergence calculations
MACD1 = 100 * (DEMA(C,Length1)-DEMA(C,Length2))/C;
MACD2 = DEMA(MACD1,Length3);
MACD3 = MACD1-MACD2;
Plot( Close, "Price", colorBlack, styleCandle );
GraphXSpace = 5;

// Plot the MACD lines.
Plot(MACD1,"MACD1",colorGreen,styleLine|styleLeftAxisScale,-1,1);
Plot(MACD2,"MACD2",colorBlue,styleLine|styleLeftAxisScale,-1,1);
Plot(MACD3,"MACD3",colorRed,styleLine|styleLeftAxisScale,-1,1);
Plot(0,"",colorRed,styleLine|styleLeftAxisScale,-1,1);