通达信线性回归分析的资料小结主图公式
源码
回归斜率线A:EMA(SLOPE(C,21)*20+C,42);
回归斜率线B:REF(回归斜率线A,2);
回归斜率带:DRAWBAND(回归斜率线A,RGB(218,165,32),REF(回归斜率线A,2),RGB(128,128,0));
DRAWKLINE(H,O,L,C);
DRAWICON(CROSS(EMA(C,3),回归斜率线A),L*0.98,13);
DRAWICON(CROSS(回归斜率线A,EMA(C,2)),H*1.03,14);
HH:=HHV(H,5);
LL:=LLV(L,5);
CH1:=(HH > REF(HH,1)AND C>REF(C,1));
CH2:=(LL < REF(LL,1)AND C<REF(C,1));
K3:=BARSLAST(CH1);
K4:=BARSLAST(CH2);
K5:=(K3<K4 OR CH1) AND NOT(CH2);
K6:=(K3>K4 OR CH2) AND NOT(CH1);
ZC:=IF(HH>REF(HH,1) AND C>REF(C,1),LL,REF(LL,BARSLAST(HH>REF(HH,1)AND C>REF(C,1))));
YL:=IF(LL<REF(LL,1) AND C<REF(C,1),HH,REF(HH,BARSLAST(LL<REF(LL,1) AND C<REF(C,1))));
短期趋势A:IF(K5,ZC,YL),DOTLINE,COLORGREEN;
IF(短期趋势A>=REF(短期趋势A,1),短期趋势A,DRAWNULL),COLOR2222B2;
短期趋势B:IF(K6,ZC,YL),DOTLINE,COLORFFFFFF;
IF(短期趋势B>=REF(短期趋势B,1),短期趋势B,DRAWNULL),COLOR9314FF;
A:=SLOPE(CLOSE,10)/C*100;{表示求10周期线性正回归线的斜率}
B:=FORCAST(CLOSE,10)/C;{表示求10周期线性回归预测本周期正收盘价};
D:=-(SLOPE(CLOSE,10)/C*100);{表示求10周期线性负回归线的斜率}
F:=(A*C+B*C)/C;{表示10周期内价格回归存在斜率预测};
买:=CROSS(A,D) OR CROSS(F,D);
DRAWICON(买,((L+H)/2)*0.98,23);
713444117.jpg
|