variable:n=0;
if n=0 and kd then begin
buy(kd ,1,thisclose);
n:=1;
end//开仓语句,记录开仓状态
ifif n=1 and kd2 then begin
buy(kd2 and n=1,1,thisclose);//加仓语句
n:=2;
end
这样加仓了 ,但是如果kd平仓条件到了先平了,由于n不能归0,会导致再次满足kd就无法开仓,而如果使n归0,那仅仅kd平了以后kd可以再开 单如果kd2又满足条件则又会多开一手,请各位大大帮忙解决一
下
不一样啊 仓位都是一手没问题 我的意思是怎么管理n
variable:n=0;
if n=0 and kd then begin
buy(kd ,1,thisclose);
n:=1;
end//开仓语句,记录开仓状态
ifif n=1 and kd2 then begin
buy(kd2 and n=1,1,thisclose);//加仓语句
n:=2;
end
这样加仓了 ,但是如果kd平仓条件到了先平了,由于n不能归0,会导致再次满足kd就无法开仓,而如果使n归0,那仅仅kd平了以后kd可以再开 单如果kd2又满足条件则又会多开一手
也就是开仓和加仓各管各的?
variable:n=0,m=0;
if kd and m=0 then begin
buy....;
M:=1;
end
if m=1 and 平多 then begin
sell........;
m:=0;
end
if n=0 and 加多1 then begin
buy......;
n:=1;
end
if n=1 and 平加多 then begin
sell.......;
n:=0;
end
试验了一下 还是有个问题
variable:d1=0,d2=0,k1=0,k2=0;
if d1=0 and kd then begin
开多1:buy(kd,1,thisclose);
d1:=1;
end
if d1=1 and pd then begin
平多1:sell(pd,1,thisclose);
d1:=0;
end
if d2=0 and kd2 then begin
开多2:buy(kd2,1,thisclose);
d2:=1;
end
if d2=1 and pd2 then begin
平多2:sell(pd2,1,thisclose);
d2:=0;
end
if k1=0 and kk then begin
开空1:buyshort(kk,1,thisclose);
k1:=1;
end
if k1=1 and pk then begin
平空1:sellshort(pk,1,thisclose);
k1:=0;
end
if k2=0 and kk2 then begin
开空2:buyshort(kk2,1,thisclose);
k2:=1;
end
if k2=1 and pk2 then begin
平空2:sellshort(pk2,1,thisclose);
k2:=0;
end
为什么只有一个方向的开平仓 我设计的应该是平仓加反手
要反手的,你把平仓反手写一起
比如这样的
if 反手 then beign
sell.......;
buyshort.....;
end
或者你把条件写直接写IF后面不写前面
比如你喜欢这样
kk:=c>o;
if kk then ....;
写成
if c>o then ..........;