input:lONG(26),SHORT(12),M(9);
DIFF : EMA(CLOSE,SHORT) - EMA(CLOSE,LONG),COLORRED,linethick0;
DEA : EMA(DIFF,M),COLORMAGENTA,linethick0;
MACD : 2*(DIFF-DEA) ,linethick0;
A:=HHV(DIFF,300);
A*1.3,colorgreen,linethick0;
B:=MACD-REF(MACD,1);
mxa:=max(HHVALL(diff),HHVALL(dea),HHVALL(macd));
mna:=min(LLVALL(diff),LLVALL(dea),LLVALL(macd));
a2:=(mxa+mna)/2;
a3:=mxa-mna;
mxb:=HHVALL(H);
mnb:=LLVALL(L);
b2:=(mxb+mnb)/2;
b3:=mxb-mnb;
diffa:=(diff-a2)*(b3/a3)+b2;
deaa:=(dea-a2)*(b3/a3)+b2;
macda:=(macd-a2)*(b3/a3)+b2;
b4:=-a2*(b3/a3)+b2;
PARTLINE(DIFFA,DIFF REF(DIFF ,1), RGB(0,255,0),1,rgb(255,0,0)), linethick1;
PARTLINE(DEAA,DEA REF(DEA,1),RGB(51,204,204),1,RGB(255,0,255)),linethick1;
STICKLINE(MACD 0 AND B 0,b4,MACDA,1,0),COLORRED;
STICKLINE(MACD 0 AND B 0,b4,MACDA,1,0),COLORGREEN;
STICKLINE(MACD 0 AND B 0,b4,MACDA,1,0),COLORMAGENTA;
STICKLINE(MACD 0 AND B 0,b4,MACDA,1,0),COLORBLUE;