具体源码如下:
//参数:15,2,2,6,10
JJ:=(2*C+H+L)/4;
AA:=EMA(JJ,N1);
BB:=REF(AA,1);
MA1:=MA(C,20);
MA2:=MA(C,55);
TR:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR:=REF(MA(TR,20),1);
DIFF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
MACD:=2*(DIFF-DEA);
//定义限价止损变量
MINPRICE(IF1207)
A:=0.2;
//取合约最小变动价位
HH:=HHV(H,BARSBK+1);
//买开仓位置到现在最高价
LL:=LLV(L,BARSSK+1);
//卖开仓位置到现在最低价
//限价止损模块:
SL:=N2*ATR;
TP:=N3*SL;
DTP:=(N4/10)*SL;
A1:=BKPRICE+TP;
A2:=A1+DTP;
A3:=A1-N5*A;
A4:=HH-DTP;
//以上为根据止赢点差计算多单追踪止赢位置
B1:=SKPRICE-TP;
B2:=B1-DTP;
B3:=B1+N5*A;
B4:=LL+DTP;
//以上为根据止赢点差计算空单追踪止赢位置
CROSS(AA,BB)MA1>MA2TIME>0920TIME=1510||(((C=A1HHA2C0),SP ;
CROSS(BB,AA)MA10920TIME=1510||(((C>=SKPRICE+SL)||(LL=B2C>=B3)||(LL=B4))SKPRICE>0),BP;
AUTOFILTER;