[PEL] 复制代码
//构建鳄鱼线
Y:=(H+L)/2;
上唇:Ref((sma(Y,5,1)),3),colorgreen;
牙齿:Ref((sma(Y,8,1)),5),colorred;
下颚:REF((SMA(Y,13,1)),8),colorblue;
R2:=REF(牙齿, 5);
KU1:=IFELSE(H=HHV(H, 3), 1, 0);
KD1:=IFELSE(L=LLV(LOW, 3), 1, 0);
//上分形
UL:=IFELSE (REF(KU1, 2)=1 AND REF(KU1, 1)=0 AND
KU1=0, REF (HIGH, 2), REF(HIGH, 2+BARSLAST(REF(KU1,2)=1 AND REF(KU1,1)=0 AND KU1=0)));
//下分形
DL:=IFELSE (REF(KD1, 2)=1 AND REF(KD1, 1)=0 AND
KD1=0, REF(LOW, 2), REF(LOW, 2+BARSLAST(REF(KD1,2)=1 AND REF(KD1,1)=0 AND KD1=0)));
//定义信号开仓位置
SHANG:=IFELSE(high>=R2, UL, REF (UL, BARSLAST (HIGH>R2)));
XIA:=IFELSE(LOW<=R2, DL, REF (DL, BARSLAST (LOW<=R2)));
//建仓
if C>SHANG AND REF(CLOSE, 1)<REF( SHANG, 1)AND holding<=0 then
begin
sellshort(1,holding,marketr);
buy(1,1,marketr);
end
if C<XIA AND REF(CLOSE, 1)>REF(XIA,1) AND holding>=0 then
begin
sell(1,holding,marketr);
buyshort(1,1,marketr);
end
AO:=sma(y,5,1)-sma(y,34,1);
AC:=sma((AO-sma(AO,5,1)),5,1);
//加仓
if AO>REF(AO, 1) AND REF(AO, 1)>REF(AO, 2) AND AC>REF(AC,1) AND REF(AC,1)>REF(AC, 2)AND C>REF(C,1) and holding=1 then
begin
buy(1,1,marketr);
end
if AO<REF(AO, 1) AND REF(AO,1)<REF(AO, 2) AND AC<REF(AC, 1) AND REF (AC,1)<REF (AC, 2)AND C<REF(C, 1) and holding=-1 then
begin
buyshort(1,1,marketr);
end
//出场,止损止盈
A: =MULTIPLIER;
SL:=100;
TP:=100;
if (c<=enterprice-SL*A or c>=enterprice+TP*A) then sell(1,holding,marketr);
if (c>=enterprice+SL*A or c<=enterprice-TP*A) then sellshort(1,holding,marketr);