以下是通達(dá)信總算完美解決周K線在副圖上顯示(含周均線 源碼貼圖 副圖)(無(wú)源碼的請(qǐng)下載附件導(dǎo)入) 由于原貼周K線顯示在主圖并靠左側(cè),且不易區(qū)分,為方便看盤,故將周K線做成副圖并加上了周均線,實(shí)測(cè)一模一樣。源碼中含有月K線,需要的同學(xué)自行修改。 1、新建引用公式“AA” C1:C; O1:O; H1:H; L1:L; V1:V; ZF:(C-REF(C,1))/REF(C,1); DT1:BARSCOUNT(C); ZH:CURRBARSCOUNT; SJ:IF(ISLASTBAR,DATE,0);{最后一天時(shí)間}; 2、再建公式“三周期K線” {周K線} PPP:=0;{設(shè)定從倒數(shù)第PP根K線結(jié)束顯示周線} Q11:=90;{設(shè)定周K線顯示根數(shù)為Q11} Q12:=00;{設(shè)定月K線顯示根數(shù)為Q12} CCC:=AA.C1#WEEK;HHH:=AA.H1#WEEK;LLL:=AA.L1#WEEK;OO:=AA.O1#WEEK; ZQZ:=TOTALBARSCOUNT; ZQC:=BARSCOUNT(C); KX1:=ZQZ-ZQC;{周K線顯示開(kāi)始位置} K6:=AA.DT1#WEEK;{周K線周期} Q:=IF(CONST(K6)<Q11,CONST(K6)+1,Q11);{如總周K小于Q11,顯示根數(shù)改為總周K線+1根} PP:=IF(ZQZ<PPP,ZQZ-Q,PPP);{如總K線小于開(kāi)始位置,改周K線開(kāi)始位置為總K線周期-Q} K7:=K6>REF(K6,1);{周K線更后} K8:=SUM(K7,0);{當(dāng)前周K線位置} K9:=CONST(K8)-K8; W2:=KX1<PP+Q AND PERIOD=5;{周K線顯示區(qū)域} ZH:=ISLASTBAR; SU:=IF(ZH,0,SUMBARS(K7,KX1-K9)-1); C1:=REF(CCC,SU);O1:=REF(OO,SU);H1:=REF(HHH,SU);L11:=REF(LLL,SU); RC:=REFX(C1,PP);RO:=REFX(O1,PP);RH:=REFX(H1,PP);RL:=REFX(L11,PP); TJ4:=RC>=REF(RC,1); TJ5:=RC<REF(RC,1); STICKLINE(W2 AND TJ4,RH,RL,0,0),COLORRED; STICKLINE(W2 AND TJ5,RH,RL,0,0),COLORLIBLUE; STICKLINE(W2 AND TJ4,RC,RO,2,1),COLORRED; STICKLINE(W2 AND TJ5,RC,RO,2,0),COLORLIBLUE; HH1:=AA.H1#MONTH;LL1:=AA.L1#MONTH; OO1:=AA.O1#MONTH;CCC1:=AA.C1#MONTH; KK6:=AA.DT1#MONTH;{月K線周期} P12:=PP-Q12-3;{設(shè)定從周K線結(jié)束位置隔3天開(kāi)始顯示月K線} Q1:=IF(PP<PPP,CONST(KK6)+1,Q12);{如總月K小于Q12,顯示根數(shù)改為總月K線+1根} P1:=IF(PP<PPP,PP-Q1-2,P12);{如總K線小于開(kāi)始位置,改月K線開(kāi)始位置為總K線周期-Q1} W22:=KX1<P1+Q1 AND PERIOD=5;{月K線顯示區(qū)域} KK7:=KK6>REF(KK6,1);{月K線更后} KK8:=SUM(KK7,0);{當(dāng)前月K線位置} KK9:=CONST(KK8)-KK8; SU1:=IF(ZH,0,SUMBARS(KK7,KX1-KK9)-1); MC1:=REF(CCC1,SU1);MO1:=REF(OO1,SU1);MH1:=REF(HH1,SU1);ML1:=REF(LL1,SU1); MRC:=REFX(MC1,P1);MRO:=REFX(MO1,P1);MRH:=REFX(MH1,P1);MRL:=REFX(ML1,P1); MTJ4:=MRC>=REF(MRC,1); MTJ5:=MRC<REF(MRC,1); STICKLINE(W22 AND MTJ4,MRH,MRL,0,0),COLORFF8080; STICKLINE( W22 AND MTJ5,MRH,MRL,0,0),COLORFF8080; STICKLINE(W22 AND MTJ4,MRC,MRO,3,1),COLORFF8080; STICKLINE( W22 AND MTJ5,MRC,MRO,3,0),COLORFF8080; A:=ALIGNRIGHT(IF(WEEKOFYEAR!=REF(WEEKOFYEAR,1),C#WEEK,DRAWNULL)); MA1:MA(A,5),COLORWHITE; MA2:MA(A,10),COLORRED; MA3:MA(A,20),COLOR6699FF;
|