input:n1(32,6,50,1);
W1:=-100*(HHV(H,N1)-C)/(HHV(H,N1)-LLV(L,N1))+50;
T1:=TIME>093000 AND TIME<143500;
T2:=TIME>150500;
if W1>45 AND REF(ANY(W1>45,9),1) AND BIAS>-55 then begin
sellshort(holding<0, 0, thisclose);
buy(holding=0 AND T1, 1, thisclose);
end
if l<ref(l,enterbars+1)-25*mindiff then sell(holding,0,marketr);这个止损指令是我加的,意图:当持有多单,如价格低于开仓时的前一根k线(以K线结束下单的话,开仓点是不是下一根K线)的低点的25个价位。市价止损。持有空单反之,老师看一下编写的对不对。
if HHV(H,5)>1.0094*C OR T2 then sell(holding>0, 0, thisclose);
if W1<-45 AND REF(ANY(W1<-45,9),1) AND BIAS<55 then begin
sell(holding>0, 0, thisclose);
buyshort(holding=0 AND T1, 1, thisclose);
end
if h>ref(h,enterbars+1)+25*mindiff then sellshort(holding,0,marketr);
if C>1.0094*LLV(L,5) OR T2 then sellshort(holding<0, 0, thisclose);
今天测试止损单没有发出是怎么回事?
没弄明白楼主的意图.
//运行周期:
//运行模式:固定时间间隔,1秒轮询
//运行品种:
楼主其实是想开仓平仓,包括楼主加的止损,都是---提前1-10秒下单?
还是有K线走完下单,有提前1-10秒下单?
以上用于5分钟周期的模型,我想固定轮询1秒,开平仓在信号出来以后,k线结束提前3秒开平仓。止损先不要了
没有对策略本身进行完善
以下只给出了固定时间间隔下提前N秒下单的方法,供您参考
//加入参数及变量来控制提前及秒下单
input:sec(5,1,60,1);//提前5秒下单参数
abb:=(time0-timetot0(dynainfo(207))<=sec) or not(islastbar); //提前5秒下单变量
.......
//把两个带有REF的条件移出
con1:=REF(ANY(W1>45,9),1);
con2:=REF(ANY(W1<-45,9),1);
if abb then
begin
....//开平仓语句
end
6楼已经回帖,不知道您是否看到了.能否满足您的需求
谢谢