//05 测试交易控制符
runmode:0;
variable:cc=0,zs=0,zy=0,daywindot=0,kcj=0;
exittime:=time>=145400;
closetime1:=time>=150500;
{ 信号输出需要添加的代码 --- BEGIN }
{ 变量(writeFileFlag + 3) --- 3是代表策略编号,不同策略编号唯一;
writeFileFlag3 指的是开仓方向: 1-开多 2-平多 3-开空 4-平空 }
globalvariable:writeFileFlag3=0,longFlag=0,shortFlag=0,initFlag=0;
if ISLASTBAR and initFlag = 0 then BEGIN
if holding > 0 then begin longFlag := 1; end
if holding < 0 then begin shortFlag := 1; end
initFlag := 1;
end
{ 信号输出需要添加的代码 --- END }
A:MA(C,M);
B:MA(C,N);
bb:=REF(C,1)>REF(B,1);{bb - 开多条件}
pd:=REF(C,1)<REF(A,1);{pd - 平多条件}
ss:=REF(C,1)<REF(A,1);{ss - 开空条件}
pk:=REF(C,1)>REF(B,1);{pk - 平空条件}
if cc>0 and pd then begin cc:=0; end //平多单 drawtext(1,o,\'2\',colorred,4);
if cc<0 and pk then begin cc:=0; end //平空单
//平空
if holding<0 and cc>=0 then begin
sellshort(1,1,market);
debugfile(\'d:\\jzt\\sinnal14.txt\',\'运行了1次平空,holding是%.2f\',holding);
pcj:=o;
//drawtext(1,o,\'4\',colorgreen,4);
if islastbar && writeFileFlag3 <> 4 && shortFlag = 1 then begin
shortFlag := 0;
writeFileFlag3 := 4;
debugfile2(\'D:\\jzt\\signal3.txt\', numtostr(date+19000000,0) + \',\' + numtostr(time,3) + \',\' + numtostr(writeFileFlag3,0) + \',\'+ \'%.2f\', pcj,0);
debugfile2(\'D:\\jzt\\signal3copy.txt\', numtostr(date+19000000,0) + \',\' + numtostr(time,3) + \',\' + numtostr(writeFileFlag3,0) + \',\'+ \'%.2f\', pcj,0);
end
end
//开空单
if cc=0 and ss then begin
cc:=-1;
zs:=c+c*30/10000;//空单止损条件
zy:=c-c*30*100/10000;//多单止盈条件
end
if exittime then begin
cc:=0;
end
//开空单
if holding=0 and cc<0 then begin
buyshort(1,1,market);
debugfile(\'d:\\jzt\\sinnal14.txt\',\'运行了1次开空,holding是%.2f\',holding);
kcj:=open;
//drawtext(1,o,\'3\',colorgreen,4);
if islastbar && writeFileFlag3 <> 3 && shortFlag = 0 then begin
shortFlag := 1;
writeFileFlag3 := 3;
debugfile2(\'D:\\jzt\\signal3.txt\', numtostr(date+19000000,0) + \',\' + numtostr(time,3) + \',\' + numtostr(writeFileFlag3,0) + \',\' + \'%.2f\', kcj,0);
debugfile2(\'D:\\jzt\\signal3copy.txt\', numtostr(date+19000000,0) + \',\' + numtostr(time,3) + \',\' + numtostr(writeFileFlag3,0) + \',\' + \'%.2f\', kcj,0);
end
end
if closetime1 then begin cc:=0; end