%>
SHORT:=12; LONG:=26; M:=9; DIFF:=(EMA(CLOSE,SHORT) - EMA(CLOSE,LONG)); DEA:=EMA(DIFF,M); MACD2:=(2 * (DIFF - DEA)); DU0:=CROSS(DIFF,0); UD0:=CROSS(0,DIFF); TDU0:=BARSLAST(DU0); TUD0:=BARSLAST(UD0); DU3:=REF(DU0,1); UD3:=REF(UD0,1); TDU3:=BARSLAST(DU3); TUD3:=BARSLAST(UD3); UDGLINE:=IF((TDU3 < TUD3),REF(HHV(HIGH,2),TDU3),REF(LLV(LOW,2),TUD3)); JDU0:=(((REF(CLOSE,1) <= REF(UDGLINE,1)) AND (CLOSE > UDGLINE)) AND (TDU0 < TUD0)); JUD0:=(((REF(CLOSE,1) >= REF(UDGLINE,1)) AND (CLOSE < UDGLINE)) AND (TUD0 < TDU0)); JDU1:=(JDU0 AND (COUNT(JDU0,TDU0) = 1)); JUD1:=(JUD0 AND (COUNT(JUD0,TUD0) = 1)); JDU2:=(JDU1 AND (REF(BARSLAST(JUD1),1) < REF(BARSLAST(JDU1),1))); JUD2:=(JUD1 AND (REF(BARSLAST(JUD1),1) > REF(BARSLAST(JDU1),1))); JDU3:=(JDU1 AND (REF(BARSLAST(JUD1),1) > REF(BARSLAST(JDU1),1))); JUD3:=(JUD1 AND (REF(BARSLAST(JUD1),1) < REF(BARSLAST(JDU1),1))); BSLINE:=IF((BARSLAST(JDU2) < BARSLAST(JUD2)),IF(REF(CROSS(0,MACD2),1),LLV(LOW,2),REF(LLV(LOW,2),BARSLAST(REF(CROSS(0,MACD2),1)))),IF(REF(CROSS(MACD2,0),1),HHV(HIGH,2),REF(HHV(HIGH,2),BARSLAST(REF(CROSS(MACD2,0),1))))); DRAWLINE((JDU1 OR (BARSLAST(JDU1) > BARSLAST(JUD1))),MAX(HHV(DIFF,0),HHV(MACD2,0)),(JUD1 OR (BARSLAST(JDU1) < BARSLAST(JUD1))),MAX(HHV(DIFF,0),HHV(MACD2,0)),0),CIRCLEDOT,colorred; DRAWLINE((JUD1 OR (BARSLAST(JDU1) < BARSLAST(JUD1))),MIN(LLV(DIFF,0),LLV(MACD2,0)),(JDU1 OR (BARSLAST(JDU1) > BARSLAST(JUD1))),MIN(LLV(DIFF,0),LLV(MACD2,0)),0),CIRCLEDOT,colorgreen; STICKLINE((MACD2 >= 0),0,MACD2,1,1),colorred; STICKLINE(((MACD2 >= 0) AND (MACD2 < REF(MACD2,1))),0,MACD2,1,0),colorred; STICKLINE((MACD2 < 0),0,MACD2,1,0),COLORFFFF00; STICKLINE(((MACD2 < 0) AND (MACD2 > REF(MACD2,1))),0,MACD2,1,1),COLORFFFF00; DIF:DIFF,colorwhite; MACD:DEA,coloryellow; DEF:MACD2,LINETHICK0,COLORFFFF00; STICKLINE((CLOSE > 0),0,0,10,0),COLOR808080; DEFUT:=BARSLAST(CROSS(MACD2,0)); DEFDT:=BARSLAST(CROSS(0,MACD2)); DEFUL:=IF((MACD2 >= 0),HHV(MACD2,(DEFUT + 1)),REF(HHV(MACD2,(DEFUT + 1)),(DEFDT + 1))); DEFDL:=IF((MACD2 < 0),LLV(MACD2,(DEFDT + 1)),REF(LLV(MACD2,(DEFDT + 1)),(DEFUT + 1))); DEFU2L:=REF(DEFUL,(DEFUT + 1)); DEFD2L:=REF(DEFDL,(DEFDT + 1)); DRAWICON(((((LLV(MACD2,4) > 0) AND (MACD2 < REF(MACD2,1))) AND (REF(MACD2,1) > REF(MACD2,2))) AND (REF(MACD2,2) > REF(MACD2,3))),MACD2,2); DRAWICON(((((HHV(MACD2,4) < 0) AND (MACD2 > REF(MACD2,1))) AND (REF(MACD2,1) < REF(MACD2,2))) AND (REF(MACD2,2) < REF(MACD2,3))),MACD2,1); IF(((((JUD1 OR (BARSLAST(JDU1) > BARSLAST(JUD1))) AND (MACD2 >= 0)) AND (REF(MACD2,1) < REF(DEFU2L,1))) AND (MACD2 > DEFU2L)),MACD2,DRAWNULL),CIRCLEDOT,coloryellow; IF(((((JDU1 OR (BARSLAST(JDU1) < BARSLAST(JUD1))) AND (MACD2 < 0)) AND (REF(MACD2,1) > REF(DEFD2L,1))) AND (MACD2 < DEFD2L)),MACD2,DRAWNULL),CIRCLEDOT,coloryellow; 低位金叉:CROSS(DIFF,DEA) AND DIFF<-0.1; STICKLINE(低位金叉,0,0.02,6,0),coloryellow; DRAWTEXT(低位金叉,0.025,'A1'),coloryellow; JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0)); 二次金叉:CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1; STICKLINE(二次金叉,0,0.03,6,0),COLORFF00FF; DRAWICON(二次金叉,DEA*0.9,1) ; DRAWTEXT(二次金叉,0.035,'2'),coloryellow; A1:=BARSLAST(REF(CROSS(DIFF,DEA),1)); 底背离:=REF(CLOSE,A1+1)>CLOSE AND DIFF>REF(DIFF,A1+1) AND CROSS(DIFF,DEA); STICKLINE(底背离,0,0.01,6,0),COLOR00FF00; 底背:DRAWLINE(A1=0,DEA,底背离,DEA,0),colorred,LINETHICK2; DRAWTEXT(底背离,0.015,'A'),COLORFF00FF; A2:=BARSLAST(REF(CROSS(DEA,DIFF),1)); 顶背离:=REF(CLOSE,A2+1)<CLOSE AND REF(DIFF,A2+1)>DIFF AND CROSS(DEA,DIFF); 顶背:DRAWLINE(A2=0,DEA,顶背离,DEA,0),colorgreen,LINETHICK2; DRAWTEXT(低位金叉 AND 二次金叉 AND 底背离,0.05,'全'),COLOR0000FF,LINETHICK2; R1:=EMA(HHV(HIGH,500),21); R2:=EMA(HHV(HIGH,250),21); R3:=EMA(HHV(HIGH,90),21); R4:=EMA(LLV(LOW,500),21); R5:=EMA(LLV(LOW,250),21); R6:=EMA(LLV(LOW,90),21);
同花顺MACD缠论指标公式
{股票教程网-http://9188edu.net承接通达信软件和公式破解,普通加密破解,完全加密破解,导入密码破解,时间限制破解,公式编写,可按您的要求写公式指标,价格按难度不同报价,有需要可以找我们}