咨詢內(nèi)容:
公式函數(shù)問題
老師,這個是線性回歸帶的效果,以下是通達信版本的公式源碼,只有兩個函數(shù)不一樣,老師幫忙改改,萬分感謝
UR:=10;LR:=10;
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),COLORWHITE;
站點:=STICKLINE(IF(BC2>TC2,LP,HP),LL,UP,0,0),COLORWHITE;
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;
ATL1:=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;
UTL1:=LRL+UT5;
RH:=IF(CURRBARSCOUNT>=MIN(BC2,TC2)-15,ATL,CONST(REF(ATL,MIN(BC2,TC2)-15)));{限制高}
RL:=IF(CURRBARSCOUNT>=MIN(BC2,TC2)-15,UTL,CONST(REF(UTL,MIN(BC2,TC2)-15)));{限制低}
上軌:IF(NP>FP,IF(ATL1<=RH,UTL1,DRAWNULL),IF(ATL>=RL,ATL,DRAWNULL)),COLORGREEN,DOTLINE;
中軌:IF(NP>FP,IF(LRL<=RH,LRL,DRAWNULL),IF(LRL>=RL,LRL,DRAWNULL)),COLORWHITE,DOTLINE;
下軌:IF(NP>FP,IF(UTL<=RH,UTL,DRAWNULL),IF(UTL1>=RL,ATL1,DRAWNULL)),COLORRED,DOTLINE;
NOTEXT中軌:=IF(NP>FP,IF(LRL<=CONST(REF(LRL,BARSLASTCOUNT(H<LRL))),LRL,DRAWNULL),IF(LRL>=CONST(REF(LRL,BARSLASTCOUNT(L>LRL))),LRL,DRAWNULL)),COLORWHITE;
NOTEXT上軌:IF(NP>FP,IF(UTL1<=CONST(REF(UTL1,BARSLASTCOUNT(H<LRL))),UTL1,DRAWNULL),IF(ATL>=CONST(REF(ATL,BARSLASTCOUNT(L>LRL))),ATL,DRAWNULL)),COLORGREEN,LINETHICK2;
NOTEXT下軌:IF(NP>FP,IF(UTL<=CONST(REF(UTL,BARSLASTCOUNT(H<LRL))),UTL,DRAWNULL),IF(ATL1>=CONST(REF(ATL1,BARSLASTCOUNT(L>LRL))),ATL1,DRAWNULL)),COLORRED,LINETHICK2;
?
<!--
咨詢內(nèi)容: 附件 :
-->
?
?來源:程序化99網(wǎng)( www.kzuj.com.cn )
博易技術(shù)人員:
您好,他們的函數(shù)系統(tǒng)和我們的函數(shù)系統(tǒng)的畫線規(guī)則是完全不一樣的,這個指標不是簡單的函數(shù)問題,這個運算方式就不一樣,包括取值的起點,所以說不好修改。如果,因為運算方式不一樣,中間出現(xiàn)斷層。這個公式我會記錄下來,看看具體的運算規(guī)則。
CURRBARSCOUNT:=DATACOUNT-BARPOS;
UR:=10;LR:=10;
TC1:=IF(H=HHV(H,8*UR),H,DRAWNULL);
TC2:=BARSLAST(TC1=H)+1;
UP:=IF(TC2=1,H,REF(H,TC2-1));
BC1:=IF(L=LLV(L,8*LR),L,DRAWNULL);
BC2:=BARSLAST(BC1=L)+1;
LL:=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),COLORWHITE;
STICKLINE(IF(BC2>TC2,LP,HP),LL,UP,0,0),COLORWHITE;
NOD:=(IF(TC2>BC2,TC2,BC2)-IF(TC2>BC2,BC2,TC2));{用時}
LR1:=FORCAST(C,NOD+1);{線性回歸預測值}
NP:=IF(CURRBARSCOUNT<=MAX(BC2,TC2),IF(MIN(TC2,BC2)=1,LR1,REF(LR1,MIN(TC2,BC2)-1)),DRAWNULL),POINTDOT,COLOR93BDA8;{近點}
LR2:=SLOPE(C,NOD+1);{線性回歸的斜率}
LR3:=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:=BARSLAST(AT1-LRL=AT2);
AT4:=IF(AT3=0,H,REF(H,AT3));
AT5:=IF(AT3=0,AT1-LRL,REF(AT1-LRL,AT3));
ATL:=LRL+AT5;
ATL1:=LRL-AT5;
UT1:=IF(BETWEEN(CURRBARSCOUNT,BC2,TC2) AND L<LRL,L,LRL);
UT2:=HHV(LRL-UT1,MAX(BC2,TC2));
UT3:=BARSLAST(LRL-UT1=UT2);
UT4:=IF(UT3=0,H,REF(H,UT3));
UT5:=IF(UT3=0,LRL-UT1,REF(LRL-UT1,UT3));
UTL:=LRL-UT5;
UTL1:=LRL+UT5;
RH:=IF(CURRBARSCOUNT>=MIN(BC2,TC2)-15,ATL,REF(ATL,MIN(BC2,TC2)-15));{限制高}
RL:=IF(CURRBARSCOUNT>=MIN(BC2,TC2)-15,UTL,REF(UTL,MIN(BC2,TC2)-15));{限制低}
上軌:IF(NP>FP,IF(ATL1<=RH,UTL1,DRAWNULL),IF(ATL>=RL,ATL,DRAWNULL)),COLORGREEN;
中軌:IF(NP>FP,IF(LRL<=RH,LRL,DRAWNULL),IF(LRL>=RL,LRL,DRAWNULL)),COLORWHITE;
下軌:IF(NP>FP,IF(UTL<=RH,UTL,DRAWNULL),IF(UTL1>=RL,ATL1,DRAWNULL)),COLORRED;

來源 程序化久久網(wǎng)