if barpos = 0 then
stopprice := l - stopnum;
if aspect = 0 then begin
//多头处理
if l <= stopprice then begin
sell(holding>0,holding,0);
aspect:= 1;
stopprice := h+stopnum;
end
//处理移动的底部
if l - stopnum > stopprice then
stopprice := l-stopnum;
end
if aspect = 1 then begin
//空头处理
if h >= stopprice then begin
sellshort(holding<0,holding,0);
aspect:= 0;
stopprice := l-stopnum;
end
//处理移动的底部
if h + stopnum < stopprice then
stopprice := h+stopnum;
end
dt:=Buy(开仓时间 AND NOT(TYPE(1)=1) and h>=UpperBand and (HOLDING=0) ,lots,LIMITR,Max(Open,UpperBand)+1*MINDIFF),orderqueue;
kt:=BuyShort(开仓时间 and NOT(TYPE(3)=1) and l<=LowerBand and (HOLDING=0) ,lots,LIMITR,Min(Open,LowerBand)-1*MINDIFF),orderqueue;
if dt then begin
buy(dt and NOT(TYPE(1)=1),10%,0);
end;
if kt then begin
buyshort(kt and NOT(TYPE(1)=3),10%,0);
end;
variable:n=0;
variable:m=0;
if barpos = 0 then
stopprice := l - stopnum;
if aspect = 0 then begin
//多头处理
if l <= stopprice then begin
sell(holding>0,holding,0);
aspect:= 1;
stopprice := h+stopnum;
n:=1;
m:=0;
end
//处理移动的底部
if l - stopnum > stopprice then
stopprice := l-stopnum;
end
if aspect = 1 then begin
//空头处理
if h >= stopprice then begin
sellshort(holding<0,holding,0);
aspect:= 0;
stopprice := l-stopnum;
m:=1;
n:=0;
end
//处理移动的底部
if h + stopnum < stopprice then
stopprice := h+stopnum;
end;
dt:=开仓时间 AND NOT(TYPE(1)=1) and h>=UpperBand and (HOLDING=0);
kt:=开仓时间 and NOT(TYPE(3)=1) and l<=LowerBand and (HOLDING=0);
if dt and m=1 then begin
buy(1,10%,0);
end;
if kt and n=1 then begin
buyshort(1,10%,0);
end;
这两句用来是干什么的?
dt:=Buy(开仓时间 AND NOT(TYPE(1)=1) and h>=UpperBand and (HOLDING=0) ,lots,LIMITR,Max(Open,UpperBand)+1*MINDIFF),orderqueue;
kt:=BuyShort(开仓时间 and NOT(TYPE(3)=1) and l<=LowerBand and (HOLDING=0) ,lots,LIMITR,Min(Open,LowerBand)-1*MINDIFF),orderqueue;
这样的胡乱赋值有什么意义?
l <= stopprice 上面代码里面哪里有根据这个判断条件开仓的?不都是l<=LowerBand 才开仓的?
但是确实开仓啦? 没有在最低价突破下轨处开仓 却在 l <= stopprice 时开空了
开仓时间:=time>opentime(1) and time<closetime(0);
平仓时间:=not(islastbar) and time=190000 or islastbar and currenttime>185905;
收盘平多:sell(平仓时间 and holding>0, 0, thisclose);
收盘平空:sellshort(平仓时间 and holding<0,0,thisclose);
variable:n=0;
variable:m=0;
if barpos = 0 then
stopprice := l - stopnum;
if aspect = 0 then begin
//多头处理
if l <= stopprice then begin
sell(holding>0,holding,0);
aspect:= 1;
stopprice := h+stopnum;
n:=1;
m:=0;
end
//处理移动的底部
if l - stopnum > stopprice then
stopprice := l-stopnum;
end
if aspect = 1 then begin
//空头处理
if h >= stopprice then begin
sellshort(holding<0,holding,0);
aspect:= 0;
stopprice := l-stopnum;
m:=1;
n:=0;
end
//处理移动的底部
if h + stopnum < stopprice then
stopprice := h+stopnum;
end;
dt:=开仓时间 AND NOT(TYPE(1)=1) and h>=UpperBand and (HOLDING=0);
kt:=开仓时间 and NOT(TYPE(3)=1) and l<=LowerBand and (HOLDING=0);
if dt and m=1 then begin
buy(1,LOTS,LIMITR,Max(Open,UpperBand)+1*MINDIFF),orderqueue;
end;
if kt and n=1 then begin
buyshort(1,lots,LIMITR,Min(Open,LowerBand)-1*MINDIFF),orderqueue;
end;
//画线
PARTLINE( aspect = 0, stopprice , colorrgb(255,0,0));
PARTLINE( aspect = 1, stopprice , colorrgb(0,255,0));
这是部分代码
没有代码是在l <= stopprice 条件下开仓的,
你觉得这个条件下开仓要么就是感觉错误,要么就是这个时候l<=LowerBand 也满足了
if cross(LowerBand,stopprice) then buyshort(holding=0,1,market);
if cross(stopprice,UpperBand) then buy(holding=0,1,market);
在上面的策略里面加上这样的代码