MT4 ATRStops 指标是很好的止盈止损指标,非常直观。

img_20191003.png

移植到金字塔交易系统中,效果如图
img_20191003(1).png

VARIABLE: CHANNELPERIOD=9,RISK=0.30,SIGNAL=1,LINE=1,NBARS=1000;
VARIABLE:UPTRENDBUFFER=-2,DOWNTRENDBUFFER=-2;

IF BARPOS<CHANNELPERIOD THEN EXIT;

SMAX:=HHV(H,CHANNELPERIOD);
SMIN:=LLV(L,CHANNELPERIOD);
BSMAX:=SMAX-(SMAX-SMIN)*RISK;
BSMIN:=SMIN+(SMAX-SMIN)*RISK;
CSMAX:=REF(BSMAX,1);
CSMIN:=REF(BSMIN,1);

IF (C>CSMAX) THEN  TREND0:=1; 
IF (C<CSMIN) THEN  TREND0:=-1;
IF (TREND0>0 && BSMIN<CSMIN)THEN  BSMIN:=CSMIN;
IF (TREND0<0 && BSMAX>CSMAX)THEN  BSMAX:=CSMAX;
LUTB:=REF(UPTRENDBUFFER,1);
LDTB:=REF(DOWNTRENDBUFFER,1);
IF (TREND0>0) THEN BEGIN
    IF (SIGNAL>0 && LUTB=-1.0) THEN BEGIN
    UPTRENDSIGNAL:=BSMIN;
     IF (LINE>0) THEN  BEGIN
     UPTRENDLINE:=BSMIN;
     UPTRENDLINE,COLORRED;
     END 
END 
ELSE BEGIN
    UPTRENDBUFFER:=BSMIN;
    IF (LINE>0) THEN  BEGIN
    UPTRENDLINE:=BSMIN;
    UPTRENDLINE,COLORRED;
    END 
    UPTRENDSIGNAL:=-1;
END
IF (SIGNAL=2) THEN  UPTRENDBUFFER:=0;   
  DOWNTRENDBUFFER:=-1.0;
  DOWNTRENDLINE:=9999;
END
IF (TREND0<0) THEN BEGIN
IF (SIGNAL>0 && LDTB=-1.0) THEN BEGIN
    DOWNTRENDSIGNAL:=BSMAX;
    IF (LINE>0) THEN  BEGIN
        DOWNTRENDLINE:=BSMAX;
        DOWNTRENDLINE,COLORCYAN;
    END 
END 
ELSE BEGIN
    DOWNTRENDBUFFER:=BSMAX;
    IF (LINE>0)THEN DOWNTRENDLINE:=BSMAX;
    DOWNTRENDSIGNAL:=-1;
END 
  IF (SIGNAL=2)THEN DOWNTRENDBUFFER:=0;    
  UPTRENDBUFFER:=-1.0;
  UPTRENDLINE:=999;
END

标签: none

添加新评论