当前位置: 网站首页 > 股票软件公式 > 通达信公式 > 文章 当前位置: 通达信公式 > 文章

通达信源码精选:线性回归通道,变色K趋势王,最佳买入

点击: 次    来源:顶尖财经    作者:股市狙击 - 小 + 大

1、线性回归通道

线性回归通道,以前发过的是飞狐的版本,这次发通达信的版本。
线性回归通道指标,任何周期适用,具体看图
 

{线性回归通道}
UR:=6;LR:=6;
TC1:=IF(H=HHV(H,8*UR),H,DRAWNULL);
TC2:=CONST(BARSLAST(TC1=H))+1;
UP:CONST(IF(TC2=1,H,REF(H,TC2-1)));
BC1:=IF(L=LLV(L,8*LR),L,DRAWNULL);
BC2:=CONST(BARSLAST(BC1=L))+1;
LL:CONST(IF(BC2=1,L,REF(L,BC2-1)));
LP:=CURRBARSCOUNT<=BC2 AND L=LL;{低点定位}
HP:=CURRBARSCOUNT<=TC2 AND H=UP;{高点定位}
STICKLINE(IF(BC2>TC2,HP,LP),LL,UP,0,0),COLOR628962;
STICKLINE(IF(BC2>TC2,LP,HP),LL,UP,0,0),COLOR628962;
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;{远点}
EQU:(NP+FP)/2,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 H>LRL,H,LRL);
AT2:=HHV(AT1-LRL,MAX(BC2,TC2));
AT3:=CONST(BARSLAST(AT1-LRL=AT2));
AT4:=CONST(IF(AT3=0,H,REF(H,AT3)));
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));
UT4:=CONST(IF(UT3=0,H,REF(H,UT3)));
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)),COLOR628962;
上轨:IF(NP>FP,IF(ATL<=RH,ATL,DRAWNULL),IF(ATL>=RL,ATL,DRAWNULL)),COLOR628962;
下轨:IF(NP>FP,IF(UTL<=RH,UTL,DRAWNULL),IF(UTL>=RL,UTL,DRAWNULL)),COLOR628962;




2、变色K趋势王,红蓝K线 多空提示

