股歌看盘2011通达信版
源码:
N:=IF(BARSCOUNT(C)<270,IF(BARSCOUNT(C)<180,30,60),90);
D1:=MA((C-LLV(C,N))/(HHV(C,N)-LLV(C,N))*100,2);
Q:=IF(C>O,V*(100-D1),V*D1);
ZF:=(C-O);
ZB:=ABS((C-REF(C,1)))/REF(C,1);
D2:=ZF*Q*ZB/(HHV(ZF*Q*ZB,N)-LLV(ZF*Q*ZB,N))*100;
D3:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
KK:=(2*D1+2*D2+D3)/5;
DT:=IF(DATE<1101121,1,0);
YYY:=DT*SMA(KK/(HHV(KK,N)-LLV(KK,N))*100,2,1);
LLL:=DT*SMA(YYY,3,1);
DDD:=DT*MEMA(LLL,2);
个股短趋:=DT*(MA(YYY,5)*1+MA(YYY,10)*2+MA(YYY,20)*3+MA(YYY,30)*4+MA(YYY,60)*5)/15,NODRAW;
{DRAWBAND(个股短趋,RGB(255,0,0),REF(个股短趋,1),RGB(0,255,0))};
个股中趋:=DT*(MA(C,5)*1+MA(C,10)*2+MA(C,20)*3+MA(C,30)*4+MA(C,60)*5+MA(C,120)*6)/21;
上轨:=DT*个股中趋*1.08,COLORLIGRAY,LINETHICK3;
下轨:=DT*个股中趋*0.92,COLORLIGRAY,LINETHICK3;
获利盘%:=DT*WINNER(C)*100,NODRAW;
全换日数:=DT*SUMBARS(V,CAPITAL);
近期获利%:=DT*LWINNER(全换日数,C)*100;
远期获利%:=DT*PWINNER(全换日数,C)*100;
获利快线:=DT*MEMA(MEMA(MEMA(近期获利%,2),2),2),COLORWHITE,LINETHICK3;
获利慢线:=DT*EXPMEMA(EXPMEMA(MEMA(近期获利%,3),3),3),COLORRED,LINETHICK3;
获利中趋:=DT*(MA(近期获利%,5)+MA(近期获利%,10)*2+MA(近期获利%,20)*3+MA(近期获利%,30)*4+MA(近期获利%,60)*5)/15,COLORYELLOW,LINETHICK3;
PD1:=MA((INDEXC-LLV(INDEXC,N))/(HHV(INDEXC,N)-LLV(INDEXC,N))*100,2);
PQ:=IF(INDEXC>INDEXO,INDEXV*(100-PD1),INDEXV*PD1);
PZF:=(INDEXC-INDEXO);
PZB:=ABS((INDEXC-REF(INDEXC,1)))/REF(INDEXC,1);
PD2:=PZF*PQ*PZB/(HHV(PZF*PQ*PZB,N)-LLV(PZF*PQ*PZB,N))*100;
PD3:=(INDEXC-LLV(INDEXL,9))/(HHV(INDEXH,9)-LLV(INDEXL,9))*100;
PKK:=(2*PD1+2*PD2+PD3)/5;
PYYY:=SMA(PKK/(HHV(PKK,N)-LLV(PKK,N))*100,2,1);
大盘短趋:=DT*(MA(PYYY,5)*1+MA(PYYY,10)*2+MA(PYYY,20)*3+MA(PYYY,30)*4+MA(PYYY,60)*5)/15,NODRAW;
{DRAWBAND(大盘短趋,RGB(255,0,0),REF(大盘短趋,1),RGB(0,0,255))};
大盘中趋:=DT*(MA(INDEXC,5)*1+MA(INDEXC,10)*2+MA(INDEXC,20)*3+MA(INDEXC,30)*4+MA(INDEXC,60)*5+MA(INDEXC,120)*6)/21;
{仓位变量}
VAR1:=IF(个股短趋>=REF(个股短趋,1),1,-1);
VAR2:=IF(个股中趋>=REF(个股中趋,1),1,-1);
VAR3:=IF(获利快线>=REF(获利快线,1),1,-1);
VAR4:=IF(获利慢线>=REF(获利慢线,1),1,-1);
VAR5:=IF(获利快线>=REF(获利快线,1) AND 获利快线>获利慢线,1,-1);
VAR6:=IF(获利快线>=REF(获利快线,1) AND 获利快线>20,1,-1);
VAR7:=IF(获利慢线>=REF(获利慢线,1) AND 获利慢线>20,1,-1);
VAR8:=IF(获利中趋>=REF(获利中趋,1),1,-1);
VAR9:=IF(获利中趋>=REF(获利中趋,1) AND 获利中趋>20,1,-1);
VAR10:=IF(C>MA(C,5),1,-1);
VAR11:=IF(C>MA(C,10),1,-1);
VAR12:=IF(MA(C,5)>REF(MA(C,5),1),1,-1);
VAR13:=IF(MA(C,5)>MA(C,10),1,-1);
VAR14:=IF(MA(C,10)>REF(MA(C,10),1),1,-1);
VAR15:=IF(DDD>=REF(DDD,1),1,-1);
VAR16:=IF(DDD>=REF(DDD,1) AND DDD>25,1,-1);
VA:=IF(C>O,VOL,-VOL);
股歌OBV:=SUM(IF(C=O,0,VA),0);
VAR17:=IF(MA(股歌OBV,5)>REF(MA(股歌OBV,5),1),1,-1);
VAR18:=IF("MACD.DIF">=REF("MACD.DIF",1),1,-1);
VAR19:=IF("MACD.DEA">=REF("MACD.DEA",1),1,-1);
VAR20:=IF("MACD.DIF">"MACD.DEA",1,-1);
股歌AMOV:=VOL*(OPEN+CLOSE)/2;
股歌AMV5:=SUM(股歌AMOV,5)/SUM(VOL,5);
股歌AMV15:=SUM(股歌AMOV,15)/SUM(VOL,15);
VAR21:=IF(股歌AMV5>REF(股歌AMV5,1),1,-1);
VAR22:=IF(股歌AMV5>股歌AMV15,1,-1);
AA:=ABS((2*CLOSE+HIGH+LOW)/4-MA(CLOSE,30))/MA(CLOSE,30);
济安线:=DMA((2*CLOSE+LOW+HIGH)/4,AA);
CC:=(CLOSE/济安线);
MA1:=MA(CC*(2*CLOSE+HIGH+LOW)/4,3);
MAAA:=((MA1-济安线)/济安线)/3;
TMP:=MA1-MAAA*MA1;
VAR23:=IF(TMP>=济安线,1,-1);
变量和:=DT*(VAR1+VAR2+VAR3+VAR4+VAR5+VAR6+VAR7+VAR8+VAR9+VAR10+VAR11+VAR12+VAR13
+VAR14+VAR15+VAR16+VAR17+VAR18+VAR19+VAR20+VAR21+VAR22+VAR23);
原始仓位%:=DT*IF(变量和<0,0,变量和/23*100);
{仓位限制系数}
CWK1:=IF(大盘中趋>=REF(大盘中趋,1),1,0.5);
CWK2:=IF(大盘短趋>=REF(大盘短趋,1),1,0.5);
CWK3:=IF(个股中趋>=REF(个股中趋,1),1,0.5);
CWK4:=IF(个股短趋>=REF(个股短趋,1),1,0);
CWK5:=IF(获利中趋>=REF(获利中趋,1),1,0.5);
CWK6:=IF(MA(C,3)>下轨,1,0.5);
CWK7:=IF("MACD.DIF"<"MACD.DEA" AND "MACD.DIF"<REF("MACD.DIF",1),0,1);
CWK8:=IF("MACD.DIF"<"MACD.DEA",0.5,1);
CWK9:=IF("MACD.DEA"<REF("MACD.DEA",1),0.5,1);
CWK10:=IF(股歌AMV5<股歌AMV15 AND 股歌AMV5<REF(股歌AMV5,1),0,1);
CWK11:=IF(股歌AMV5<股歌AMV15,0.5,1);
CWK12:=IF(TMP<济安线 AND TMP<REF(TMP,1),0,1);
CWK13:=IF(TMP<济安线,0.5,1);
CWK14:=IF(C<REF(C,1)*1.005*(1-HHV((ABS(C/REF(C,1)-1)),
IF(BARSCOUNT(C)>100,100,BARSCOUNT(C)))),0,1);{跌停清0}
CWK15:=IF(C<=0.95*HHV(C,4),0,1);{顶部下跌超5%清0}
CWK16:=IF(C<=O AND V=HHV(V,60) AND H=HHV(H,60) AND C<MA(C,5),0.5,1);{收阴 量价60日新高}
调整仓位%:=DT*原始仓位%*CWK1*CWK2*CWK3*CWK4*CWK5*CWK6*CWK7*CWK8*CWK9*CWK10
*CWK11*CWK12*CWK13*CWK14;
初始仓位%:=DT*IF(C>=MA(C,10) AND MA(C,5)>=REF(MA(C,5),1)
AND MA(C,20)>=REF(MA(C,20),1)
AND MA(C,30)>=REF(MA(C,30),1) AND MA(C,10)>=MA(C,20)
AND MA(C,20)>=MA(C,30)
AND (REF(MA(C,10),1)>=REF(MA(C,10),2)
AND MA(C,10)<REF(MA(C,10),1)
OR MA(C,10)>REF(MA(C,10),1)),100,调整仓位%)*CWK15*CWK16;
CS:=初始仓位%;
{仓位取整}
R001A:=IF(CS<10,0,初始仓位%);
R001B:=IF(CS>=10 AND CS<15,10,R001A);
R001C:=IF(CS>=15 AND CS<25,20,R001B);
R001D:=IF(CS>=25 AND CS<35,30,R001C);
R001E:=IF(CS>=35 AND CS<45,40,R001D);
R001F:=IF(CS>=45 AND CS<55,50,R001E);
R001G:=IF(CS>=55 AND CS<65,60,R001F);
R001H:=IF(CS>=65 AND CS<75,70,R001G);
R001I:=IF(CS>=75 AND CS<85,80,R001H);
R001J:=IF(CS>=85 AND CS<95,90,R001I);
R001K:=IF(CS>=95,100,R001J);
{调整因子}
T1:=C<O OR C<=REF(C,1);{阴、跌不加仓}
T2:=(H-C)/(O-L)>2 AND (H-C)>(C-O) OR (H-C)/(C-O)>2
AND (H-C)>(O-L);{上影过长不加仓}
T3:=V<0.5*REF(V,1);{缩量过半不加仓}
T4:=REF(C,1)<=REF(O,1) AND (V<REF(V,1) OR C<REF(O,1));
{昨日收阴或平盘:缩量或未突破昨日阴线不加仓}
T5:=C>=O;{收阳不减仓}
T6:=R001K>REF(R001K,1);{取整后原本增仓不减仓}
{调整1组}
R100:=IF(T1 AND R001K>REF(R001K,1),REF(R001K,1),R001K);
R101:=IF(T1 AND R100>REF(R100,1),REF(R100,1),R100);
R102:=IF(T2 AND R101>REF(R101,1),REF(R101,1),R101);
R103:=IF(T3 AND R102>REF(R102,1),REF(R102,1),R102);
R104:=IF(T4 AND R103>REF(R103,1),REF(R103,1),R103);
R105:=IF(T5 AND REF(R104,1)>R104,REF(R104,1 |