if ref((tmpd=1 or (count(bi=-1,2)=1 and aq1>=1)) and (gpd1 or gpd2),1) then begin
sellshort(1,ss,LIMITR,O);
buy(holding=0,ss,LIMITR,O);
end
多止:valuewhen(enterbars=1,llv(fl,2)),NODRAW;
if enterbars>1 and min(o,c)<=多止-2*MINDIFF then sell(1,ss,marketr);
if holding>0 and ((enterbars>1 and pdd=-1) or (enterbars>15 and aspect=1)) then sell(1,ss,marketr);
if ref((tmpk=-1 or (count(bi=1,2)=1 and aq1>=1)) and (gpk1 or gpk2),1) then begin
sell(1,ss,LIMITR,O);
buyshort(holding=0,ss,LIMITR,O);
end
空止:valuewhen(enterbars=1,hhv(fh,2)),NODRAW;
if enterbars>1 and max(o,c)>=空止+2*MINDIFF then sellshort(1,ss,marketr);
if holding<0 and ((enterbars>1 and pkk=1) or (enterbars>15 and aspect=0)) then sellshort(1,ss,marketr);
请帮忙看看
反手的,平与开不在同一个K上
[此贴子已经被作者于2017/5/16 17:01:44编辑过]
平仓在前一K线,开仓在次K上 。上面语言哪里出问题?
if ref((tmpd=1 or (count(bi=-1,2)=1 and aq1>=1)) and (gpd1 or gpd2),1) then begin
sellshort(1,ss,LIMITR,O);
buy(holding=0,ss,LIMITR,O);
end
平仓反手在图表中,是同时进行的,也就是说在执行sellshort和buy是使用的同一个holding的状态值,所以在平仓后就会造成buy(holding=0,...)条件不满足,。也就是你看到的现象
你可以改成
sellshort(1,holding,LIMITR,O);
buy(1,ss,LIMITR,O);
加上holding=0
buy(1 and holding=0,ss,LIMITR,O);
抱歉前面5楼的解释不对,把实际下单的状态和图表混了。你贴出的完整的平仓反手条件。
sellshort(1,holding,LIMITR,O);
buy(holding=0,ss,LIMITR,O);
或者在
if ref((tmpd=1 or (count(bi=-1,2)=1 and aq1>=1)) and (gpd1 or gpd2),1) and holding<=0 then begin