{变色K趋势王}
SJ:=1;
VAR2:=EMA(CLOSE,60)*SJ;
VAR3:=(CLOSE*SJ-VAR2*SJ)*2/(60+1)+VAR2;
生命线:VAR3*SJ,LINETHICK2, COLORYELLOW;
MA3:=MA(C,170);
HH1:=IF(H<REF(H,1)&&REF(H,1)<REF(H,2),REF(H,2),0);
LL1:=IF(L>REF(L,1)&&REF(L,1)>REF(L,2),REF(L,2),0);
HH2:=VALUEWHEN(HH1>0,HH1);
LL2:=VALUEWHEN(LL1>0,LL1);
HH:=HHV(HIGH,1)/10*SJ+HHV(HIGH,2)/10+HHV(HIGH,2)/10+HHV(HIGH,4)/10+HHV(HIGH,4)/10+HHV(HIGH,8)/10+HHV(HIGH,8)/10+HHV(HIGH,13)/10+HHV(HIGH,40)/10+HHV(HIGH,20)/10;
LL:=LLV(LOW,1)/10*SJ+LLV(LOW,2)/10+LLV(LOW,2)/10+LLV(LOW,4)/10+LLV(LOW,4)/10+LLV(LOW,8)/10+LLV(LOW,8)/10+LLV(LOW,13)/10+LLV(LOW,40)/10+LLV(LOW,20)/10;
H1:=IF(HH<REF(HH,1)&&LL<REF(LL,1)&&REF(OPEN,1)>CLOSE&&OPEN>CLOSE&&(HHV(OPEN,0)-CLOSE)>0,REF(HH,2),0);
L1:=IF(LL>REF(LL,1)&&HH>REF(HH,1)&&REF(OPEN,1)<CLOSE&&OPEN<CLOSE&&(CLOSE-LLV(OPEN,0))>0,REF(LL,2),0);
X:=DATE;
X0:=H1,LINETHICK2;
X00:=L1;
XXX0:=O,LINETHICK2;
XXX00:=C;
XXX000:=H;
XXX0000:=L;
H2:=VALUEWHEN(X0>0,X0),LINETHICK2;
L2:=VALUEWHEN(X00>0,X00),LINETHICK2;
K1:=IF(CLOSE>H2,-3,IF(CLOSE<L2,1,0));
K2:=VALUEWHEN(K1<>0,K1);
G:=IF(K2=1,H2,L2);
G1:=VALUEWHEN(ISLASTBAR,G);
DRAWNUMBER(L>0,G1,G1),COLORCYAN;
DRAWNUMBER(LL>0,G1,G1),COLORWHITE;
X000:=K2,LINETHICK2;
TMP:=K2,LINETHICK2;
W1:=X000,LINETHICK2;
X0000:=OPEN-CLOSE,LINETHICK2;
W2:=X0000,LINETHICK2;
HT:=IF(OPEN>CLOSE,OPEN,CLOSE),LINETHICK2;
LT:=IF(OPEN<CLOSE,OPEN,CLOSE),LINETHICK2;
STICKLINE(W1=1,XXX000,HT,0,0),COLORCYAN;
STICKLINE(W1=1,XXX0000,LT,0,0),COLORCYAN;
STICKLINE(W1=-3,XXX000,HT,0,0),COLORRED;
STICKLINE(W1=-3,XXX0000,LT,0,0),COLORRED;
STICKLINE(W1>0,XXX0,XXX00,3,1),COLORCYAN;
STICKLINE(W1<=0,XXX0,XXX00,3,1),COLORRED;
STICKLINE(W2>0&&W1<=0,XXX0,XXX00,3,0),COLORRED;
STICKLINE(W2>0&&W1>0,XXX0,XXX00,3,0),COLORCYAN;
IF(K2=1,G,DRAWNULL),COLORCYAN;
IF(K2=-3,G,DRAWNULL),COLORRED;
DRAWTEXT(CROSS(TMP,0),HH,'空'),COLORGREEN;
DRAWTEXT(CROSS(0,TMP),LL,'多');
N3:=BARSLAST(CROSS(W1>0,0.5)),LINETHICK2;
N4:=BARSLAST(CROSS(W1<=0,0.5)),LINETHICK2;
HH3:=IF(W1<=0,REF(HHV(H,N4),N3),DRAWNULL),COLORYELLOW;
LL3:=IF(W1>0,REF(LLV(L,N3),N4),DRAWNULL),COLORGREEN;
B:=CROSS(C,HH3)  OR REF(IF(HH3=DRAWNULL,1,DRAWNULL),1)&&C>HH3;
S:=CROSS(LL3,C) OR REF(IF(LL3=DRAWNULL,1,DRAWNULL),1)&&C<LL3;
{DRAWICON(B=1,L, 25);
DRAWICON(S=1,H, 27);}
LC:= REF(CLOSE,1),LINETHICK2;
RSI:=SMA(MAX(CLOSE-LC, 0), 6, 1)/SMA(ABS(CLOSE-LC), 6, 1)*100,LINETHICK2;
 
变色K趋势王公式解释和用法:
变色K结合生命线交易效果更高。
公式用法:
生命线上只做多不做空,
生命线下只做空不做多。
 
