c1:=c/ref(ema(c,30),30);
c2:=indexc/ref(ema(indexc,30),30);
l1:=c1/c2*10-10;
c3:=c/ma(c,60);
c4:=indexc/ma(indexc,60);
L2:=c3/c4*10-10;
c5:=c/ma(c,120);
c6:=indexc/ma(indexc,120);
l3:=c5/c6*10-10;
L4:=MA(L1+L2+L3,5);
诊断3:='【走势强弱诊断】 '+IFS(REF(L4,1)>0 AND REF(L4,1)>REF(L4,2),'该股中长期走势强于大盘,且近期继续走强。','')+
IFS(REF(L4,1)>0 AND REF(L4,1)<=REF(L4,2),'该股中长期走势强于大盘,但近期有所走弱。','')+
IFS(REF(L4,1)<=0 AND REF(L4,1)>REF(L4,2),'该股中长期走势弱于大盘,但近期有所转强。','')+
IFS(REF(L4,1)<=0 AND REF(L4,1)<=REF(L4,2),'该股中长期走势弱于大盘,且近期继续走弱。','');
诊断4:='【基本面诊断】 '+'该股为'+IFS( FINANCE2(33)>=50/100,'绩优、','')+IFS(FINANCE2(33)<50/100 AND FINANCE2(33)>=10/100,'中等业绩、','')+IFS(FINANCE2(33)<10/100 AND FINANCE2(33)>=0,'绩差、','')+
IFS(FINANCE2(33)<0,'亏损、','')+IFS(DYNAINFO(39)<=20 AND DYNAINFO(39)>0,'低市盈率、','')+IFS(DYNAINFO(39)>20 AND DYNAINFO(39)<=50,'中等市盈率、','')+IFS(DYNAINFO(39)>50,'高市盈率、','')+
IFS(FINANCE2(37)>=30000,'大盘股。','')+IFS(FINANCE2(37)<30000 AND FINANCE2(37)>=10000,'中盘股。','')+IFS(FINANCE2(37)<10000,'小盘股。','');
MA5:=MA(C,5);
MA10:=MA(C,10);
MA30:=MA(C,30);
MA60:=MA(C,60);
MA120:=MA(C,120);
MA250:=MA(C,250);
诊断5:='【均线诊断】 '+IFS((MA5>MA10 and MA10>MA30 and MA5>MA30),'短期均线多头排列;','')+
IFS((MA5<MA10 and MA10<MA30 and MA5<MA30),'短期均线空头排列;','')+
IFS((MA30>MA60 and MA30>MA120 and MA60>MA120),'中期均线多头排列;','')+
IFS((MA30<MA60 and MA30<MA120 and MA60<MA120),'中期均线空头排列;','')+
IFS((MA60>MA120 and MA120>MA250 and MA60>MA250),'长期均线多头排列;','')+
IFS((MA60<MA120 and MA120<MA250 and MA60<MA250),'长期均线空头排列;','')+
IFS((crOSS(MA5,MA10)),'短期均线5日10日金叉;','')+
IFS((CROSS(MA10,MA5)),'短期均线5日10日死叉;','')+
IFS((CROSS(C,MA120)),'今日股价上穿半年线;','')+
IFS((CROSS(MA120,C)),'今日股价跌破半年线;','')+
IFS((CROSS(C,MA250)),'今日股价上穿一年线;','')+
IFS((CROSS(MA250,C)),'今日股价跌破一年线;','')+
IFS((CROSS(C,MA60) and CROSS(C,MA120) and CROSS(C,MA250)),'股价一阳上穿三线;','')+
IFS((MA30>REF(MA30,1)),'30日均线趋势向上;','')+
IFS((MA30>REF(MA30,1) AND MA30<REF(MA30,1)*1.001),'30日均线趋势走平;','')+
IFS((MA30<REF(MA30,1)),'30日均线趋势向下;','')+
IFS((MA5>REF(MA5,1)*1.015),'5日均线强劲向上;','')+
IFS((MA5>REF(MA5,1) AND MA5<REF(MA5,1)*1.005),'5日均线方向不明;','')+
IFS((MA5<REF(MA5,1)*0.985),'5日均线快速向下;','');
PT := REF(HIGH,1)-REF(LOW,1);
重心:=(HIGH + LOW + CLOSE)/3;
压力Ⅰ:= 2*重心-LOW;
压力Ⅱ:= 重心 + PT;
支撑Ⅰ:= 2.002*重心-HIGH;
支撑Ⅱ:= 重心 - PT;
诊断6:='【压力/支撑诊断】 '+
IFS(压力Ⅰ=压力Ⅰ and 压力Ⅰ>0,'第一压力位:'+numtostr(压力Ⅰ),'')+
IFS(支撑Ⅰ=支撑Ⅰ and 支撑Ⅰ>0,' 第一支撑位:'+numtostr(支撑Ⅰ),'')+
IFS(压力Ⅱ=压力Ⅱ and 压力Ⅱ>0,' 第二压力位:'+numtostr(压力Ⅱ),'')+
IFS(支撑Ⅱ=支撑Ⅱ and 支撑Ⅱ>0,' 第二支撑位:'+numtostr(支撑Ⅱ),'');
DIFF:="macd.DIFF"(26,12,9);
DEA:="MacD.DEA"(26,12,9);
MACD:="MACD.MACD"(26,12,9);
诊断1:='【MACD诊断】 '+IFS(DIFF>=0,'MACD指标显示该股处于多头行情中','MACD指标显示该股处于空头行情中')+
IFS(DIFF>=0 AND MACD>=0 AND MACD>REF(MACD,1),'且有加速上涨趋势。','')+
IFS(DIFF>=0 AND MACD>=0 AND MACD<=REF(MACD,1),'但上涨趋势有所减缓,短线投资者可逢高卖出,但当回落至均线或其他支撑位时应及时回补。','')+
IFS(DIFF>=0 AND MACD<0 AND MACD>=REF(MACD,1),',目前正处于回落整理阶段,但整理即将结束,可在均线或其他支撑位附近逢低买入,但当整理完成后选择再次向下突破时应注意及时止损。','')+
IFS(DIFF>=0 AND MACD<0 AND MACD<REF(MACD,1),',目前正处于回落整理阶段,且回落有加速趋势。','')+
IFS(DIFF<0 AND MACD<=0 AND MACD<REF(MACD,1),'且有加速下跌趋势。','')+
IFS(DIFF<0 AND MACD<=0 AND MACD>=REF(MACD,1),'但下跌趋势有所减缓,可在W&R指标大于90时逢低买入,但有可能再次加速下跌,注意及时止损。','')+
IFS(DIFF<0 AND MACD>0 AND MACD>REF(MACD,1),',目前正处于反弹阶段,投资者应保持谨慎。','')+
IFS(DIFF<0 AND MACD>0 AND MACD<REF(MACD,1),',短线反弹已经结束,应继续坚持谨慎原则。','')+
IFS(CROSS(DIFF,0),'该股今日从空头市场转换为多头行情。','')+
IFS(CROSS(0,DIFF),'该股今日从多头市场转换为空头行情。','');
K:="kd.K"(9,3,3);
D:="KD.D"(9,3,3);
诊断2:='【kdj诊断】 '+IFS(K>80 AND CROSS(D,K)=0,'KD指标提示该股已经处于超买状态,如果KD指标死叉应及时卖出。','')+
IFS(K<20 AND CROSS(K,D)=0,'KD指标提示该股已经处于超卖状态,如果KD指标金叉应及时买入。','')+
IFS(CROSS(K,D) AND LLV(K,3)<40,'KD低位金叉,建议买入。','')+
IFS(CROSS(D,K) AND HHV(K,3)>80,'KD高位死叉,建议卖出。','');
LC := REF(CLOSE,1);
rsi1:=SMA(MAX(CLOSE-LC,0),6,1)/SMA(Abs(CLOSE-LC),6,1)*100;
RSI2:=SMA(MAX(CLOSE-LC,0),12,1)/SMA(ABS(CLOSE-LC),12,1)*100;
RSI3:=SMA(MAX(CLOSE-LC,0),24,1)/SMA(ABS(CLOSE-LC),24,1)*100;
RSII:=SMA(MAX(CLOSE-LC,0),3,1)/SMA(ABS(CLOSE-LC),3,1)*100;
TYP := (HIGH + LOW + CLOSE)/3;
货币比:=SUM(IF(TYP>REF(TYP,1),TYP*vol,0),14)/SUM(IF(TYP<REF(TYP,1),TYP*VOL,0),14);
mfi:=100-(100/(1+货币比));
a1:=count(cross(mfi,80),20);
a2:=count(cross(20,mfi),20);
wr:=-100*(HHV(HIGH,14)-CLOSE)/(HHV(HIGH,14)-LLV(LOW,14));
PSY:=COUNT(CLOSE>REF(CLOSE,1),12)/12*100;
bias := (CLOSE-MA(CLOSE,5))/MA(CLOSE,5)*100;
ARN := SUM(HIGH-OPEN,26)/SUM(OPEN-LOW,26);
obv:=SUM(IF(CLOSE>REF(CLOSE,1),VOL,IF(CLOSE<REF(CLOSE,1),-VOL,0)),34);
W3:=MA(V,5)<=MA(V,10);
诊断7:='【技术解盘】 '+
IFS(W3,'5日均量死叉10日均量,做多能量枯竭,卖出;','')+
IFS(ARN>1.5,'注意价格将进入回挡下跌,可准备卖出;','')+
IFS(ARN<0.4,'股价已达到低点,可考虑介入;','')+
IFS(obv>0,'OBV多头信号;','')+
IFS(obv<0,'OBV空头信号;','')+
IFS(CROSS(BIAS,10),'BIAS超买,短线即将见顶,应及时卖出;','')+
IFS(CROSS(-10,BIAS),'BIAS超卖,短线即将见底,应伺机买进;','')+
IFS(WR>-20,'W&R超买,短线即将见顶,应及时卖出;','')+
IFS(WR<-80,'W&R超卖,短线即将见底,应伺机买进;','')+
IFS(psy<20,'心理压力小,应及时买入;','')+
IFS(PSY>80,'心理压力大,应及时卖出;','')+
ifs(mfi<20,'mfi指标在20以下处于超卖信号区,不久将要上涨;','')+
ifs(mfi>80,'mfi指标在80以上处于超买信号区,股价将要下跌;','')+
ifs(a1,'mfi指标在两月前曾发出超买信号,表明股价将会下跌;','')+
ifs(a2,'mfi指标在两月前曾发出超卖信号,表明股价将会上涨;','');
诊断8:='【RSI解盘】 '+
ifs(rsi1<15 AND (BArslAST(rsi1<15)>=1),'RSI超卖--买入信号;','')+
ifs(RSI1>85 AND (BARSLAST(RSI1>85)>=1),'RSI超买--卖出信号;','')+
ifs((((LLV(LOW,20)=LOW) AND (NOT(LLV(RSI1,20)=RSI1))) OR (COUNT(CLOSE<REF(CLOSE,1),30)>18 AND (COUNT(RSI1>REF(RSI1,1),30)>18))) AND (RSI1<20),'RSI底背离--买入信号;','')+
ifs((((HHV(HIGH,20)=HIGH) AND (NOT(HHV(RSI1,20)=RSI1))) OR (COUNT(CLOSE>REF(CLOSE,1),30)>18 AND (COUNT(RSI1<REF(RSI1,1),30)>18))) AND (RSI1>80),'RSI顶背离--卖出信号;','')+
ifs(CROSS(RSI1,RSI2) AND (RSI1<50),'RSI金叉--买入信号;','')+
ifs(CROSS(RSI2,RSI1) AND (RSI1>50),'RSI死叉--卖出信号;','')+
ifs(RSI1<5 ,'RSI极低位--强买入信号;','')+
ifs(RSI1>93,'RSI极高位--强卖出信号;','');
kk:=150;
DRAWTEXTREL(50 ,10, 诊断4+' '+诊断3),colorred;
DRAWTEXTREL(50 ,10+kk, 诊断6),colorbrown;
DRAWTEXTREL(50 ,10+2*kk, 诊断5),colorblue;
DRAWTEXTREL(50 ,10+3*kk , 诊断7),color000999;
DRAWTEXTREL(50 ,10+4*kk , 诊断1),colore66878;
DRAWTEXTREL(50 ,10+5*kk , 诊断8+' '+诊断2),colorbrown;