if maxseqloss=3 then maxseqloss=maxseqloss-3;
我的意思是,当连续出现3次亏损时,下次交易就忽视前几次交易的连续亏损次数。
我最终想表达的意思是,出现连续三次亏损就平仓,等待第二种进场方式。不知正确否,需要用一个全局变量来标识吗?
variable:a=0;
if maxseqloss =3 then a:=1;
if a:=1 then buy();
variable:yinglicishu=0;
yingkui:=exitprice-enterprice;
if 平仓条件 then begin
sell();
end
if ref(平仓条件,1) and yingkui>0 then yingkuicishu:=0;
if 平仓条件 then begin
sell();
end
if ref(平仓条件,1) and yingkui<0 then yingkuicishu:=yingkuicishu+1;
if yingkuisichu =3 then yingkuicishu:=0;
if 开多条件 and yingkui<3 then buy();
i
老师,上面的模版有一个问题就是,当持有多单时,yingkui》0该笔交易是盈利的;当持有空单时yingkui》0该笔交易是亏损的。这个怎么解决呢?
ref(平仓条件,1)为什么要写在里面
variable:ykcs=0;//申明全局变量ykcs
yingkui:=exitprice-enterprice;//计算上次开平仓差值
cound1:=(holding=-1 and ...) ;//当持有空单时且。。。
cound2:=(holding=1 and ...);//当持有多单是且。。。
if cound1 then begin
if holding=-1 then sellshort(1,1,market);//平仓
ifelse(yingkui>=0,ykcs:=ykcs+1,ykcs:=0);//上次交易是否盈利,若盈利则ykcs变为0.否则+1
if holding=0 and ykcs<3 then buy(1,1,market);//若ykcs<3,则反向开仓。若ykcs=3则不再开仓
end
if cound2 then begin//
if holding=1 then sell(1,1,market);//
ifelse(yingkui>=0,ykcs:=0,ykcs:=ykcs+1);//
if holding=0 and ykcs<3 then buyshort(1,1,market);//
end
ifelse(ykcs=3,0,ykcs);//当ykcs=3时,则等待cound3,cound4出现再开仓
cound3:=(holding=0 and ...);//
cound4:=(holding=0 and ...);//
if cound3 then buy(1,1,market);//在没有单的情况下重新开多单
if cound4 then buyshort(1,1,market);//在没有单的情况下重新开空单
1.有问题的是红线的句子会不会存在这个单还没成交,而下面的yingkui计算的是上上次平仓价格和这次的开仓价格差值。
2.ykcs=3回到0后没等到cound3,cound4,就按照 if holding=0 and ykcs<3 then buy(1,1,market);//若ykcs<3,则反向开仓。若ykcs=3则不再开仓。重新开仓了。
3.cound1,cound2中的条件是holding<>0,会不会和下面的if内的holding=0(反向开仓)冲突。
1、你若需要这么精细化的控制 判断单子是否成交的问题 需要用到后台函数
2、你1根K线上同时满足开平条件,那你设置的条件就有问题,需要改进。
3、。。。你都不等于0了 还判断等于0的情况干嘛。
您没给源码con1、cond2可以有无限的可能性情况下,关于模型的前后逻辑性问题,请用户自己判断。
因我们也无法得知您的本意,可能造成误解
1,我就是用下面holding=0,来判断单子是否成交。
2,我问的意思是,当亏损三次后,则出场,不在根据cound1,cound2来循环。等重新有个cound3,cound4满足后。在进行cound1,cound2循环。亏损3次后又。。。
3,我判断holding=0,是在平仓单成交的情况下才开多仓。
我想问的,老师。当令ykcs=3,返回0后,是否会不出现cound3,cound4的情况就直接进入cound1,cound2中的循环。
1 holding这是不能判断是否成交,holding不是实际持仓
你的平仓条件呢?