DIFF : EMA(CLOSE,S) - EMA(CLOSE,P);
DEA : EMA(DIFF,M);
MACD1 : 2*(DIFF-DEA), COLORSTICK;
nn1:=barslast(macd1>0 and ref(macd1<0,1));
nn2:=barslast(macd1<0 and ref(macd1>0,1));
s1:=sum(macd1,nn1+1);
s2:=sum(macd1,nn2+1);
if macd1>0 then macd2:=s1;
if macd1<0 then macd2:=s2;
mm:macd2,nodraw;
drawtext(macd1>0 and ref(macd1<0,1),macd1,numtostr(ref(mm,1),2)),colorred;
drawtext(macd1<0 and ref(macd1>0,1),macd1,numtostr(ref(mm,1),2)),colorgreen;
这个是以前我写的,直接在系统自带的macd公式里面改
DIFF : EMA(CLOSE,S) - EMA(CLOSE,P);
DEA : EMA(DIFF,M);
MACD1 : 2*(DIFF-DEA), COLORSTICK;
nn1:=sumbars(macd1>0 and ref(macd1<0),1);
nn2:=sumbars(macd1>0 and ref(macd1<0),2);
nn:=sumbars(macd1<0 and ref(macd1>0),1);
s1:=ref(sum(macd1,nn),nn1);
s2:=ref(sum(macd1,nn),nn2);
s1是最近一块绿的总和,s2是最近第二块绿的总和,两个相减就是你要的值
nn:=sumbars(macd1<0 and ref(macd1>0),1);
这一句改为
nn:=sumbars(macd1<0 and ref(macd1>0,1),1);