【新提醒】反向推算macd、diff、金叉死叉(源码 副图 贴图)
---------------------
MACD公式源码:
DIFF : EMA(CLOSE,SHORT) - EMA(CLOSE,LONG);
DEA : EMA(DIFF,M);
MACD : 2*(DIFF-DEA), COLORSTICK;
由源码可知,MACD的重点是在于快速EMA与慢速EMA的差值。
通过反向推算MACD中Diff,设其明日的值与今天的值相等,便能更好的把握多空能量发生改变时的价位。
EMA=【2x+(N-1)*EMA’】/(N+1);
那么可以得于
明日diff=今日Diff的时候
股价:=(diff*(short+1)*(long+1)-(long+1)*(short-1)*ema(c,short)+(short+1)*(long-1)*ema(c,long))/(2*((long+1)-(short+1)));
我们在MACD的原码里加入两行:
xx:=(diff*(short+1)*(long+1)-(long+1)*(short-1)*ema(c,short)+(short+1)*(long-1)*ema(c,long))/(2*((long+1)-(short+1)));
drawtextabs(5,5,'Diff转向:'+xx);
同理,我们也可以反推出MACD金叉和死叉里的价格。
有同学想知道金叉死叉的价格,实际上其实没有太大操作意义。(详见图2)
根据MACD的值变化反推出来的价格线反而更具操作意义。
黄线是金叉死叉反推价,白线是diff反推价,紫线是macd反推价。
各代码如下:
参数: short(12,1,100,1) long(26,1,100,1) M(9,1,100,1)
DIFF :=EMA(CLOSE,SHORT) - EMA(CLOSE,LONG);
DEA :=EMA(DIFF,M);
MACD :=2*(DIFF-DEA);
jcsc:=(M-1)/(M+1)*dea/(1-2/(m+1));{计算出金叉死叉时的Diff值}
dd:=(macd/2+(dea*(m-1)/(M+1)))/(1-2/(m+1));{计算出明日macd=macd时的Diff值}
xx:(diff*(short+1)*(long+1)-(long+1)*(short-1)*ema(c,short)+(short+1)*(long-1)*ema(c,long))/(2*((long+1)-(short+1)));{计算今日Diff=diff的对应股价}
js:(jcsc*(short+1)*(long+1)-(long+1)*(short-1)*ema(c,short)+(short+1)*(long-1)*ema(c,long))/(2*((long+1)-(short+1)));{计算金叉死叉的对应股价}
ddd:(dd*(short+1)*(long+1)-(long+1)*(short-1)*ema(c,short)+(short+1)*(long-1)*ema(c,long))/(2*((long+1)-(short+1)));{计算macd柱体变向时的对应股价}
[ 本帖最后由 山丘村长 于 2011-4-29 20:28 编辑 ]