mp=marketposition;
if getappinfo(aistrategyauto)=1 then
if not lastbaronchart_s then
cur_bar=currentbar+1
else once cur_bar=currentbar;
//computing order funds
once initial=getrtcashbalance(account);
capital_var=getrtcashbalance(account);
value2=minlist(buyp*0.01*initial,capital_var);
value1=intportion(value2/(close*bigpointvalue*100))*100;
//computing order funds
//trend adjustment
if postradeexitname(1,postradecount(1)-1)="zhs" and mp[1]=1 and mp=0 then
flag2=currentbar;
if mp=0 and currentbar>=cur_bar then
flag1=flag1+1
else flag1=0;
//trend adjustment
//computing price
if cur_bar=currentbar or (mp<>mp[1] and mp=0) or flag1=flag_bar or flag2+flag_bar=currentbar then begin
value11=highest(pricevalue,length);
value22=lowest(pricevalue,length);
value33=intportion(((value11-value22)/(minmove*1 point))/8);
//T+1
value4=0;
fill_array(b1234,0);
fill_array(b1234_tf,false);
for value5=0 to postradecount(0)-1 begin
if postradeisopen(0,value5)=true and postradeentryname(0,value5)="Initial Entry" then begin
b1234[0]=postradesize(0,value5);
if juliantodate(postradeentrydatetime(0,value5))<>date or (bartype_ex>=4 and bartype_ex<=7) then begin
b1234_tf[0]=true;
value4=value4+b1234[0];
end;
end
else if postradeisopen(0,value5)=true and postradeentryname(0,value5)="b1" then begin
b1234[1]=postradesize(0,value5);
if juliantodate(postradeentrydatetime(0,value5))<>date or (bartype_ex>=4 and bartype_ex<=7) then begin
b1234_tf[1]=true;
value4=value4+b1234[1];
end;
end
else if postradeisopen(0,value5)=true and postradeentryname(0,value5)="b2" then begin
b1234[2]=postradesize(0,value5);
if juliantodate(postradeentrydatetime(0,value5))<>date or (bartype_ex>=4 and bartype_ex<=7) then begin
b1234_tf[2]=true;
value4=value4+b1234[2];
end;
end
else if postradeisopen(0,value5)=true and postradeentryname(0,value5)="b3" then begin
b1234[3]=postradesize(0,value5);
if juliantodate(postradeentrydatetime(0,value5))<>date or (bartype_ex>=4 and bartype_ex<=7) then begin
b1234_tf[3]=true;
value4=value4+b1234[3];
end;
end
else if postradeisopen(0,value5)=true and postradeentryname(0,value5)="b4" then begin
b1234[4]=postradesize(0,value5);
if juliantodate(postradeentrydatetime(0,value5))<>date or (bartype_ex>=4 and bartype_ex<=7) then begin
b1234_tf[4]=true;
value4=value4+b1234[4];
end;
end;
end;
//T+1
//order
if currentbar>=cur_bar and flag2+flag_bar<=currentbar then begin
if b1234[1]=0 and close>b2 then
buy("b1") value1 shares next bar at b1 limit;
if b1234[2]=0 and close>b3 then
buy("b2") value1 shares next bar at b2 limit;
if b1234[3]=0 and close>b4 then
buy("b3") value1 shares next bar at b3 limit;
if b1234[4]=0 and close>b4-leg*(minmove*1 point) then
buy("b4") value1 shares next bar at b4 limit;
if b1234_tf[4]=true then
sell("s1") from entry("b4") next bar at s1 limit;
if b1234_tf[3]=true then
sell("s2") from entry("b3") next bar at s2 limit;
if b1234_tf[2]=true then
sell("s3") from entry("b2") next bar at s3 limit;
if b1234_tf[1]=true then
sell("s4") from entry("b1") next bar at s4 limit;
if b1234_tf[0]=true then
sell("Initial_Entry") from entry("Initial Entry") next bar at s4 limit;
sell("zhs") value4 shares total next bar at zhs stop;
tl_setend_bn(arr_num[0],currentbar,mid);
tl_setend_bn(arr_num[1],currentbar,b1);
tl_setend_bn(arr_num[2],currentbar,b2);
tl_setend_bn(arr_num[3],currentbar,b3);
tl_setend_bn(arr_num[4],currentbar,b4);
tl_setend_bn(arr_num[5],currentbar,s1);
tl_setend_bn(arr_num[6],currentbar,s2);
tl_setend_bn(arr_num[7],currentbar,s3);
tl_setend_bn(arr_num[8],currentbar,s4);
end;
//order 作者: masterhdd 时间: 2018-7-11 21:12:03