
等级: 新手上路
- 注册:
- 2025-6-28
- 曾用名:
|
满足开多条件后,涨2%加仓,再涨2%再次加仓,跌了2%加仓。
INPUT:M(20,5,300,30),SS(1,1,10000,1);
MID : MA(CLOSE,M);//中轨
BB: =ref(mid,1);
B2:=ref(mid,2);
AA:=ref(c,1);
手数:=SS;
//条件:
开多条件:=AA>BB AND BB>B2 and HOLDING=0;//上穿上轨开多
开空条件:=AA<BB AND BB<B2 and HOLDING=0;//下穿下轨开空
平多条件:=C<MID AND HOLDING>0; //下穿中轨平多
平空条件:=C>MID AND HOLDING<0; //上穿中轨平空
variable:n=0;
IF 开多条件 and n=0 THEN
begin
BUY(1,手数,MARKET);
n:=1;
end
if n=1 and close>enterprice*1.02 then
begin
BUY(1,手数,MARKET);
n:=2;
END
if n=2 and close>enterprice*1.02 then
begin
BUY(1,手数,MARKET);
n:=3;
END
IF 开空条件 and n=0 THEN
begin
BUYSHORT(1,手数,MARKET);
n:=1;
end
if n=1 and close<enterprice*1.02 then
begin
BUYSHORT(1,手数,MARKET);
n:=2;
END
if n=2 and close<enterprice*1.02 then
begin
BUYSHORT(1,手数,MARKET);
end
IF 平多条件 THEN SELL(1,手数,MARKET);
IF 平空条件 THEN SELLSHORT(1,手数,MARKET);
|
|