载入中...
在线检测未来函数
载入中...

通达信线性回归主图指标公式

来源:Internet,编辑:股旁网,2019-08-13

EM01:=EMA(C,10);
EM:=EMA(C,21);
UP:=EMA(EM,13);
DOWN:=EMA(EM,17);
MIDD:(UP+DOWN)/2,POINTDOT;
STICKLINE(MIDD>REF(MIDD,1),UP,DOWN,1,0),COLORMAGENTA;
STICKLINE(MIDD<REF(MIDD,1),UP,DOWN,1,0),COLORGREEN;
STICKLINE(MIDD=REF(MIDD,1),UP,DOWN,1,0),COLORGRAY;
止盈线:EMA(EMA(C,10),10),COLORYELLOW,LINETHICK1;
空止盈:=止盈线>REF(止盈线,1);
IF(空止盈-1,止盈线,DRAWNULL),COLORCYAN,LINETHICK1;
DRAWICON(REF(MIDD,1)<=REF(MIDD,2) AND MIDD>REF(MIDD,1),DOWN,7);
DRAWICON(REF(MIDD,1)>=REF(MIDD,2) AND MIDD<REF(MIDD,1),UP,8);
{线性回归画线}
UR:=15;LR:=15;{可调}
TC1:=IF(C=HHV(C,5*UR),C,DRAWNULL);
TC2:=CONST(BARSLAST(TC1=C))+1;
BC1:=IF(L=LLV(L,5*LR),L,DRAWNULL);
BC2:=CONST(BARSLAST(BC1=L))+1;
NOD:=(IF(TC2>BC2,TC2,BC2)-IF(TC2>BC2,BC2,TC2));
LR1:=FORCAST(C,NOD+1);
NP:=IF(CURRBARSCOUNT<=MAX(BC2,TC2),CONST(IF(MIN(TC2,BC2)=1,LR1,REF(LR1,MIN(TC2,BC2)-1))),DRAWNULL),POINTDOT,COLOR93BDA8;
LR2:=SLOPE(C,NOD+1);
LR3:=CONST(IF(MIN(TC2,BC2)=1,LR2,REF(LR2,MIN(TC2,BC2)-1)));
FP:=NP-LR3*(NOD),POINTDOT,COLOR93BDA8;
AD:=ABS(NP-FP);
DBL:=BARSLAST(BC1!=DRAWNULL)+1;
DBH:=BARSLAST(TC1!=DRAWNULL)+1;
BSP:=IF(BC2>TC2,DBL,DBH)-1;
LRL:=IF(NP>FP,FP+AD/NOD*BSP,FP-AD/NOD*BSP);
AT1:=IF(BETWEEN(CURRBARSCOUNT,BC2,TC2) AND C>LRL,C,LRL);
AT2:=HHV(AT1-LRL,MAX(BC2,TC2));
AT3:=CONST(BARSLAST(AT1-LRL=AT2));
AT5:=CONST(IF(AT3=0,AT1-LRL,REF(AT1-LRL,AT3)));
ATL:=LRL+AT5;
UT1:=IF(BETWEEN(CURRBARSCOUNT,BC2,TC2) AND L<LRL,L,LRL);
UT2:=HHV(LRL-UT1,MAX(BC2,TC2));
UT3:=CONST(BARSLAST(LRL-UT1=UT2));
UT5:=CONST(IF(UT3=0,LRL-UT1,REF(LRL-UT1,UT3)));
UTL:=LRL-UT5;
RH:=IF(CURRBARSCOUNT>=MIN(BC2,TC2)-10,ATL,CONST(REF(ATL,MIN(BC2,TC2)-11)));
RL:=IF(CURRBARSCOUNT>=MIN(BC2,TC2)-10,UTL,CONST(REF(UTL,MIN(BC2,TC2)-11)));
中轨:=IF(NP>FP,IF(LRL<=RH,LRL,DRAWNULL),IF(LRL>=RL,LRL,DRAWNULL)),COLORLICYAN;
上轨12:IF(NP>FP,IF(ATL<=RH,ATL,DRAWNULL),IF(ATL>=RL,ATL,DRAWNULL)),COLORLICYAN;
下轨12:IF(NP>FP,IF(UTL<=RH,UTL,DRAWNULL),IF(UTL>=RL,UTL,DRAWNULL)),COLORLICYAN;
IF(NP>FP,IF(LRL-UTL<ATL-LRL,LRL*2-UTL,IF(ATL-LRL<LRL-UTL,LRL-(ATL-LRL),DRAWNULL)),IF(LRL-UTL<ATL-LRL,LRL*2-UTL,IF(ATL-LRL<LRL-UTL,LRL-(ATL-LRL),DRAWNULL))),DOTLINE,COLORLICYAN;
URA:=5;LRA:=5;{可调}
TC1A:=IF(C=HHV(C,5*URA),C,DRAWNULL);
TC2A:=CONST(BARSLAST(TC1A=C))+1;
BC1A:=IF(L=LLV(L,5*LRA),L,DRAWNULL);
BC2A:=CONST(BARSLAST(BC1A=L))+1;
NODA:=(IF(TC2A>BC2A,TC2A,BC2A)-IF(TC2A>BC2A,BC2A,TC2A));
LR1A:=FORCAST(C,NODA+1);
NPA:=IF(CURRBARSCOUNT<=MAX(BC2A,TC2A),CONST(IF(MIN(TC2A,BC2A)=1,LR1A,REF(LR1A,MIN(TC2A,BC2A)-1))),DRAWNULL),POINTDOT,COLOR93BDA8;
LR2A:=SLOPE(C,NODA+1);
LR3A:=CONST(IF(MIN(TC2A,BC2A)=1,LR2A,REF(LR2A,MIN(TC2A,BC2A)-1)));
FPA:=NPA-LR3A*(NODA),POINTDOT,COLOR93BDA8;
ADA:=ABS(NPA-FPA);
DBLA:=BARSLAST(BC1A!=DRAWNULL)+1;
DBHA:=BARSLAST(TC1A!=DRAWNULL)+1;
BSPA:=IF(BC2A>TC2A,DBLA,DBHA)-1;
LRLA:=IF(NPA>FPA,FPA+ADA/NODA*BSPA,FPA-ADA/NODA*BSPA);
AT1A:=IF(BETWEEN(CURRBARSCOUNT,BC2A,TC2A) AND C>LRLA,C,LRLA);
AT2A:=HHV(AT1A-LRLA,MAX(BC2A,TC2A));
AT3A:=CONST(BARSLAST(AT1A-LRLA=AT2A));
AT5A:=CONST(IF(AT3A=0,AT1A-LRLA,REF(AT1A-LRLA,AT3A)));
ATLA:=LRLA+AT5A;
UT1A:=IF(BETWEEN(CURRBARSCOUNT,BC2A,TC2A) AND L<LRLA,L,LRLA);
UT2A:=HHV(LRLA-UT1A,MAX(BC2A,TC2A));
UT3A:=CONST(BARSLAST(LRLA-UT1A=UT2A));
UT5A:=CONST(IF(UT3A=0,LRLA-UT1A,REF(LRLA-UT1A,UT3A)));
UTLA:=LRLA-UT5A;
RHA:=IF(CURRBARSCOUNT>=MIN(BC2A,TC2A)-10,ATLA,CONST(REF(ATLA,MIN(BC2A,TC2A)-11)));
RLA:=IF(CURRBARSCOUNT>=MIN(BC2A,TC2A)-10,UTLA,CONST(REF(UTLA,MIN(BC2A,TC2)-11)));
中轨A:=IF(NPA>FPA,IF(LRLA<=RHA,LRLA,DRAWNULL),IF(LRLA>=RLA,LRLA,DRAWNULL)),COLOR628962;
上轨12A:IF(NPA>FPA,IF(ATLA<=RHA,ATLA,DRAWNULL),IF(ATLA>=RLA,ATLA,DRAWNULL)),COLORWHITE;
下轨12A:IF(NPA>FPA,IF(UTLA<=RHA,UTLA,DRAWNULL),IF(UTLA>=RLA,UTLA,DRAWNULL)),COLORWHITE;
IF(NPA>FPA,IF(LRLA-UTLA<ATLA-LRLA,LRLA*2-UTLA,IF(ATLA-LRLA<LRLA-UTLA,LRLA-(ATLA-LRLA),DRAWNULL)),IF(LRLA-UTLA<ATLA-LRLA,LRLA*2-UTLA,IF(ATLA-LRLA<LRLA-UTLA,LRLA-(ATLA-LRLA),DRAWNULL))),DOTLINE,COLORWHITE;

通达信线性回归主图指标公式

 

相关文章