以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请问一下,在序列模式下,标注MACD红绿柱面积的代码,错在哪?  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=54174)

--  作者:ljact
--  发布时间:2013/7/21 21:54:51
--  请问一下,在序列模式下,标注MACD红绿柱面积的代码,错在哪?
DIFF :=EMA(C,12) - EMA(C,26);
DEA  :=EMA(DIFF,9);
MACD :=2*(DIFF-DEA), COLORSTICK;
MJ:=C;
MJ[1]:=macd[1];
if (ref(macd,1)<=0 and macd>0) or (ref(macd,1)>=0 and macd<0) then MJ:=MACD;
else MJ[barpos]:=MJ[barpos-1]+macd[barpos];
drawnumber((refx(macd,1)<=0 and macd>0) or (refx(macd,1)>=0 and macd<0),C,MJ[barpos],0,colormagenta);

--  作者:jinzhe
--  发布时间:2013/7/22 9:31:51
--  

数组用序列,就会最后一根值全部往前赋值成一个值。

 

下列公式用逐k线模式

DIFF :=EMA(C,12) - EMA(C,26);
DEA  :=EMA(DIFF,9);
MACD :=2*(DIFF-DEA), COLORSTICK;
MJ:=C;
MJ[1]:=macd[1];

if (ref(macd,1)<=0 and macd>0) or (ref(macd,1)>=0 and macd<0) and barpos>1 then MJ:=MACD;
if barpos>1 and ref(macd,1)>0 and macd<=0 or ref(macd,1)<0 and macd>=0 then  MJ[barpos]:=MJ[barpos-1]+macd[barpos];
drawnumber((refx(macd,1)<=0 and macd>0) or (refx(macd,1)>=0 and macd<0),C,MJ[barpos],0,colormagenta);


--  作者:ljact
--  发布时间:2013/7/22 20:22:07
--  

是否说明这段代码没法改成序列模式?因为我的指标中,还有其他代码,只能采用序列模式。


--  作者:jinzhe
--  发布时间:2013/7/23 9:07:52
--  
不能用序列,或者说序列很难改,和数组的赋值思路相反
[此贴子已经被作者于2013/7/23 9:08:01编辑过]