原文地址:笔面积作者:哦t唔登{使用说明:原理是在悟多的分笔分段公式基础上,计算macd的面积, 当笔向上时,只累加红柱面积;当笔向下时,只累加绿柱面积, 面积均取正数(绿柱时为绝对值),以方便扩展到选股公式 假如我这一点理解错误,请不要使用本公式,或者自行修改.} p:=26;s:=12;m:=9; var1:="chzhshch@kxian";{处理k线关系} var2:="chzhshch@bi";{处理笔关系} {var3:="chzhshch@d an";}{处理段关系} diff : ema(close,s) - ema(close,p); dea : ema(diff,m); macd : 2*(diff-dea), colorstick; {计算段的时候,将var2改为var3即可} a1:=barslast(var20); a2:=ref(var2,a1); aa1:=ref(a1+1,1); {到前顶或底的距离} aa2:=-ref(a2,1); var4:=if (aa20,if(macd0,macd,0),if(macd0,macd,0));{上涨只加红柱,下跌只加绿柱} var5:s m(var4,aa1)10;{按比例缩小10倍,使图形保持美观,倍数可调节} {在笔顶底处,标出求和数值} drawtext(var2=1 ,ref(var5,1), +ref(var5,1)),colorred; drawtext(var2=-1 ,ref(var5,1), +ref(var5,1)),coloryellow; drawtext(barstat s=2 and var40,var4, +abs(var5)),align2,colorgreen; drawtext(barstat s=2 and var40,var4, +var5),align2,colorred; b:=barslast(var2=-1)+1; 前一低:=ref(var5,b); a:=barslast(var2=1)+1; 前一高:=ref(var5,a); uu:=backset(barstatus=2,barslast(var2=-1)+1); vv:=uuref(uu,1); ww:=backset(vv,ref(barslast(var2=-1),1)+2); xx:=wwref(ww,1); uu2:=backset(barstatus=2,barslast(var2=1)+1); vv2:=uu2ref(uu2,1); ww2:=backset(vv2,ref(barslast(var2=1),1)+2); xx2:=ww2ref(ww2,1); 一低:ref(ref(var5,1),barslast(vv)); 二低:ref(ref(var5,1),barslast(xx)); 一高:ref(ref(var5,1),barslast(vv2)); 二高:ref(ref(var5,1),barslast(xx2));