开仓时:满足开仓条件,出现同向开仓信号后,忽略掉前两个信号,直到出现第三个信号后才开仓
平仓时:满足平仓条件,出现平仓信号就平仓。
请问该如何解决
VARIABLE:n=0;
if 开仓条件 then n:=n+1;
if 开仓条件 and n=3 THEN
begin
buy(holding=0,1,market);
n:=4;
end
if 平仓条件 then
sell(holding>0,1,market);
一个开仓信号一个平仓信号
哪里不复合您的要求请指出来
pk:=a<b and l>b ;
kd:=a<b and l>b ;
pd:=a<b and h<a ;
kk:=a<b and h<a ;
if kd then n:=n+1;
if kd and n=3 THEN begin
开多:buy(holding=0,1,market);
n:=4;
end
if pd then 平多:sell(holding>0,1,market);
if kk then n:=n+1;
if kk and n=3 THEN begin
开空:buyshort(holding=0,1,market);
n:=4;
end
if pk then 平空:sellshort(holding>0,1,market);
这段代码是这么写的,你帮忙看下哪里出问题了?
把n:=4 改成n:=0;
VARIABLE:n=0;
if 开仓条件 then n:=n+1;
if 开仓条件 and n=3 THEN
begin
buy(holding=0,1,market);
n:=0;
end
if 平仓条件 then
sell(holding>0,1,market);
从左边开始,出现第一个信号是平多开空,执行之前的平多操作,
单这里的开空信号是第一个,忽略掉
然后第二个开空信号也忽略掉,
再第三个开空信号那里执行开空操作,后面出现的信号不加仓,
出现平空开多信号后,平掉空单,第一个多单信号,忽略掉
然后出现平多开空信号,这里没有操作
然后等出现第三个开空信号执行开空操作
以此类推,不知道能不能说明白