1,谁破5日,谁破10日?
2,执行完半仓平仓后,中间不允许再开单,等全平后再开仓?
VARIABLE:n:=0;
ma5:ma(c,5);
ma10:ma(c,10);
jc:cross(ma5,ma10);
p1:cross(ma5,c);
p2:cross(ma10,c);
if jc and n=0 then buy(holding=0,2,market);
if p1 then
begin
sell(holding>0,0.5*holding,market);
n:=1;
end
if p2 then
begin
sell(holding>0,holding,market);
n:=0;
end
VARIABLE:n:=0;
ma5:ma(c,5);
ma10:ma(c,10);
jc1:cross(ma5,ma10);
jc2:cross(ma10,ma5);
p11:cross(ma5,c);
p12:cross(ma10,c);
p21:cross(c,ma5);
p22:cross(c,ma10);
if jc1 and n=0 then buy(holding=0,2,market);
if p11 then
begin
sell(holding>0,0.5*holding,market);
n:=1;
end
if p21 then
begin
sell(holding>0,holding,market);
n:=0;
end
if jc2 and n=0 then buy(holding=0,2,market);
if p21 then
begin
sell(holding>0,0.5*holding,market);
n:=1;
end
if p22 then
begin
sell(holding>0,holding,market);
n:=0;
end
加进空头怎么空头测不出来。谢谢。
你没有写空头代码啊,你下边加buy sell的还是开多平多。
if p21 then //应该是p12吧?
begin
sell(holding>0,holding,market);
n:=0;
end
VARIABLE:n:=0;
ma5:ma(c,5);
ma10:ma(c,10);
jc1:cross(ma5,ma10);
jc2:cross(ma10,ma5);
p11:cross(ma5,c);
p12:cross(ma10,c);
p21:cross(c,ma5);
p22:cross(c,ma10);
if jc1 and n=0 then buy(holding=0,2,market);
if p11 then
begin
sell(holding>0,0.5*holding,market);
n:=1;
end
if p12 then
begin
sell(holding>0,holding,market);
n:=0;
end
if jc2 and n=0 then buyshort(holding=0,2,market);
if p21 then
begin
sellshort(holding>0,0.5*holding,market);
n:=1;
end
if p22 then
begin
sellshort(holding>0,holding,market);
n:=0;
end
这样写还是不行呢。
VARIABLE:n:=0,m:=0;//开多开空分别设置变量
ma5:ma(c,5);
ma10:ma(c,10);
jc:cross(ma5,ma10);//金叉开多
sc:cross(ma10,ma5);//死叉开空
pd1:cross(ma5,c);//平多条件1
pd2:cross(ma10,c);//平多条件2
pk1:cross(c,ma5);//平空条件1
pk2:cross(c,ma10);//平空条件2
if jc and n=0 then buy(holding=0,2,market);//开仓时要限制holding=0
if pd1 then
begin
sell(holding>0,0.5*holding,market);//平多仓时要限制holding>0
n:=1;
end
if pd2 then
begin
sell(holding>0,holding,market);//平多仓时要限制holding>0
n:=0;
end
if sc and m=0 then buyshort(holding=0,2,market);//开仓时要限制holding=0
if pk1 then
begin
sellshort(holding<0,0.5*holding,market);//平空仓时要限制holding<0
m:=1;
end
if pk2 then
begin
sellshort(holding<0,holding,market);//平空仓时要限制holding<0
m:=0;
end