买1开多条件:********;
买1止损条件:********;
买1止盈条件:********;
买1移止条件:********;
if 买1开多条件 and holding<=0 then begin
sellshort(1,0,thisclose);
buy(1,1,thisclose);
end
if 买1止损条件 and holding>0 then begin
sell(1,0,thisclose);
end
if 买1止盈条件 and holding>0 then BEGIN
sell(1,0,thisclose);
end
if 买1移止条件 and holding>0 then BEGIN
sell(1,0,thisclose);
end
买2开多条件:********;
买2止损条件:********;
买2止盈条件:********;
买2移止条件:********;
if 买2开多条件 and holding<=0 then begin
sellshort(1,0,thisclose);
buy(1,1,thisclose);
end
if 买2止损条件 and holding>0 then begin
sell(1,0,thisclose);
end
if 买2止盈条件 and holding>0 then BEGIN
sell(1,0,thisclose);
end
if 买2移止条件 and holding>0 then BEGIN
sell(1,0,thisclose);
end
卖1开空条件:********;
卖1止损条件:********;
卖1止盈条件:********;
卖1移止条件:********;
if 卖1开空条件 and holding>=0 then begin
sell(1,0,thisclose);
buyshort(1,1,thisclose);
end
if 卖1止损条件 and holding<0 then begin
sellshort(1,0,thisclose);
end
if 卖1止盈条件 and holding<0 then BEGIN
sellshort(1,0,thisclose);
end
if 卖1移止条件 and holding<0 then BEGIN
sellshort(1,0,thisclose);
end
卖2开空条件:********;
卖2止损条件:********;
卖2止盈条件:********;
卖2移止条件:********;
if 卖2开空条件 and holding>=0 then begin
sell(1,0,thisclose);
buyshort(1,1,thisclose);
end
if 卖2止损条件 and holding<0 then begin
sellshort(1,0,thisclose);
end
if 卖2止盈条件 and holding<0 then BEGIN
sellshort(1,0,thisclose);
end
if 卖2移止条件 and holding<0 then BEGIN
sellshort(1,0,thisclose);
end
把持仓判断条件写在下单语句中比如
sellshort(holding<0,)
buy(holding=0,)
以上这样,如果有很多组买卖条件,只要不断增加就可以了是吗?
持仓判断写在开平仓函数里,与直接写在外面,有什么区别?请指点一下