用这种公式做交易主要是会选择品种和周期,选择那些经常宽幅震荡和经常出现单边走势的品种和周期效果好,这种公式都怕横盘震荡。
公式的买卖点提示是在红绿变色时提示,方便查看。( 股 民 学 院 : http://www.58188.net )
公式没有未来函数信号不漂移。




3、最佳买入

本公式,多个买点同时发出信号,共振更佳。

{最佳买入}
M:=7;
M1:=3;
DIFF:= EMA(CLOSE,12)-EMA(CLOSE,26);
DIF:EMA(CLOSE,12)-EMA(CLOSE,26),COLORRED;
LC:=REF(CLOSE,1);
RSI5:=((SMA(MAX((CLOSE-LC),0),5,1)/SMA(ABS((CLOSE-LC)),5,1))*100);
DEA:EMA(DIF,9),COLORBLUE;
MACD:2*(DIF-DEA),COLORSTICK;
TR1:=SUM(MAX(MAX((HIGH-LOW),ABS((HIGH-REF(CLOSE,1)))),ABS((LOW-REF(CLOSE,1)))),10);
HD:=(HIGH-REF(HIGH,1));
FH1:=REF(MACD,1)<REF(MACD,2) AND REF(MACD,2)<REF(MACD,3) AND REF(MACD,3)<REF(MACD,4);
FH2:=MACD>=0 AND COUNT(MACD>REF(MACD,1),1)=1;
LD:=(REF(LOW,1)-LOW);
DMP:=SUM(IF(((HD>0) AND (HD>LD)),HD,0),10);
DMM:=SUM(IF(((LD>0) AND (LD>HD)),LD,0),10);
FH3:=FH1 AND FH2 AND EMA(C,13)>REF(EMA(C,13),1);
FH4:=FH1 AND FH2 AND ABS((DIF-DEA)/C)<0.018;
FH5:=FH1 AND FH2 AND MACD<0.10;
PDI:=((DMP*100)/TR1);
MDI:=((DMM*100)/TR1);
VV:=CLOSE>OPEN AND MA(CLOSE,5)>MA(CLOSE,10) AND MA(CLOSE,10)>MA(CLOSE,30) AND DIFF>DEA AND MACD>REF(MACD,1) AND DIFF>0 AND DEA>0 AND MA(VOL,5)>MA(VOL,34) AND MA(CLOSE,30)>=REF(MA(CLOSE,30),1);
ADX:=MA(((ABS((MDI-PDI))/(MDI+PDI))*100),5);
AV:=(RSI5+ADX);
佛手:IF(VV,1,0),NODRAW;
DRAWICON(佛手,0.06,11);
二次翻红:(FH3 OR FH4 OR FH5),COLORRED,NODRAW;
DXR:=(((ADX+REF(ADX,5))/2)+RSI5);
WR10:=((100*(HHV(HIGH,10)-CLOSE))/(HHV(HIGH,10)-LLV(LOW,10)));
低买:CROSS(DIF,DEA) AND DIF<0,COLORFF00FF,NODRAW;
加油:CROSS(DIF,DEA) AND DIF>0,COLORYELLOW,NODRAW;
NEWVOL:=(RSI5-WR10);
最佳买入:=(AV+NEWVOL);
DRAWICON(二次翻红,-0.05,1);
DRAWTEXT(二次翻红,-0.15,'翻红'),COLORRED;
买入选股:IF(CROSS(最佳买入,0),3,0),STICK,COLOR00FFFF,LINETHICK2;
VARA1:=SMA(买入选股,3,1);
DRAWTEXT(CROSS(DIF,DEA) AND DIF<0,DEA-0.02,'低买'),COLORFF00FF;
DRAWTEXT(CROSS(DIF,DEA) AND DIF>0,DEA-0.05,'加油'),COLORYELLOW;
XG:二次翻红 OR 低买 OR 加油,NODRAW;
VARA2:=SMA(VARA1,3,1),COLOR0000FF;
VARA3:=SMA(VARA2,3,1),COLOR00FFFF;
YLZC:=IF(CLOSE=INDEXC,(INDEXC+INDEXH+INDEXL+INDEXO)/4,AMOUNT/(VOL+0.01)/100);
阻价:=IF(CLOSE=INDEXC,YLZC+INDEXC-INDEXL,YLZC+(CLOSE-LOW));
支价:=IF(CLOSE=INDEXC,INDEXL+INDEXC-YLZC,LOW+(CLOSE-YLZC));
建仓买点:IF(CROSS(VARA2,VARA3) AND (VARA2<40),3,0* 10000),COLOR0000FF,LINETHICK1;
今压:REF(阻价,1),LINETHICK0,COLORAA11BB,NODRAW;
今撑:REF(支价,1),LINETHICK0,COLOR009900,NODRAW;
STICKLINE(建仓买点,0,1.0,6,0),COLORFF80FF;
STICKLINE(建仓买点,0.5,2.0,2,0),COLOR3000FF;
明压:阻价,LINETHICK0,NODRAW;
明撑:支价,LINETHICK0,NODRAW;
{股 民 学 院 : http://www.58188.net 整理}

上一篇:通达信源码精选:散户操盘线主图,主力资金,多空线

下一篇:通达信源码精选:鳄鱼分形主图、动量震荡副图和动量加速副图,组合使用更好