NXTS牛熊天数指标源码如下:
Z:=ZIG(C,N);
高点:=Z>REF(Z,1) AND Z>REFX(Z,1);
低点:=Z<REF(Z,1) AND Z<REFX(Z,1);
NG:=BARSLAST(高点);
ND:=BARSLAST(低点);
D0:=DATETODAY(DATE)-DATETODAY(REF(DATE,BARSSINCE(C)));
DG:=DATETODAY(DATE)-DATETODAY(REF(DATE,NG));
DD:=DATETODAY(DATE)-DATETODAY(REF(DATE,ND));
N1:=(NG>ND OR COUNT(高点,0)=0) AND ND>0 AND (HHV(C,ND)-REF(C,ND))/REF(C,ND)>(N/100);
N2:=NG<ND AND NG>0 AND (LLV(C,NG)-REF(C,NG))/REF(C,NG)>=-(N/100);
N3:=NG<ND AND NG=0;
N4:=COUNT(低点 OR 高点,0)=0 AND (HHV(C,0)-REF(C,BARSSINCE(C)))/REF(C,BARSSINCE(C))>(N/100);
N5:=COUNT(低点,0)=0 AND NG>0 AND (LLV(C,NG)-REF(C,NG))/REF(C,NG)>=-(N/100);
N6:=COUNT(低点,0)=0 AND NG=0;
X1:=(NG<ND OR COUNT(低点,0)=0) AND NG>0 AND (LLV(C,NG)-REF(C,NG))/REF(C,NG)<-(N/100);
X2:=NG>ND AND ND>0 AND (HHV(C,ND)-REF(C,ND))/REF(C,ND)<=(N/100);
X3:=NG>ND AND ND=0;
X4:=COUNT(高点 OR 低点,0)=0 AND (LLV(C,0)-REF(C,BARSSINCE(C)))/REF(C,BARSSINCE(C))<-(N/100);
X5:=COUNT(高点,0)=0 AND ND>0 AND (HHV(C,ND)-REF(C,ND))/REF(C,ND)<=(N/100);
X6:=COUNT(高点,0)=0 AND ND=0;
牛市天数:IF(N4 OR N5 OR N6,D0,IF(N1 OR N2 OR N3,DD,0)),COLORRED;
熊市天数:IF(X4 OR X5 OR X6,D0,IF(X1 OR X2 OR X3,DG,0)),COLORGREEN;