在实际开仓过程中,为避免一次性委托所带来的过大点差,应该采取分成5次开仓,每次1/5仓,但是在程序执行开仓时,应该如何设置编程?望解答,万分感谢
abb1:=(time0-timetot0(dynainfo(207)))<=30*60-20*TN OR NOT(ISLASTBAR);
IF TN<5 AND abb1 THEN begin
if holding>0 then buy(1,0.2*手数,thisclose);
if holding<0 then buyshort(1,0.2*手数,thisclose);
TN:=TN+1
end
30分钟K图表上,轮询模式中 间隔1秒轮询1次
[此贴子已经被作者于2019/5/27 16:45:30编辑过]
B1:=0;B2:=0;B3:=0;B4:=0;B5:=0;TN:=1;
abb1:=(time0-timetot0(dynainfo(207)))<=30*60-20*TN OR NOT(ISLASTBAR);
IF TN<5 AND abb1 THEN begin
if B1=0 AND holding>0 then BEGIN buy(1,0.2*手数,thisclose); B1:=1; TN:=TN+1; END
if B1=0 AND holding<0 then BEGIN buyshort(1,0.2*手数,thisclose);B1:=1; TN:=TN+1; END
if B2=0 AND holding>0 then BEGIN buy(1,0.2*手数,thisclose); B2:=1; TN:=TN+1; END
if B2=0 AND holding<0 then BEGIN buyshort(1,0.2*手数,thisclose);B2:=1; TN:=TN+1; END
if B3=0 AND holding>0 then BEGIN buy(1,0.2*手数,thisclose); B3:=1; TN:=TN+1; END
if B3=0 AND holding<0 then BEGIN buyshort(1,0.2*手数,thisclose);B3:=1; TN:=TN+1; END
if B4=0 AND holding>0 then BEGIN buy(1,0.2*手数,thisclose); B4:=1; TN:=TN+1; END
if B4=0 AND holding<0 then BEGIN buyshort(1,0.2*手数,thisclose);B4:=1; TN:=TN+1; END
if B5=0 AND holding>0 then BEGIN buy(1,0.2*手数,thisclose); B5:=1; TN:=TN+1; END
if B5=0 AND holding<0 then BEGIN buyshort(1,0.2*手数,thisclose);B5:=1; TN:=TN+1; END
end
30分钟K图表上,轮询模式中 间隔1秒轮询1次
TN:=1;
//M1:TIME0-TIMETOT0(DYNAINFO(207)),LINETHICK0;//剩余秒数
abb1:=(time0-timetot0(dynainfo(207)))<=TIME0-20 OR NOT(ISLASTBAR);
IF TN=1 AND abb1 THEN begin
if holding>0 then BEGIN buy(1,0.2*手数,thisclose); TN:=TN+1; END
if holding<0 then BEGIN buyshort(1,0.2*手数,thisclose);TN:=TN+1; END
end
abb2:=(time0-timetot0(dynainfo(207)))<=TIME0-40 OR NOT(ISLASTBAR);
IF TN=2 AND abb2 THEN begin
if holding>0 then BEGIN buy(1,0.2*手数,thisclose); TN:=TN+1; END
if holding<0 then BEGIN buyshort(1,0.2*手数,thisclose); TN:=TN+1; END
abb3:=(time0-timetot0(dynainfo(207)))<=TIME0-60 OR NOT(ISLASTBAR);
IF TN=3 AND abb3 THEN begin
if holding>0 then BEGIN buy(1,0.2*手数,thisclose); TN:=TN+1; END
if holding<0 then BEGIN buyshort(1,0.2*手数,thisclose); TN:=TN+1; END
end
abb4:=(time0-timetot0(dynainfo(207)))<=TIME0-80 OR NOT(ISLASTBAR);
IF TN=4 AND abb4 THEN begin
if holding>0 then BEGIN buy(1,0.2*手数,thisclose); TN:=TN+1; END
if holding<0 then BEGIN buyshort(1,0.2*手数,thisclose); TN:=TN+1; END
abb5:=(time0-timetot0(dynainfo(207)))<=TIME0-100 OR NOT(ISLASTBAR);
IF TN=5 AND abb5 THEN begin
if holding>0 then BEGIN buy(1,0.2*手数,thisclose); TN:=TN+1; END
if holding<0 then BEGIN buyshort(1,0.2*手数,thisclose); TN:=TN+1; END
end
30分钟K图表上,轮询模式中 间隔1秒轮询1次
TN:=1;T0:=REF(TIME0,1);
//M1:TIME0-TIMETOT0(DYNAINFO(207)),LINETHICK0;//剩余秒数
abb1:=timetot0(dynainfo(207))>=T0+20 OR NOT(ISLASTBAR);
IF TN=1 AND abb1 THEN begin
if holding>0 then BEGIN buy(1,0.2*手数,thisclose); TN:=TN+1; END
if holding<0 then BEGIN buyshort(1,0.2*手数,thisclose);TN:=TN+1; END
end
abb2:=timetot0(dynainfo(207))>=T0+40 OR NOT(ISLASTBAR);
IF TN=2 AND abb2 THEN begin
if holding>0 then BEGIN buy(1,0.2*手数,thisclose); TN:=TN+1; END
if holding<0 then BEGIN buyshort(1,0.2*手数,thisclose); TN:=TN+1; END
abb3:=timetot0(dynainfo(207))>=T0+60 OR NOT(ISLASTBAR);
IF TN=3 AND abb3 THEN begin
if holding>0 then BEGIN buy(1,0.2*手数,thisclose); TN:=TN+1; END
if holding<0 then BEGIN buyshort(1,0.2*手数,thisclose); TN:=TN+1; END
end
abb4:=timetot0(dynainfo(207))>=T0+80 OR NOT(ISLASTBAR);
IF TN=4 AND abb4 THEN begin
if holding>0 then BEGIN buy(1,0.2*手数,thisclose); TN:=TN+1; END
if holding<0 then BEGIN buyshort(1,0.2*手数,thisclose); TN:=TN+1; END
abb5:=timetot0(dynainfo(207))>=T0+100 OR NOT(ISLASTBAR);
IF TN=5 AND abb5 THEN begin
if holding>0 then BEGIN buy(1,0.2*手数,thisclose); TN:=TN+1; END
if holding<0 then BEGIN buyshort(1,0.2*手数,thisclose); TN:=TN+1; END
end
30分钟K图表上,轮询模式中 间隔1秒轮询1次