以下代码有何问题??这超全局变量,弄晕了
我自己看来extgbdata('buypart'),应该和holding一致才对。
根据输出,holding开多或空的时候会变一下,然后又变成0。不明其中奥妙
runmode:0;
aaa:=ref(count(c>o,2),1)=2;
bbb:=ref(count(c<o,2),1)=2;
if islastbar then begin
if extgbdata('buypart')<0 && aaa then begin
sellshort(1,0,thisclose);
extgbdataset('buypart',0);
msgout(1,'平空');
end
if extgbdata('buypart')>0 && bbb then begin
sell(1,0,thisclose);
extgbdataset('buypart',0);
msgout(1,'平多');
end
if extgbdata('buypart')=0 && aaa then begin
buy(1,1,thisclose);
extgbdataset('buypart',1);
msgout(1,'开多');
end
if extgbdata('buypart')=0 && bbb then begin
BUYSHORT(1,1,thisclose);
extgbdataset('buypart',-1);
msgout(1,'开空');
end
msgout(1,'buypart:' & numtostr(extgbdata('buypart'),0)&';holding:' & numtostr(holding,0));
end;
以下是部分输出
------------------------------------------------------------
2015/05/14 17:16:51 buypart:-1;holding:0
2015/05/14 17:16:54 buypart:-1;holding:0
2015/05/14 17:16:58 平空
2015/05/14 17:16:58 开多
2015/05/14 17:16:58 buypart:1;holding:1
2015/05/14 17:16:59 buypart:1;holding:0
2015/05/14 17:17:01 buypart:1;holding:0
2015/05/14 17:17:04 buypart:1;holding:0
想了一下,是不是因为逐K模式,从头刷了一次,把holding搞成0了?
以buypart=1为例,从头刷一次,只可能触发平多,所以holding变0了
那,是不是说如果要buypart和holding相同,只能是后台交易的序列模式?
这后台没权限我也不知道后台的序列模式是不是这样?!
反正有点头晕