请教大师:以下怎么写?
1.开多单持仓到当止损价大于等于成本价时开始加多单仓1手。
2开空单持仓到当止损价小于等于成本价时开始加空单仓1手。
3.所有持仓(包括加仓部分)均以布林线中轨止损。
jc1:holding>0 and MID>AvGENTERPRICE;//多头加仓条件
if jc1 then buy(holding>0,1,market);
jc2:holding<0 and AvGENTERPRICE<MID;//空头加仓条件
if jc2 then buyshort(holding<0,1,market);
zs1:holding>0 and MID<AvGENTERPRICE;//多头止损条件
if zs1 then sell(holding>0,holding,market);
zs2:holding<0 and MID>AvGENTERPRICE;//空头止损条件
if zs2 then sellshort(holding<0,holding,market);
[此贴子已经被作者于2019/2/26 10:16:12编辑过]
请教:这样加入后,会开很多次的单,我只要求开一次单。怎么解决?
VARIABLE:ct1:=0,ct2:=0;
jc1:holding>0 and MID>AvGENTERPRICE;//多头加仓条件
if jc1 then
begin
buy(holding>0 and ct1<2,1,market);
ct1:=ct1+1;
end
jc2:holding<0 and AvGENTERPRICE<MID;//空头加仓条件
if jc2 then begin
buyshort(holding<0 and ct2<2,1,market);
ct2:=ct2+1;
end
zs1:holding>0 and MID<AvGENTERPRICE;//多头止损条件
if zs1 then
begin
sell(holding>0,holding,market);
ct1:=0;
end
zs2:holding<0 and MID>AvGENTERPRICE;//空头止损条件
if zs2 then
begin
sellshort(holding<0,holding,market);
ct2:=0;
end
用全局变量控制试下。