[PEL] 复制代码 input:x(20,1,100,1),nmin(10,1,100,1),ss(1,1,10000,1);
x周期高点:=ref(hhv(h,x),1);
x周期低点:=ref(llv(l,x),1);
手数:=ss;
//由于时间进制不同,时间加减需要换算成秒处理后,再转化成时间
end_time:t0totime(timetot0(closetime(0))-nmin*60);
开仓时间:=time>opentime(1) and time<end_time;
平仓时间:=time>=end_time;
//交易条件:
开多平空条件:=high>=x周期高点 and 开仓时间=1;
开空平多条件:=low<=x周期低点 and 开仓时间=1;
//交易系统
dhd:=tbuyholdingex('','',2);
khd:=tsellholdingex('','',2);
if 开多平空条件=1 then begin
平空:tsellshort(khd>0, 手数,lmt,x周期高点);
开多:tbuy(dhd=0, 手数,lmt,x周期高点);
end
if 开空平多条件=1 then begin
平多:tsell(dhd>0,手数,lmt,x周期低点);
开空:tbuyshort(khd=0,手数,lmt,x周期低点);
end
//收盘平仓时间是根据k线时间判断的,使用时需要根据实际周期进行调整,保证平仓时间在应用周期中存在。
if 平仓时间=1 then begin
收盘平多:tsell(dhd>0, 0, lmt,DYNAINFO( 34));
收盘平空:tsellshort(khd>0,0,lmt,DYNAINFO( 28));
end
|