编写要求:
网上有一个“筹码分布”的帖子,对研究主力成本非常直观。可是,现在的筹码分布是静止的,不能研究历史!也就是,它只能显示N天内的筹码分布情况。如果改变N值,比如改得很大,这样的筹码分布就不适合研究中线、短线。现在,如果能有一种方法,在不改变N值的情况下,当光标向左移动时,筹码分布一直存在并且是变化的(下面的源码,当光标向左移动时,屏幕上只剩下K线,没有筹码分布了)?
TS:=350;N:=95;
DA1:=IF(TS>TOTALBARSCOUNT,TOTALBARSCOUNT,TS);
DA:=IF(CURRBARSCOUNT>DA1,0,DA1);
HI:=REFDATE(HHV(H,DA),DATE);{最高价}
LO:=REFDATE(LLV(L,DA),DATE);
C1:=IF(CURRBARSCOUNT<=DA,C,DRAWNULL);
GZ:=EXP(LN(HI/LO)/15); {对数格值}
LH1:=SUM(IF(C1>=(HI/GZ),V,0),DA);
LH2:=SUM(IF(C1>=(HI/POW(GZ,2)) AND C1<(HI/GZ),V,0),DA);
LH3:=SUM(IF(C1>=(HI/POW(GZ,3)) AND C1<(HI/POW(GZ,2)),V,0),DA);
LH4:=SUM(IF(C1>=(HI/POW(GZ,4)) AND C1<(HI/POW(GZ,3)),V,0),DA);
LH5:=SUM(IF(C1>=(HI/POW(GZ,5)) AND C1<(HI/POW(GZ,4)),V,0),DA);
LH6:=SUM(IF(C1>=(HI/POW(GZ,6)) AND C1<(HI/POW(GZ,5)),V,0),DA);
LH7:=SUM(IF(C1>=(HI/POW(GZ,7)) AND C1<(HI/POW(GZ,6)),V,0),DA);
LH8:=SUM(IF(C1>=(HI/POW(GZ,8)) AND C1<(HI/POW(GZ,7)),V,0),DA);
LH9:=SUM(IF(C1>=(HI/POW(GZ,9)) AND C1=(LO*POW(GZ,5)) AND C1=(LO*POW(GZ,4)) AND C1=(LO*POW(GZ,3)) AND C1=(LO*POW(GZ,2)) AND C1=(LO*GZ) AND C1=LO AND C1=CURRBARSCOUNT ,HI*N/100,HI/GZ,5,0)COLORYELLOW;
STICKLINE(CEILING(DA*L2/SS)*3>=CURRBARSCOUNT ,HI/POW(GZ,1)*N/100,HI/POW(GZ,2),5,0)COLORLIGRAY;
STICKLINE(CEILING(DA*L3/SS)*3>=CURRBARSCOUNT ,HI/POW(GZ,2)*N/100,HI/POW(GZ,3),5,0)COLORGRAY;
STICKLINE(CEILING(DA*L4/SS)*3>=CURRBARSCOUNT,HI/POW(GZ,3)*N/100,HI/POW(GZ,4),5,0)COLORLIGRAY;
STICKLINE(CEILING(DA*L5/SS)*3>=CURRBARSCOUNT ,HI/POW(GZ,4)*N/100,HI/POW(GZ,5),5,0)COLORGRAY;
STICKLINE(CEILING(DA*L6/SS)*3>=CURRBARSCOUNT ,HI/POW(GZ,5)*N/100,HI/POW(GZ,6),5,0)COLORLIGRAY;
STICKLINE(CEILING(DA*L7/SS)*3>=CURRBARSCOUNT,HI/POW(GZ,6)*N/100,HI/POW(GZ,7),5,0)COLORGRAY;
STICKLINE(CEILING(DA*L8/SS)*3>=CURRBARSCOUNT ,LO*POW(GZ,7),LO*POW(GZ,8)*N/100,5,0)COLORLIGRAY;
STICKLINE(CEILING(DA*L9/SS)*3>=CURRBARSCOUNT ,LO*POW(GZ,6),LO*POW(GZ,7)*N/100,5,0)COLORGRAY;
STICKLINE(CEILING(DA*L10/SS)*3>=CURRBARSCOUNT ,LO*POW(GZ,5),LO*POW(GZ,6)*N/100,5,0)COLORLIGRAY;
STICKLINE(CEILING(DA*L11/SS)*3>=CURRBARSCOUNT ,LO*POW(GZ,4),LO*POW(GZ,5)*N/100,5,0)COLORGRAY;
STICKLINE(CEILING(DA*L12/SS)*3>=CURRBARSCOUNT ,LO*POW(GZ,3),LO*POW(GZ,4)*N/100,5,0)COLORLIGRAY;
STICKLINE(CEILING(DA*L13/SS)*3>=CURRBARSCOUNT ,LO*POW(GZ,2),LO*POW(GZ,3)*N/100,5,0)COLORGRAY;
STICKLINE(CEILING(DA*L14/SS)*3>=CURRBARSCOUNT ,LO*POW(GZ,1),LO*POW(GZ,2)*N/100,5,0)COLORLICYAN;
STICKLINE(CEILING(DA*L15/SS)*3>=CURRBARSCOUNT ,LO,LO*POW(GZ,1)*N/100,5,0)COLORGRAY;
DRAWKLINE(HIGH,OPEN,LOW,CLOSE);
均线:MA(C,TS),COLORMAGENTA,LINETHICK2;
解答:
?DA1:=IF(TS>TOTALBARSCOUNT,TOTALBARSCOUNT,TS);
DA:=IF(CURRBARSCOUNT>DA1,0,DA1);