问:每一片红柱子的总面积,和每一片绿柱子的总面积。应该如何编写公式?谢谢。飞狐,大智慧 通达信 都可以。
计算MACD红绿柱子的面积的公式
答:飞狐
参数名:参数
............................
参数 10 0.01 1000
............................
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);
BA1:=IF(MACD>0 AND ref(MACD,1)<=0,1,0);
BA:=IF(MACD<0 AND ref(MACD,1)>=0,1,BA1);
BC:=BARSLAST(BA)+1;
SMACD:=BV-REF(BV,BC);
var3:=if(MACD>0,HHV(abs(macd),bc),LLV(macd,bc));
var4:=macd;
var5:=SMACD;
varn:=ref(var3,1);
drawnumber(ref(var4,1)>0 and var4<=0 ,varn,ref(var5,1)*参数/1.0,0),{pxup100,}colorgreen;
drawnumber(ref(var4,1)<0 and var4>=0 ,varn,ref(abs(var5)*参数/1.0,1),0),{pxdn40,}colorff00ff;
drawnumber(islastbar and var4<0,varn,abs(var5)*参数/1.0,0),align2,colorff00ff{,pxup40};
drawnumber(islastbar and var4>0,varn,var5*参数/1.0,0),align2,colorgreen{,pxdn100};
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))*参数/1.0,0),linethick0,colorgreen;
红柱面积:IF (MACD>0,SUM(MACD,BARSLAST(jc>0))*参数/1.0,0),linethick0,colorred;
总股本:FINANCE(1),linethick0;
流通盘:FINANCE(7),linethick0;
股东总数:=FINANCE(50),LINETHICK;
人均持股:流通盘/股东总数*10000,PRECISION2,linethick0;