[PEL] 复制代码
INPUT:X(40,1,200,1),ss(1,1,200,1),N(100,1,200,1);//X是均线参数,SS是手数,N是止盈的点数,默认是100点
MA40:MA(C,X);
FOR I=0 TO 3 DO //循环变量每个收盘时间来进行判断
BEGIN
abb:=timetot0(CLOSETIME(I))-time0,NODRAW;//当前K线时间距离收盘K线结束倒计时
abb3:=timetot0(CLOSETIME(I))-timetot0(dynainfo(207)),NODRAW;//当前时间距离收盘K时间
IF (ISLASTBAR and abb3>=0 and abb3<10*60) THEN MARK:=1;
END
多止损:l<ref(l,1)-3*mindiff and TORDERPRICE(1,1)>0;//最新价小于前一个k最低价-1跳 止损;且前面有开仓信号
空止损:h>ref(h,1)+3*mindiff and TORDERPRICE(1,3)>0;//最新价大于前一个k最高价+1跳 止损
//完善止盈止损的判断。1.判断上次信号到底是什么信号 2.判断当前后台程序化前面有无开仓
多止盈:TTYPE(1)=1 and c-TORDERPRICE(1,1) >=N*MINDIFF and TORDERPRICE(1,1)>0;//盈利N跳 止盈
空止盈:TTYPE(1)=3 and TORDERPRICE(3,1)-c>=N*MINDIFF and TORDERPRICE(1,3)>0;
tsell(多止损 and tbuyholdingex('','',1)>0 and not(MARK),tbuyholdingex('','',1),mkt);
tsellshort(空止损 and tsellholdingex('','',1)>0 and not(MARK),tsellholdingex('','',1),mkt);
tsell(多止盈 and tbuyholdingex('','',1)>0 and not(MARK),tbuyholdingex('','',1),mkt);
tsellshort(空止盈 and tsellholdingex('','',1)>0 and not(MARK),tsellholdingex('','',1),mkt);
//开多,开空条件
kd:C>MA40 and L>MA40 and C>REF(C,1) and C>REF(O,1) and O>=REF(O,1) and H>REF(H,1) and ABS(H-L)<=70*MINDIFF and O>MA40+10*MINDIFF;
kk:C<MA40 and H<MA40 and C<REF(C,1) and C<REF(O,1) and H<REF(H,1) and ABS(H-L)<=70*MINDIFF and O<MA40-10*MINDIFF;
t:time0-timetot0(dynainfo(207));//距离最K结束的时间(秒) 仅在最后一个K正常输出。
tbuy(kd and TBUYHOLDINGEX('','',1)=0 and not(MARK),ss,lmt,h+1*mindiff);//开多
tbuyshort(kk and TSELLHOLDINGEX('','',1)=0 and not(MARK),ss,lmt,l-1*mindiff);//开空
if TISPRVREMAIN(1) and t<=3 then TCANCELEX(1,1,'',STKLABEL);// 不满足突破条件了,在K线结束前3秒进行撤单操作。
if TISPRVREMAIN(3) and t<=3 then TCANCELEX(1,3,'',STKLABEL);
if TENTERBARS(1)=1 and TISPRVREMAIN(1) then TCANCELEX(1,1,'',STKLABEL);
if TENTERBARS(1)=1 and TISPRVREMAIN(3) then TCANCELEX(1,3,'',STKLABEL);