v1:=ema(close,2);
v2:=ema(ema(close,5)*1.01,10);
多1:=CROSS(v1,v2);
空1:=CROSS(v2,v1);
多开1:=BARSLAST(多1);
空开1:=BARSLAST(空1);
开仓1:=IF(多开1<=空开1, 1,2);
开多1:=(开仓1=1) ;
开空1:=(开仓1=2) ;
variable:ss:=1;
variable:num=0;
if ss=s then num:=0;
if ss=1 then num:=1;
if 开多1 then
begin
TSELLSHORT(1,HOLDING,MKT);
Tbuy(开多1,ss,MKT);
if num=1 then
ss:=ss+1;
else if num=0 then
ss:=ss-1;
end
if 开空1 then
begin
Tbuyshort(1 ,1,MKT);
Tbuyshort(开空1,ss,MKT);
if num=1 then
ss:=ss+0.1;
else if num=0 then
ss:=ss-1;
end
v1:=ema(close,2);
v2:=ema(ema(close,5)*1.01,10);
多1:=CROSS(v1,v2);
空1:=CROSS(v2,v1);
多开1:=BARSLAST(多1);
空开1:=BARSLAST(空1);
开仓1:=IF(多开1<=空开1, 1,2);
开多1:=(开仓1=1) ;
开空1:=(开仓1=2) ;
variable:ss:=1;
variable:num=0;
if ss=s then num:=0;
if ss=1 then num:=1;
if 开多1 then
begin
TSELLSHORT(1,HOLDING,MKT);
Tbuy(开多1,ss,MKT);
if num=1 then
ss:=ss+1;
else if num=0 then
ss:=ss-1;
end
if 开空1 then
begin
Tbuyshort(1 ,1,MKT);
Tbuyshort(开空1,ss,MKT);
if num=1 then
ss:=ss+0.1;
else if num=0 then
ss:=ss-1;
end