上一次多头开仓盈利大于50点,则再次buy,怎么描述
variable:n=0;
if holding>0 and 平多条件 then begin
sell;
if c-enterprice>50*mindiff then n:=1;
end
if n=1 then begin
sellshort;
buy;
end
if c-enterprice>50*mindiff then n:=1;
这个全局变量没有信号
2楼是简略写法,具体开平仓及加仓条件,需要楼主自己填写的,以下为简单示例
variable:n=0;
ma5:ma(c,5);
ma20:ma(c,20);
if cross(ma5,ma20) and holding=0 then buy(1,1,market);
if cross(ma20,ma5) and holding>0 then begin
sell(1,1,market);
if c-enterprice>50*mindiff then n:=1;//如果赢利超过50个点,则赋值为1
end
if cross(ma5,ma20) and holding=0 and n=1 then
begin
buy(1,1,market);
n:=0;//加仓后赋值为0
end
2楼是简略写法,具体开平仓及加仓条件,需要楼主自己填写的,以下为简单示例
明白了,原来是N在赋值为1后,没有初始化为0.....