龙听期货论坛's Archiver

龙听 发表于 2018-1-22 21:51

际人学长的MACD红绿柱面积公式(飞狐指标)

input:调整参数(0.1,0.0001,1000),数字位置(1,1,1000);//{input:默认参数,最小值,最大值}
[code]
p:=26;s:=12;m:=9;
DIFF:EMA(c,s) - EMA(c,p);
DEA:EMA(DIFF,m);
MACD:2*(DIFF-DEA),COLORSTICK;
BV:=SUM(MACD/调整参数,0);
BA:=IF(MAX(BV,REF(BV,2))REF(BV,1),1,0);
BC:=BARSLAST(BA)+1;
SMACD:=BV-REF(BV,BC);
涨面积:=FLOOR(SUM(MACD,BARSLAST(MACD<0))/调整参数),linethick0;
跌面积:=FLOOR(ABS(SUM(MACD,BARSLAST(MACD>0)))/调整参数),linethick0;
var3:=if(macd>0,HHV(abs(macd),bc)*数字位置,LLV(macd,bc)*数字位置);
var4:=(macd)/20;{图形比例缩小1/20,可修改}
var5:=SMACD*100;
DRAWNUMBER(CROSS(0,MACD),ref(var3,1),REF(涨面积,1),0),,colorgreen;
DRAWNUMBER(CROSS(MACD,0),ref(var3,1),REF(跌面积,1),0),colorff00ff;
M1:=REF(MACD,1);
STICKLINE(macd>0 and macd<=m1,0,macd,3,0),coloryellow;
STICKLINE(macd<0 and macd>=m1,0,macd,3,0),colorwhite;
jc := dea-diff;
绿柱面积:IF (MACD<0,SUM(MACD,BARSLAST(jc<0))/调整参数,0),linethick0,colorcyan,PRECISION0;
红柱面积:IF (MACD>0,SUM(MACD,BARSLAST(jc>0))/调整参数,0),linethick0,colorred,PRECISION0;

AA1:=IF(MACD>0,1,-1),LINETHICK0;
AA2:=REF(AA1,1),LINETHICK0;
AA3:=AA1*AA2,LINETHICK0;
AA4:=BARSLAST(AA3<0),LINETHICK0;
AA5:=AA4+1,LINETHICK0;
当前面积:SUM(MACD,AA5)/0.10,COLORGREEN,LINETHICK0;
[/code]

页: [1]