Y:=(H+L)/2;
AA:=REF((SMA(Y,5,1)),3);
BB:=REF((SMA(Y,8,1)),5);
CC:=REF((SMA(Y,13,1)),8);
MA1:=MA(CLOSE,5),COLORWHITE,LINETHICK3;
MA2:=MA(CLOSE,10),COLORYELLOW,LINETHICK3;
MA3:=MA(CLOSE,30),COLORDB7093,LINETHICK3;
鳄:CC,COLORFF6600;
齿:BB,COLORRED;
唇:AA,COLORGREEN;
R2:=REF(齿,5);
KU1:=IF(HIGH=HHV(HIGH,3),1,0);
KD1:=IF(LOW=LLV(LOW,3),1,0);
UL:=IF(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:=IF(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)));
上分形:IF(HIGH>=R2,UL,REF(UL,BARSLAST(HIGH>R2))),POINTDOT,LINETHICK3,COLORMAGENTA;
下分形:IF(LOW<=R2,DL,REF(DL,BARSLAST(LOW<=R2))),POINTDOT,LINETHICK3,COLORYELLOW;
AO:=MA(Y,5)-MA(Y,34);
MAO:=MA(AO,5);
AC:=AO-MAO;
AC1:=REF(AC,1);
AO1:=REF(AO,1);
KAC:=IF(AC>AC1 AND AO>AO1,1,0);
KAO:=IF(AC<AC1 AND AO<AO1,-1,0);
STICKLINE(KAC=1 AND CLOSE>=OPEN,OPEN,CLOSE,3,1),COLORRED;
STICKLINE(KAO=-1 AND CLOSE>=OPEN,OPEN,CLOSE,3,1),COLORGREEN;
STICKLINE(KAO=0 AND KAC=0 AND CLOSE>=OPEN,OPEN,CLOSE,3,1),COLORDDDDDD;
STICKLINE(CLOSE>=OPEN,HIGH,CLOSE,0.0,1.0),COLORRED;
STICKLINE(CLOSE>=OPEN,OPEN,LOW,0.0,1),COLORRED;
STICKLINE(KAC=1 AND CLOSE<OPEN,OPEN,CLOSE,3,0),COLORRED;
STICKLINE(KAO=-1 AND CLOSE<OPEN,OPEN,CLOSE,3,0),COLORGREEN;
Buy1:=Filter(KAC=1 And CLOSE>=OPEN,4);
BuyP:=KAO=-1;
Sell1:=Filter(KAO=-1 AND CLOSE>=OPEN,4);
SellP:=KAC=1;
//使用系列模式时
//{平多}EXITLONG:BuyP ,TFILTER;
//{开空}ENTERSHORT:Sell1 ,TFILTER;
//
//{平空}EXITSHORT:SellP ,TFILTER;
//{开多} ENTERLONG:Buy1,TFILTER;
//使用逐K线模式时
variable:DuoKong=1;
OrdVol:=1; {开仓手数}
ZsDs:=10; {止损点数}
//以下变量用于移动止盈,,移动止盈只能保证你尽可能稳健盈利,却不能保证盈利最大化,如果不想使用,可是将总开关设置为0
YdZy:=0; {移动止盈总开关,1为开,0为关}
variable:HighPrice=0,LowPrice=0; {保存开仓后的最高价、最低价}
variable:DHcDs=3,KHcDs=3; {多、空单回撤点数}
variable:DYlDs=7,KYlDs=7; {多、空单盈利点数,当盈利点数达到这个标准后,如果回撤达到上面的参数值就平仓}
variable:Z3B1=0; {赚3保1开关}
variable:MaxProfit=0,CurrentProfit=0; {最大盈利、当前盈利}
//持有空单
If Holding<0 then Begin
If
SellP And Enterbars>2 then begin //平空单
空平:SellShort(1,0,mkt),orderqueue;
End
//止损
If C-Enterprice>=ZsDs then begin
空损:SellShort(1,0,mkt),orderqueue;
End
//移动止盈
If YdZy=1 then begin
//每周期判断是否创新低
If L<LowPrice then begin
LowPrice:=L;
End
If OpenProfit>MaxProfit then begin
MaxProfit:=OpenProfit,linethick0;
End
空最高:MaxProfit,linethick0;
CurrentProfit:=OpenProfit;
//如果盈利超过10点之后回撤达到3点,就平仓,保住盈利
If Enterprice-LowPrice>=KYlDs then begin
If L-LowPrice>=KHcDs Then Begin //回撤超过3点
空赢:SellShort(1,0,market);
End
End
End
//赚3保1
If Z3B1=1 then begin
If Enterprice-LowPrice>=3 then begin
If Enterprice-L<=1.2 then begin
空保:SellShort(1,0,market);
End
End
End
End
//开多单
If holding=0 then begin
If DuoKong=1 Or DuoKong=2 then begin
If Buy1 then begin
多开:Buy(1,ordVol,mkt);
HighPrice:=Enterprice; //将开仓价保存到最高价
End
End
end
//持有多单
If Holding>0 then Begin
If BuyP And Enterbars>2 then begin {平多单}
多平:Sell(1,0,mkt),orderqueue;
End
//多单管理
//止损
If Enterprice-C>=ZsDs then begin
多损:Sell(1,0,mkt),orderqueue;
End
//移动止盈
If YdZy=1 then begin
//每周期判断是否创新高
If H>HighPrice then begin
HighPrice:=H;
End
If OpenProfit>MaxProfit then begin
MaxProfit:=OpenProfit;
End
CurrentProfit:=OpenProfit;
多最高:MaxProfit,linethick0;
多赢额:CurrentProfit,linethick0;
//如果盈利超过10点之后回撤达到3点,就平仓,保住盈利
If HighPrice-Enterprice>=DYlDs then begin
If HighPrice-H>=DHcDs Then Begin //回撤超过3点
多赢:Sell(1,0,market);
End
End
End
//赚3保1
If Z3B1=1 then begin
If HighPrice-Enterprice>=3 then begin
If H-Enterprice<=1.2 then begin
多保:Sell(1,0,market);
End
End
End
End
//开空单
If holding=0 then begin
If DuoKong=1 Or DuoKong=3 then begin
If Sell1 then begin
空开:BuyShort(1,ordVol,mkt);
LowPrice:=enterprice;
End
End
end
最低价:LowPrice,linethick0;
最高价:HighPrice,linethick0;
开仓价:Enterprice,noaxis,linethick0;
持仓:Holding,linethick0;
//收益:asset,noaxis,colorred;
次数:totaltrade,linethick0;
胜率:percentwin,linethick0;
连亏:maxseqloss,linethick0;
连赢:maxseqwin,linethick0;