{周K线}
PPP:=0;{设定从倒数第PP根K线结束显示周线}
Q11:=90;{设定周K线显示根数为Q11}
Q12:=00;{设定月K线显示根数为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线显示开始位置}
K6:=AA.DT1#WEEK;{周K线周期}
Q:=IF(CONST(K6)<Q11,CONST(K6)+1,Q11);{如总周K小于Q11,显示根数改为总周K线+1根}
PP:=IF(ZQZ<PPP,ZQZ-Q,PPP);{如总K线小于开始位置,改周K线开始位置为总K线周期-Q}
K7:=K6>REF(K6,1);{周K线更后}
K8:=SUM(K7,0);{当前周K线位置}
K9:=CONST(K8)-K8;
W2:=KX1<PP+Q AND PERIOD=5;{周K线显示区域}
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;{设定从周K线结束位置隔3天开始显示月K线}
Q1:=IF(PP<PPP,CONST(KK6)+1,Q12);{如总月K小于Q12,显示根数改为总月K线+1根}
P1:=IF(PP<PPP,PP-Q1-2,P12);{如总K线小于开始位置,改月K线开始位置为总K线周期-Q1}
W22:=KX1<P1+Q1 AND PERIOD=5;{月K线显示区域}
KK7:=KK6>REF(KK6,1);{月K线更后}
KK8:=SUM(KK7,0);{当前月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;