MACD背离指标编写公式
macd顶背离选股公式
macd顶背离选股公式
MACD(Moving Average Convergence Divergence)指标是一
种技术分析工具,用于判断股票价格的趋势性和买入卖出时机的选择。
顶背离是指股票价格形成高点,而MACD指标形成
低点,预示着价格可能会下跌。
以下是MACD顶背离选股的公式:
1. 计算MACD指标:
- 首先,计算股票的12日指数移动平均线(EMA12)和26
日指数移动平均线(EMA26)。
- 然后,计算MACD线,即EMA12减去EMA26。
- 最后,计算MACD的9日简单移动平均线(EMA9)。
2. 确定顶背离:
- 找出股票价格的高点,比如之前的高点或当前的高点。
- 找出对应的MACD指标的低点,即MACD线形成的低点。
3. 判断顶背离:
- 如果股票价格形成高点,而MACD指标形成低点,则判断
为顶背离。
- 这种顶背离可能是一个卖出信号,暗示着股票价格可能会
下跌。
需要注意的是,MACD顶背离并不是绝对可靠的信号,可能
存在假信号。
因此,建议结合其他技术指标和股票基本面分析,综合判断投资决策。
MACD背离指标编写公式
MACD背离指标编写公式DIFF:EMA(CLOSE,12)-EMA(CLOSE,27); DEA:EMA(DIFF,9); MACD:=2*(DIFF-DEA); STICKLINE(MACD>=0,MACD,0,2,1),COLORF00FF0;STICKLINE(MACD<0,MACD,0,2,1),COLORWHITE;STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR00AAFF; STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR00BBFF; STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR00CCFF; STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR00DDFF; STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR00EEFF; STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR00FFFF; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR0000AA; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR0011BB; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR0022CC; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR0033DD; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR0044EE; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR0055FF; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORAA00BB; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORBB11BB; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORCC22BB; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORDD33BB; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLOREE44BB; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORFF55BB; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORFFAA00; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORFFBB11; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORFFCC22; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORFFDD33; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORFFEE44; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORFFFF55; IF(DIFF<0,DIFF,0),COLORRED,LINETHICK1;IF(DIFF<0,0,DIFF),COLORYELLOW,LINETHICK1;IF(DIFF<DEA,DIFF,DEA),COLOR00FF00,LINETHICK1;IF(DIFF>DEA,DEA,DEA),COLORWHITE,LINETHICK1; 低位金叉:=CROSS(DIFF,DEA) AND DIFF<-0.1;STICKLINE(低位金叉,0,-0.18,2,0),COLORYELLOW; DRAWTEXT(低位金叉,-0.1,' 低位金叉'),COLORYELLOW; JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0)); 二次金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1; STICKLINE(二次金叉,0,-0.18,2,0),COLORFF00FF; DRAWICON(二次金叉,DEA*1.04,13) DRAWTEXT(二次金叉,-0.1,' 二次金叉'),COLORFF00FF; 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.13,2,0),COLOR00FF00; DRAWLINE(A1=0,DEA,底背离,DEA,0),COLORRED,LINETHICK2; DRAWTEXT(底背离,0.1,' 底背离'),COLOR00FF00; 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;。
通达信DMI,MACD.RSI背离指标公式
通达信DMI,MACD.RSI背离指标公式N:=14;MM:=6;RSV:=(CLOSE-LLV(LOW,10))/(HHV(HIGH,10)-LLV(LOW,10))*100;K:=SMA(RSV,3,1);D:=SMA(K,3,1);J:=3*K-2*D;DIFF:=EMA(CLOSE,12) - EMA(CLOSE,26);DEA:=EMA(DIFF,9);MACD:=2*(DIFF-DEA), COLORSTICK;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;A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));B1:=REF(CLOSE,A1+1)>CLOSE AND REF(DIFF,A1+1)<DIFF AND CROSS(DIFF,DEA); MACD底背离:FILTER(B1>0,5);STICKLINE(FILTER(B1>0,5),0,10,1,0),COLOR00FF00;DRAWTEXT(FILTER(B1>0,5),10,'MACD底背'),COLOR00FF00;A3:=BARSLAST(REF(CROSS(RSI1,RSI2),1));B3:=REF(CLOSE,A3+1)>CLOSE AND REF(RSI1,A3+1)<RSI1 AND CROSS(RSI1,RSI2); RSI底背离:FILTER(B3>0,5),LINETHICK0;STICKLINE(FILTER(B3>0,5),0,30,1,0),COLORFFFF00;DRAWTEXT(FILTER(B3>0,5),30,'RSI底背'),COLORFFFF00;C1:=BARSLAST(REF(CROSS(DEA,DIFF),1));D1:=REF(CLOSE,C1+1)<CLOSE AND REF(DIFF,C1+1)>DIFF AND CROSS(DEA,DIFF); MACD顶背离:FILTER(D1>0,5),LINETHICK0;STICKLINE(FILTER(D1>0,5),100,80,1,0),COLOR0066FF;DRAWTEXT(FILTER(D1>0,5),80,'MACD顶背'),COLOR0066FF;C3:=BARSLAST(REF(CROSS(RSI2,RSI1),1));D3:=REF(CLOSE,C3+1)<CLOSE AND REF(RSI1,C3+1)>RSI1 AND CROSS(RSI2,RSI1); RSI顶背离:FILTER(D3>0,5),LINETHICK0;STICKLINE(FILTER(D3>0,5),100,80,1,0),COLOR15F70A;DRAWTEXT(FILTER(D3>0,5),80,'RSI顶背'),COLOR15F70A;{以上不动}TR1:=EMA(MAX(MAX(HIGH-LOW,ABS(HIGH-REF(CLOSE,1))),ABS(REF(CLOSE,1)-LOW)),21);HD :=HIGH-REF(HIGH,1);LD :=REF(LOW,1)-LOW;DMP:=EMA(IF(HD>0 AND HD>LD,HD,0),21);DMM:=EMA(IF(LD>0 AND LD>HD,LD,0),21);PDI:= DMP*100/TR1;MDI:= DMM*100/TR1;ADX: EMA((PDI-MDI)/(MDI+PDI)*100,6)*2;ADXR:EMA(ADX,6);ADMA:=EMA(ADX,20);OMD:(ADX-2*ADMA+ADXR)/2, COLORSTICK;DRAWBAND(ADX,RGB(155,50,50),ADXR,RGB(0,100,50));STICKLINE(OMD>REF(OMD,1) AND OMD>0,0,OMD,1,0),COLORRED;STICKLINE(OMD>REF(OMD,1) AND OMD<0,0,OMD,1,0),COLORGREEN; STICKLINE(OMD<REF(OMD,1),0,OMD,1,0),COLORCBCBC0;STICKLINE(OMD>=0 OR OMD<=0,0,0,50,1),COLORWHITE;ADX1:ADX,COLORRED;ADXR1:ADXR,COLORYELLOW;{DMI顶底背离}DM1:=BARSLAST(REF(CROSS(ADX1,ADXR1),1));DM2:=REF(CLOSE,DM1+1)>CLOSE AND REF(ADX1,DM1+1)<ADX1 ANDCROSS(ADX1,ADXR1);DMI底背离:FILTER(DM2>0,5),LINETHICK0;DRAWTEXT(FILTER(DM2>0,5),ADX1,'DMI底背'),COLORFFFF00;DM3:=BARSLAST(REF(CROSS(ADXR1,ADX1),1));DM4:=REF(CLOSE,DM3+1)<CLOSE AND REF(ADX1,DM3+1)>ADX1 AND CROSS(ADXR1,ADX1);DMI顶背离:FILTER(DM4>0,5),LINETHICK0;DRAWTEXT(FILTER(DM4>0,5),ADX1,'DMI顶背'),COLORGREEN;。
MACD顶底背离指标
MACD顶底背离指标DIFF:EMA(CLOSE,12)-EMA(CLOSE,27);DEA:EMA(DIFF,9);MACD:=2*(DIFF-DEA);STICKLINE(MACD>=0,MACD,0,4,1),COLORF00FF0;STICKLINE(MACD<0,MACD,0,4,1),COLORWHITE;STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,4,0 ),COLOR00AAFF; STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,3.3,0 ),COLOR00BBFF; STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,2.2,0 ),COLOR00CCFF; STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,1.65,0 ),COLOR00DDFF; STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,1.1,0 ),COLOR00EEFF; STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,0.55,0 ),COLOR00FFFF; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,4 ,0 ),COLOR0000AA; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,3.3 ,0 ),COLOR0011BB; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,2.2,0 ),COLOR0022CC; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,1.65 ,0 ),COLOR0033DD; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,1.1 ,0 ),COLOR0044EE; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,0.55 ,0 ),COLOR0055FF; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,4,0 ),COLORAA00BB; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,3.3 ,0 ),COLORBB11BB; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,2.2,0 ),COLORCC22BB; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,1.65,0 ),COLORDD33BB;STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,1.1,0 ),COLOREE44BB; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,0.55 ,0 ),COLORFF55BB; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,4,0 ),COLORFFAA00; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,3.3 ,0 ),COLORFFBB11; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,2.2,0 ),COLORFFCC22; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,1.65 ,0 ),COLORFFDD33; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,1.1 ,0 ),COLORFFEE44; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,0.55 ,0 ),COLORFFFF55;IF(DIFF<0,DIFF,0),COLORRED,LINETHICK1;IF(DIFF<0,0,DIFF),COLORYELLOW,LINETHICK1;IF(DIFF<DEA,DIFF,DEA),COLOR00FF00,LINETHICK1;IF(DIFF>DEA,DEA,DEA),COLORWHITE,LINETHICK1;低位金叉:=CROSS(DIFF,DEA) AND DIFF<-0.1;STICKLINE(低位金叉,0,-0.18,6,0),COLORYELLOW;DRAWTEXT(低位金叉,-0.1,' 低位金叉'),COLORYELLOW;JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));二次金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1; STICKLINE(二次金叉,0,-0.18,6,0),COLORFF00FF;DRAWICON(二次金叉,DEA*1.04,13) ;DRAWTEXT(二次金叉,-0.1,' 二次金叉'),COLORFF00FF;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.13,6,0),COLOR00FF00;DRAWLINE(A1=0,DEA,底背离,DEA,0),COLORRED,LINETHICK2;DRAWTEXT(底背离,0.1,' 底背离'),COLOR00FF00;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;。
MACD顶底背离通达信指标公式源码
MACD顶底背离通达信指标公式源码```pascal{MACD指标的顶底背离}{参数:N(计算的周期)}MA1:=MA(CLOSE,5);MA2:=MA(CLOSE,35);DIF:EMA1-EMA2;DEA:EMA(DIF,5);MACD:(DIF-DEA);TopSignal:(REF(HIGH<N,1) AND HIGH[1]>HIGH[2] ANDHIGH[1]>HIGH) AND REF(DEA,1)<0 AND DEA>0;BottomSignal:(REF(LOW<N,1) AND LOW[1]<LOW[2] AND LOW[1]<LOW) AND REF(DEA,1)>0 AND DEA<0;{ 在图表上画出TopSignal和BottomSignal的信号 }IF TopSignal THEN DRAWICON(TopSignal,'↑');IF BottomSignal THEN DRAWICON(BottomSignal,'↓');```源码的主要部分如下所示:-首先定义了两个移动平均线MA1和MA2,分别计算了收盘价的5日和35日均线。
-然后计算了MACD指标的快线(DIF)和慢线(DEA),采用了指数平滑移动平均线(EMA)的计算方法。
-最后根据顶底背离的条件判断,通过比较前一日和当前日的最高价和最低价,以及前一日和当前日的DEA值,来确定顶底背离的信号。
在图表上,通过DRAWICON函数可以绘制出顶底背离的箭头标志,上箭头表示顶背离,下箭头表示底背离。
请注意,这只是一个简化版的MACD顶底背离指标公式,具体的实现还需要根据具体的需求和市场情况进行调整和优化。
对于股票投资和分析,建议综合考虑多个指标和因素,进行综合分析和判断。
文华财经指标公式源码MACD顶背离底背离
DIFF:EMA(CLOSE,12) - EMA(CLOSE,26);DEA:EMA(DIFF,9),COLORYELLOW;MACD:=2*(DIFF-DEA),NODRAW;JC:=CROSS(DIFF,DEA);SC:=CROSSDOWN(DIFF,DEA);N1:=BARSLAST(JC)+1;N2:=BARSLAST(SC)+1;HH:=V ALUEWHEN(CROSSDOWN(DIFF,DEA),HHV(H,N1));//上次MACD红柱期间合约最大值HH2:=V ALUEWHEN(CROSSDOWN(DIFF,DEA),REF(HH,1));//上上次MACD红柱期间合约最大值MHD:=V ALUEWHEN(CROSSDOWN(DIFF,DEA),HHV(MACD,N1));//上次MACD红柱期间MACD最大值MHD2:=V ALUEWHEN(CROSSDOWN(DIFF,DEA),REF(MHD,1));//上上次MACD红柱期间MACD最大值LL:=VALUEWHEN(CROSS(DIFF,DEA),LLV(L,N2));LL2:=V ALUEWHEN(CROSS(DIFF,DEA),REF(LL,1));MLD:=V ALUEWHEN(CROSS(DIFF,DEA),LLV(MACD,N2));MLD2:=V ALUEWHEN(CROSS(DIFF,DEA),REF(MLD,1));A:MACD<0&&HH>HH2&&MHD<MHD2;//顶背离B:MACD>0&&LL<LL2&&MLD>MLD2;A1:=BACKSET(CROSS(A,0.5),REF(HHVBARS(MACD,N1),1)+1+1);A2:=BACKSET(CROSS(A,0.5),REF(HHVBARS(MACD,N1),SUMBARS(SC,2))+SUMBARS( SC,2)+1);B1:=BACKSET(CROSS(B,0.5),REF(LLVBARS(MACD,N2),1)+1+1);B2:=BACKSET(CROSS(B,0.5),REF(LLVBARS(MACD,N2),SUMBARS(JC,2))+SUMBARS(JC ,2)+1);//DRAWLINE1(CROSS(A2,0.5),MACD,CROSS(A1,0.5),MACD,0),COLORRED,LINETHICK2 ;//DRAWLINE1(CROSS(B2,0.5),MACD,CROSS(B1,0.5),MACD,0),COLORGREEN,LINETHIC K2;//STICKLINE1(MACD>REF(MACD,1),0,MACD,0,0),COLORRED;//STICKLINE1(MACD<REF(MACD,1),0,MACD,0,0),COLORGREEN;//DRAWCOLORLINE(DIFF>REF(DIFF,1),DIFF,COLORWHITE,COLORMAGENTA);//DRAWICON(CROSS(DIFF,0),0,147),V ALIGN0;//DRAWICON(CROSSDOWN(DIFF,0),0,146),V ALIGN2;。
准确的macd底背离自动画线指标公式
准确的macd底背离自动画线指标公式MACD(Moving Average Convergence Divergence)是一种常用的技术指标,它通过计算两个移动平均线的差异来分析股票价格的趋势和动能。
MACD底背离是一种常见的技术形态,它可以帮助投资者判断股票价格反转的可能性。
本文将介绍MACD底背离的自动画线指标公式,并解释其含义和应用。
MACD底背离是指股票价格和MACD指标之间出现的一种特殊形态,它表明股票价格下跌趋势的动能减弱,可能会出现反转。
MACD底背离的自动画线指标公式可以通过计算MACD指标和股票价格之间的差异来判断是否存在底背离形态。
我们需要计算MACD指标。
MACD指标由两条线组成,分别是DIF线和DEA线。
DIF线是短期移动平均线(一般为12日)与长期移动平均线(一般为26日)的差值,而DEA线是DIF线的9日移动平均值。
通过计算DIF线和DEA线的差异,我们可以得到MACD指标的数值。
接下来,我们需要计算股票价格与MACD指标之间的差异。
一般情况下,我们可以将股票价格与MACD指标的DIF线进行比较。
如果股票价格出现下跌,而DIF线出现上升,则可能存在底背离形态。
这是因为股票价格的下跌动能减弱,可能会发生反转。
根据上述原理,我们可以得到MACD底背离的自动画线指标公式如下:1. 计算MACD指标:MACD = DIF线 - DEA线其中,DIF线= 短期移动平均线(一般为12日)- 长期移动平均线(一般为26日)DEA线 = DIF线的9日移动平均值2. 计算股票价格与MACD指标之间的差异:差异 = 股票价格 - DIF线3. 判断是否存在底背离形态:如果差异为负值,且差异出现下降趋势,同时MACD指标出现上升趋势,则可能存在底背离形态。
MACD底背离的自动画线指标公式可以帮助投资者快速准确地判断股票价格反转的可能性。
当股票价格出现下跌趋势时,如果MACD 指标出现上升趋势,同时股票价格与MACD指标之间的差异逐渐减小,那么可能会出现底背离形态,投资者可以考虑适时买入股票。
macd指标背离公式编写
macd指标背离公式编写MACD指标是一种常用的技术指标,用于判断股票或其他金融资产的买入和卖出时机。
在MACD指标中,背离是一种重要的信号,可以帮助投资者捕捉到市场价格的转折点。
本文将介绍MACD指标的背离公式,并分析其在实际交易中的应用。
MACD指标是由两条线和一个柱状图组成的。
其中,快线称为DIF线,慢线称为DEA线,柱状图则反映了DIF线和DEA线之间的差异。
MACD指标的计算公式如下:DIF线 = 12日EMA - 26日EMADEA线 = 9日DIF的EMAMACD柱状图 = DIF线 - DEA线MACD指标的背离是指当价格与MACD指标的走势相背离时,可能发生市场价格的转折。
背离分为正背离和负背离两种情况。
正背离发生在价格创新低而MACD柱状图却没有创新低的情况下。
这意味着市场上的卖盘力量减弱,可能预示着价格将上涨。
投资者可以在正背离出现时考虑买入。
负背离发生在价格创新高而MACD柱状图却没有创新高的情况下。
这意味着市场上的买盘力量减弱,可能预示着价格将下跌。
投资者可以在负背离出现时考虑卖出。
MACD指标背离的判断方法可以通过观察价格和MACD指标的走势来进行。
具体而言,当价格创新高或新低时,观察MACD柱状图是否同步创新高或新低。
如果MACD柱状图没有同步创新高或新低,就可能出现背离信号。
在实际交易中,投资者可以结合背离信号和其他技术指标来进行判断。
例如,可以观察背离信号是否与支撑位或阻力位重合,以增加交易的成功率。
此外,还可以结合其他技术分析工具,如移动平均线、相对强弱指标等,进行综合判断。
然而,需要注意的是,MACD指标背离并非绝对准确的买卖信号,投资者在使用时应谨慎。
背离信号只能作为参考,需要结合市场的整体趋势和其他技术指标来进行判断。
总结起来,MACD指标的背离是一种重要的买卖信号,可以帮助投资者捕捉市场价格的转折点。
正背离和负背离分别预示着价格上涨和下跌的可能性。
投资者可以结合背离信号和其他技术指标进行综合判断,但需要注意背离信号并非绝对准确,需要谨慎使用。
超短macd背离通达信指标公式源码
WY1001:=(2*CLOSE+HIGH+LOW)/4;{非常准}WY1002:=EMA(WY1001,4);WY1003:=EMA(WY1002,4);WY1004:=EMA(WY1003,4);XYS0:(WY1004-REF(WY1004,1))/REF(WY1004,1)*100;STICKLINE(XYS0>=0,XYS0,0,2,0),COLOR0000FF;STICKLINE(XYS0<0,XYS0,0,2,0),COLORFFFF00;PJGJ:=AMOUNT/VOL/100;SSRYDJX:=MA(PJGJ,13);SSRCJL:=EMA(VOL,13);SSRCJE:=EMA(AMOUNT,13);SSRCBJX:=SSRCJE/SSRCJL/100;CYS13:=(CLOSE-SSRCBJX)/SSRCBJX*100;XYSHSL:=EMA(VOL/CAPITAL*100,13);STICKLINE(XYSHSL>6.1 AND CYS13>5 ,2 ,0 ,2 ,0 ),COLORGREEN; STICKLINE(XYSHSL>3.8 AND CYS13>5 ,1.5 ,0 ,2 ,0 ),COLORYELLOW; STICKLINE(XYSHSL>2.1 AND CYS13>5 ,1 ,0 ,2 ,0 ),COLORCYAN; STICKLINE(XYSHSL>1.8 AND CYS13>5 ,0.5 ,0 ,2 ,0 ),COLORBLUE;XYS1:MA(XYS0,2),COLOR00FF00;XYS2:MA(XYS0,1),COLOR00FFFF;STICKLINE(CROSS(XYS2,XYS1) , 0.2 ,0 ,2,0 ),COLOR00FFFF; STICKLINE(XYS2>XYS1 AND 0>XYS2 ,XYS2 ,0 ,2 ,0),COLORFF00FF; STICKLINE(XYS2<XYS1 AND 0<XYS2 ,XYS2 ,0 ,2,1),COLOR00FF00; STICKLINE(CROSS(XYS1,XYS2) AND XYS2>0 ,XYS2 ,0 ,2 ,0),COLOR00FF00;A1:=BARSLAST(REF(CROSS(XYS2,XYS1),1));底背离:=REF(CLOSE,A1+1)>CLOSE AND XYS2>REF(XYS2,A1+1) AND CROSS(XYS2,XYS1);DRAWTEXT(底背离,XYS2*1,' 底背离'),COLORWHITE;DRAWICON(底背离,XYS2*1,38);DA1:=BARSLAST(REF(CROSS(XYS2,XYS1),1));D底背离:=REF(CLOSE,DA1+1)>CLOSE AND XYS2>REF(XYS2,DA1+1) AND CROSS(XYS2,XYS1);底背画线:DRAWLINE(DA1=0,XYS1,D底背离,XYS1,0),COLORWHITE,DOTLINE,LINETHICK3;A2:=BARSLAST(REF(CROSS(XYS1,XYS2),1));{MACD日线顶背离}顶背离:=REF(CLOSE,A2+1)<CLOSE AND REF(XYS1,A2+1)>XYS1 AND CROSS(XYS1,XYS2);DRAWTEXT(顶背离,XYS1*1,' 顶背离'),COLORGREEN;DRAWICON(顶背离,XYS1*1,39);DA2:=BARSLAST(REF(CROSS(XYS1,XYS2),1));D顶背离:=REF(CLOSE,DA2+1)<CLOSE AND REF(XYS1,DA2+1)>XYS2 AND CROSS(XYS1,XYS2);顶背画线:DRAWLINE(DA2=0,XYS1,顶背离,XYS1,0),COLORLIGREEN,DOTLINE,LINETHICK2;。
【通达信】经典MACD(背离)
【通达信】经典MACD(背离)-指标公式源码DIF:EMA(CLOSE,12)-EMA(CLOSE,26),COLORRED,LINETHICK2;DEA:EMA(DIF,9),COLORWHITE,LINETHICK2;持仓段:=0,COLOR00CFFF;空仓段:=0,COLORFFCCFF;STICKLINE(DIF>DEA,-0.5,-0.6,10,1),COLOR00CFFF;STICKLINE(DIF<DEA,-0.5,-0.6,10,1),COLORFFCCFF;MACD:(DIF-DEA)*2,COLORSTICK;STICKLINE(((MACD<REF(MACD,1)) AND (MACD>0)),0,MACD,1,0),COLORLIBLUE,LINETHICK2;STICKLINE(((MACD>REF(MACD,1)) AND (MACD<0)),0,MACD,1,0),COLORFF00FF,LINETHICK2;建仓:IF(DIF<0,DIF,0),COLORYELLOW,LINETHICK2;加仓:IF(DIF<0,0,DIF),COLORRED,LINETHICK2;白线破仓:IF(DIF<DEA,DIF,DEA),COLORWHITE,LINETHICK2;趋势强弱:IF(DIF>DEA,DEA,DEA),COLORFF937F,LINETHICK2;AA:=COUNT(CROSS(DIF,DEA),BARSLAST(DEA>=0));二次金叉:=CROSS(DIF,DEA) AND DEA<0 AND COUNT(AA=2,21)=1;DRAWTEXT(二次金叉,0.2,' 二次金叉'),COLORYELLOW;BB:=COUNT(CROSS(DEA,DIF),BARSLAST(DEA<=0));二次绿叉:=CROSS(DEA,DIF) AND DEA>0 AND COUNT(BB=2,21)=1;DRAWTEXT(二次绿叉,0.2,' 二次绿叉'),COLORGREEN;A1:=BARSLAST(REF(CROSS(DIF,DEA),1));底背离:=REF(CLOSE,A1+1)>CLOSE AND DIF>REF(DIF,A1+1) AND CROSS(DIF,DEA); STICKLINE(底背离,0,0.03,6,0),COLOR00FF00;底背:DRAWLINE(A1=0,DEA,底背离,DEA,0),COLORRED,LINETHICK4; DRAWTEXT(底背离,0.12,' 底背离'),COLORFF00FF;A2:=BARSLAST(REF(CROSS(DEA,DIF),1));顶背离:=REF(CLOSE,A2+1)<CLOSE AND REF(DIF,A2+1)>DIF AND CROSS(DEA,DIF); 顶背:DRAWLINE(A2=0,DEA,顶背离,DEA,0),COLORGREEN,LINETHICK4;【通达信】经典MACD(背离)-指标公式效果图。
MACD底部金叉背离公式大全
MACD底部(零轴以下)金叉背离选股源码DIFF:=EMA(CLOSE,12)-EMA(CLOSE,26);DEA:=EMA(DIFF,9);MACD:=2*(DIFF-DEA);JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0)); 多次金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOU NT=N,22)=1;A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));底背离:=REF(DIFF,A1+1)<DIFF AND REF(DEA,A1+1)<DEA AN D REF(L,A1+1)>L AND CROSS(DIFF,DEA);XG:多次金叉AND 底背离;{N取值范围1~8};更新:针对大家对N值设定麻烦问题,小新在强班指导下,做了一点小小的更改,以后选股就不必再为N值的设定而烦恼了,可以一次过选出底背离情况下N次金叉【至少1次(含1次)】的股票!在此多谢强班的指导! 新源码如下:DIFF:=EMA(CLOSE,12)-EMA(CLOSE,26);DEA:=EMA(DIFF,9);MACD:=2*(DIFF-DEA);JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0)); N次金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOU NT>=1,22)>=1;A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));底背离:=REF(DIFF,A1+1)<DIFF AND REF(DEA,A1+1)<DEA AN D REF(L,A1+1)>L AND CROSS(DIFF,DEA);XG:N次金叉AND 底背离;n=2就是底部2次金叉,n=3 就是3次金叉,以此类推。
MACD背离指标编写公式
MACD背离指标编写公式背离是指价格走势与一些技术指标走势相反的情况。
MACD(Moving Average Convergence Divergence)背离指标是用来察觉价格与MACD指标之间的背离关系的工具。
它可以提供交易者关于价格走势可能发生反转的重要信息。
MACD指标是由两条线组成的,即快线(DIF线)和慢线(MACD线)。
快线是通过计算两个移动平均线的差值获得的,而慢线则是快线的移动平均线。
根据MACD的特性,我们可以定义背离为价格走势创造了新高或新低,而MACD没有创造新高或新低的情况。
下面是编写MACD背离指标的公式:1.计算DIF日线和周线:- DIF日线: DIF_day = EMA(CLOSE, 12) - EMA(CLOSE, 26)- DIF周线: DIF_week = EMA(CLOSE, 12) - EMA(CLOSE, 26)2.计算MACD日线和周线:- MACD日线: MACD_day = EMA(DIF_day, 9)- MACD周线: MACD_week = EMA(DIF_week, 9)3.判断背离情况:- 金叉背离:当价格创造新低,而MACD没有创造新低时,为金叉背离。
公式为:PRICE_LOW > PRICE_LOW[-1] AND MACD_day < MACD_day[-1] AND MACD_week < MACD_week[-1]- 死叉背离:当价格创造新高,而MACD没有创造新高时,为死叉背离。
公式为:PRICE_HIGH < PRICE_HIGH[-1] AND MACD_day >MACD_day[-1] AND MACD_week > MACD_week[-1]以上公式是一个简单的背离指标的编写方式,可以根据实际情况进行调整和改进。
在使用背离指标进行交易时,还需要考虑其他因素,如市场趋势、交易量等。
MACD背离指标公式
主升浪骑马M1:EMA(CLOSE,5),COLORYELLOW;M2:EMA(CLOSE,13),COLORWHITE,LINETHICK1;{MA=13日红线}M3:EMA(M2,34),COLORLIMAGENTA,LINETHICK1;{MA=34日绿线}M4:EMA(M2,55),COLORBLUE,LINETHICK1;{MA=55日红线}M5:EMA(CLOSE,114),COLORLIGREEN,LINETHICK2;TYX3:=MA(REF(HHV((C+L+O+H)/4,30),1),3);TYX4:=MA((C+L+O+H)/4,13);TYX5:=EMA((C+L+O+H)/4,21);STICKLINE(C<TYX5 AND C>O,H,L,0,0),COLORRED;STICKLINE(C<TYX5 AND C>O,C,O,3,1),COLORRED;STICKLINE(C<TYX5 AND C<O,H,L,0,0),COLOR007700;STICKLINE(C<TYX5 AND C<O,C,O,3,0),COLOR005500;STICKLINE(C<TYX5 AND C<O,C,O,2,0),COLOR006600;STICKLINE(C<TYX5 AND C<O,C,O,1,0),COLOR007700;STICKLINE(C>TYX5 AND C<O,H,L,0,0),COLORFFDD44;STICKLINE(C>TYX5 AND C<O,C,O,3,0 ),COLORFF7700;STICKLINE(C>TYX5 AND C<O,C,O,2,0 ),COLORFFAA22;STICKLINE(C>TYX5 AND C<O,C,O,1 ,0 ),COLORFFDD44;STICKLINE(C>TYX5 AND C>O,H,L,0,0 ),COLOR00EEFF;STICKLINE(C>TYX5 AND C>O,C,O,3,0 ),COLOR00AAFF;STICKLINE(C>TYX5 AND C>O,C,O,2,0 ),COLOR00CCFF;STICKLINE(C>TYX5 AND C>O,C,O,1,0 ),COLOR00EEFF;STICKLINE(C>TYX4 AND C>O,H,L,0,0),COLORFF66AA;STICKLINE(C>TYX4 AND C>O,C,O,3,0 ),COLORFF11FF;STICKLINE(C>TYX4 AND C>O,C,O,2,0 ),COLORFF44FF;STICKLINE(C>TYX4 AND C>O,C,O,1,0 ),COLORFF66FF;STICKLINE(C>TYX3 AND C>O,H,L,0,0),COLOR0000DD;STICKLINE(C>TYX3 AND C>O,C,O,3,0),COLOR000099;STICKLINE(C>TYX3 AND C>O,C,O,2,0),COLOR0000BB;STICKLINE(C>TYX3 AND C>O,C,O,1,0),COLOR0000DD;STICKLINE(HIGH=LOW AND CLOSE=OPEN AND (CLOSE/REF(CLOSE,1))>1.048,HIGH,LOW,3,0) ,COLORRED;STICKLINE(HIGH=LOW AND CLOSE=OPEN AND (REF(CLOSE,1)/CLOSE)>1.048,HIGH,LOW,3,0) ,COLOR00FF00;STICKLINE(REF(COUNT(C<TYX3,5)=5,1) AND C>TYX3 AND C>O,C,O,1,0),COLOR00CCFF; DRAWICON((ZIG(3,5)>REF(ZIG(3,5),1)) AND (REF(ZIG(3,5),1)<=REF(ZIG(3,5),2)) AND(REF(ZIG(3,5),2)<=REF(ZIG(3,5),3)),LOW*0.99,1);DRAWICON((ZIG(3,5)<REF(ZIG(3,5),1)) AND (REF(ZIG(3,5),1)>=REF(ZIG(3,5),2)) AND(REF(ZIG(3,5),2)>=REF(ZIG(3,5),3)),H,2);AZ6:=(3 * (SMA((((CLOSE - (LLV(LOW,27))) /((HHV(HIGH,27)) - (LLV(LOW,27)))) * 100),5,1))) - (2 * (SMA((SMA((((CLOSE -(LLV(LOW,27))) / ((HHV(HIGH,27)) - (LLV(LOW,27)))) * 100),5,1)),3,1)));B7:=(10);DRAWTEXT(CROSS(AZ6,B7),L,'←底'),COLORYELLOW;VARC:=(ZIG(3,5)>REF(ZIG(3,5),1)) AND (REF(ZIG(3,5),1)<=REF(ZIG(3,5),2)) AND(REF(ZIG(3,5),2)<=REF(ZIG(3,5),3));VARD:=(ZIG(3,5)<REF(ZIG(3,5),1)) AND (REF(ZIG(3,5),1)>=REF(ZIG(3,5),2)) AND(REF(ZIG(3,5),2)>=REF(ZIG(3,5),3));DRAWTEXT((VARC=1),L,'←朝霞'),COLOR0000FF;DRAWTEXT((VARD=1),H,'←跑'),COLOR00FF00;HZ:=EMA(CLOSE,10);短波:=EMA(HZ,1),COLORRED,LINETHICK1;中波:=EMA(HZ,26),COLORFF00FF,LINETHICK1;均线148天:=EMA(C,148),POINTDOT,LINETHICK1,COLORGREEN;成本:=SUM(AMOUNT,0)/SUM(VOL,0)/100,COLORYELLOW ,LINETHICK2 ;HZ2:=EMA(HZ,8),COLORRED,LINETHICK2;HZ4:=EMA(HZ,39),COLORGREEN,LINETHICK2;A2:=STICKLINE(短波>HZ2,短波,HZ2,3,1),COLORYELLOW;A3:=STICKLINE(中波>HZ4,中波,HZ4,3,1),COLORGREEN;买入:=IF(CROSS(短波,HZ2),C,0);DRAWTEXT(买入>0,LOW*0.92,'买入'),COLORYELLOW;{MA60: MA(CLOSE, 60),COLORFF00FF,POINTDOT,LINETHICK1;}VARE:=MA(100*(CLOSE-LLV(CLOSE,34))/(HHV(HIGH,34)-LLV(LOW,34)),5)-20;VARF:=100-3*SMA((CLOSE-LLV(LOW,75))/(HHV(HIGH,75)-LLV(LOW,75))*100,20,1)+2*SMA(SMA(( CLOSE-LLV(LOW,75))/(HHV(HIGH,75)-LLV(LOW,75))*100,20,1),15,1);VAR10:=100-3*SMA((OPEN-LLV(LOW,75))/(HHV(HIGH,75)-LLV(LOW,75))*100,20,1)+2*SMA(SMA(( OPEN-LLV(LOW,75))/(HHV(HIGH,75)-LLV(LOW,75))*100,20,1),15,1);VAR11:=VARF<REF(VAR10,1) AND VOL>REF(VOL,1) AND CLOSE>REF(CLOSE,1);DRAWTEXT(VAR11 AND COUNT(VAR11,30)=1,LOW*0.83,'大资金'),LINETHICK1,COLORWHITE; VAR12:=(HIGH+LOW+CLOSE)/3;VAR13:=(VAR12-MA(VAR12,14))/(0.015*AVEDEV(VAR12,14));VAR14:=(VAR12-MA(VAR12,70))/(0.015*AVEDEV(VAR12,70));VAR15:=IF(VAR13>=150 AND VAR13<200 AND VAR14>=150 AND VAR14<200,10,0);VAR16:=IF(VAR13<=-150 AND VAR13>-200 AND VAR14<=-150 AND VAR14>-200,-10,VAR15); VAR17:=(CLOSE-MA(CLOSE,13))/MA(CLOSE,13)*100;VAR18:=100-ABS(VAR17);VAR19:=IF(VAR18<90,VAR18,100);VAR1A:=IF(VARE>0,VARE,0);VAR1B:=IF(VAR14>=200 AND VAR13>=150,15,IF(VAR14<=-200 AND VAR13<=-150,-15,VAR16))+60;VAR1C:=VAR1A>48 AND VAR1B>60 AND VAR19<100;DRAWTEXT(VAR1C AND COUNT(VAR1C,30)=1,LOW*0.94,'大笔成交') COLORWHITE;X:=BARSLAST(REF(CROSS(C,MA(C,120)),1)) AND CROSS(MA(C,20),MA(C,120));DRAWTEXT(X,MA(C,120)-0.07,'牛股'),COLORRED;VAR111:=MA(LOW,1);VAR222:=MA(HIGH,2);VAR333:=MA(CLOSE,2);VAR777:=REF(VAR333,1);VAR888:=SMA(MAX(VAR333-VAR777,0),13,1)/SMA(ABS(VAR333-VAR777),13,1)*100;VAR444:=(VAR333-LLV(VAR111,9))/(HHV(VAR222,9)-LLV(VAR111,9))*100;VAR555:=SMA(VAR444,3,1);【阳】:=SMA(VAR555,3,1);Y1:=SMA(【阳】,3,1);VAR666:=(HHV(VAR222,9)-VAR333)/(HHV(VAR222,9)-LLV(VAR111,9))*100;【阴】:=SMA(VAR666,3,1);Y2:=SMA(【阴】,3,1);VARBBB:=MA(INDEXC,3)*100/MA(INDEXC,10)-100;VAREEE:=IF(VARBBB>10,10,VARBBB);VARFFF:=IF(VAREEE<-10,-10,VAREEE);VAR122:=REF(VARBBB,1);VAR133:=100*(VAR333-REF(VAR333,1))/REF(VAR333,1);VAR144:=INDEXC;VAR155:=REF(VAR144,1);VAR166:=100*(VAR144-VAR155)/VAR144;VAR177:=MA(VAR133,3);VAR188:=MA(VAR166,3);VAR199:=(3*CLOSE+VAR111+OPEN+HIGH)/6;VAR1AA:=(20*VAR199+19*REF(VAR199,1)+18*REF(VAR199,2)+17*REF(VAR199,3)+16*REF(VAR1 99,4)+15*REF(VAR199,5)+14*REF(VAR199,6)+13*REF(VAR199,7)+12*REF(VAR199,8)+11*REF(VA R199,9)+10*REF(VAR199,10)+9*REF(VAR199,11)+8*REF(VAR199,12)+7*REF(VAR199,13)+6*REF(V AR199,14)+5*REF(VAR199,15)+4*REF(VAR199,16)+3*REF(VAR199,17)+2*REF(VAR199,18)+REF(V AR199,20))/210;VAR1BB:=MA(VAR1AA,12);VAR1CC:=EMA(VAR1AA,5);VAR1DD:=ABS(VAR1AA-VAR1BB);VAR1EE:=REF(VAR333,1)*0.015;VAR1FF:=REF(INDEXC,1);VAR244:=ZIG(3,10)>REF(ZIG(3,10),1) AND REF(ZIG(3,10),1)<REF(ZIG(3,10),2);VAR255:=ZIG(3,10)<REF(ZIG(3,10),1) AND REF(ZIG(3,10),1)>REF(ZIG(3,10),2);VAR266:=MA(CLOSE,26);VAR277:=VAR266+2*STD(VAR333,26);VAR288:=VAR266-2*STD(VAR333,26);VAR2BB:=IF(VAR244 AND VAR111<VAR288,1,0);VAR2CC:=IF(VAR255*VAR111 AND VAR222>VAR277,2,VAR2BB);VAR2DD:=IF(VAR2CC=1,80,45);VAR2EE:=IF(VAR2CC=2,0,VAR2DD);大户1:=EMA(100*(CLOSE-LLV (LOW,34))/(HHV(HIGH,34)-LLV(LOW,34)),3);大户:=MA(大户1,2);散户1:=(WINNER(C*1.1)-WINNER(C*0.9))*100;散户:=MA(散户1,12);VAR1:=1;主力1:=(100-VAR1)*VAR1;主力:=MA(主力1,2);游资1:=MA(WINNER(CLOSE*0.95)*100,3)*VAR1*1.1;游资:=MA(游资1,2);主升浪:= (CROSS(大户,主力) AND (MA(C,20)-LLV(MA(C,20),30))/ LLV(MA(C,20),30)*100<10 AND 主力>50 AND (主力-REF(主力,50)) >20 AND (C-MA(C,20))/MA(C,20)*100 <12 AND散户<70) OR (CROSS(大户,主力) AND (MA(C,20)-LLV(MA(C,20),30))/ LLV(MA(C,20),30)*100<10 AND 主力>70 AND (主力-REF(主力,50)) >30 AND (C-MA(C,20))/MA(C,20)*100 <20 AND散户<70 ) OR (CROSS(游资,主力) AND 大户>80 AND 散户>80 AND (REF(主力,100)-主力)/主力*100 >80) ;DRAWTEXT(主升浪, LOW*0.95,'主升浪'),COLORYELLOW;大黑马飚升:= CROSS(游资,散户) AND REF(主力,5)>75 AND ((游资-REF(游资,3)) /3>8OR (大户-REF(大户,3)) /3>7)AND (HHV(HIGH,100)-C)/C*100<40;DRAWTEXT(大黑马飚升, LOW*0.94,'黑马飚升'),COLORYELLOW;黑马飚升:= (CROSS(大户,散户) AND REF(主力,5)>75 AND ((游资-REF(游资,3)) /3>6OR (大户-REF(大户,3)) /3>6)AND (HHV(HIGH,50)-C)/C*100<40) OR ( CROSS(游资,散户)AND REF(主力,5)>50 AND ((游资-REF(游资,3)) /3>6 OR(大户-REF(大户,3)) /3>6)AND (HHV(HIGH,50)-C)/C*100<40);长线大黑马:= CROSS(游资,大户) AND 游资>90 AND C>REF(C,20) AND 主力<30; DRAWTEXT(长线大黑马, LOW*0.90,'长线黑马'),COLORRED;MA5:MA(CLOSE,5),POINTDOT,COLOR000000,LINETHICK1;牛熊线:EMA(C,250),CIRCLEDOT,COLOR999999;界:MA(CLOSE,21);风险线:= MA(CLOSE,13),LINETHICK2,COLORGREEN;止损线:= MA(CLOSE,27),LINETHICK0,COLOREE00EE;VARA:=(100 - ((90 * (HHV(HIGH,21) - CLOSE)) / (HHV(HIGH,21) - LLV(LOW,21))));VAR2:=(100 - ((90 * (HHV(HIGH,21) - CLOSE)) / (HHV(HIGH,21) - LLV(LOW,21))));VAR3:=(100 - MA(((100 * (HHV(HIGH,6) - CLOSE)) / (HHV(HIGH,6) - LLV(LOW,6))),34)); DRAWTEXT(CROSS(VAR2,MA(VAR3,6)),(LOW * 0.988),'B'),COLORYELLOW,LINETHICK3; DRAWTEXT(CROSS(MA(VAR3,6),VARA),(HIGH * 1.06),'S'),COLOREE00EE,LINETHICK2; DRAWTEXT(CROSS(MA5,界),(LOW * 0.96),'底背离');DRAWTEXT(CROSS(C,止损线)AND 止损线>风险线,(LOW * 0.98),'主升浪'),COLORYELLOW,LINETHICK3;MACD背离指标公式DIFF: EMA(CLOSE,12) - EMA(CLOSE,26),COLORWHITE;DEA: EMA(DIFF,9),COLORYELLOW;MACD: 2*(DIFF-DEA), COLORSTICK;STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,0,0),COLORYELLOW;STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,0,0),COLORGREEN;低位金叉:=CROSS(DIFF,DEA) AND DIFF<-0.1;STICKLINE(低位金叉,0,0.08,6,0),COLORYELLOW;DRAWTEXT(低位金叉,0.16,' 低金叉'),COLORWHITE;JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));二次金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1;STICKLINE(二次金叉,0,0.06,6,0),COLORFF00FF;DRAWICON(二次金叉,DEA*0.9,1) ;DRAWTEXT(二次金叉,0.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.03,6,0),COLOR00FF00;底背:DRAWLINE(A1=0,DEA,底背离,DEA,0),COLORRED,LINETHICK4;DRAWTEXT(底背离,0.12,' 底背离'),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,LINETHICK4;DRAWTEXT(低位金叉AND 二次金叉AND 底背离,0.25,'三全项'),COLOR0000FF,LINETHICK2; {抄底逃顶公式极准确的}。
macd背离指标源码
DIFF:EMA(CLOSE,12) - EMA(CLOSE,26);DEA:EMA(DIFF,9);MACD:2*(DIFF-DEA),COLORSTICK;A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));B1:=REF(C,A1+1)>C AND REF(DIFF,A1+1)<DIFF AND CROSS(DIFF,DEA);A2:=BARSLAST(REF(CROSS("KDJ.K"(9,3,3),"KDJ.D"(9,3,3)),1));B2:=REF(C,A2+1)>C AND REF("KDJ.K"(9,3,3),A2+1)<"KDJ.K"(9,3,3) AND CROSS("KDJ.K"(9,3,3),"KDJ.D"(9,3,3));A3:=BARSLAST(REF(CROSS("RSI.RSI1"(6,12,24),"RSI.RSI2"(6,12,24)),1));B3:=REF(C,A3+1)>C AND REF("RSI.RSI1"(6,12,24),A3+1)<"RSI.RSI1"(6,12,24) AND CROSS("RSI.RSI1"(6,12,24),"RSI.RSI2"(6,12,24));C1:=BARSLAST(REF(CROSS(DEA,DIFF),1));D1:=REF(C,C1+1)<C AND REF(DIFF,C1+1)>DIFF AND CROSS(DEA,DIFF);C2:=BARSLAST(REF(CROSS("KDJ.D"(9,3,3),"KDJ.K"(9,3,3)),1));D2:=REF(C,C2+1)<C AND REF("KDJ.K"(9,3,3),C2+1)>"KDJ.K"(9,3,3) AND CROSS("KDJ.D"(9,3,3),"KDJ.K"(9,3,3));C3:=BARSLAST(REF(CROSS("RSI.RSI2"(6,12,24),"RSI.RSI1"(6,12,24)),1));D3:=REF(C,C3+1)<C AND REF("RSI.RSI1"(6,12,24),C3+1)>"RSI.RSI1"(6,12,24) AND CROSS("RSI.RSI2"(6,12,24),"RSI.RSI1"(6,12,24));MACD底背:IF(B1>0,-0.1,0),COLORRED,POINTDOT;KDJ底背:IF(B2>0,-0.1,0),COLORFF00FF,POINTDOT;RSI底背:IF(B3>0,-0.1,0),COLORYELLOW,POINTDOT;MACD顶背:IF(D1>0,0.1,0),COLOR00FF00,POINTDOT;KDJ顶背:IF(D2>0,0.1,0),COLORFFCC66,POINTDOT;RSI顶背:IF(D3>0,0.1,0),COLORWHITE,POINTDOT;STICKLINE(B1>0,-0.1,0,2,0),COLORRED;STICKLINE(B2>0,-0.1,0,2,0),COLORFF00FF;STICKLINE(B3>0,-0.1,0,2,0),COLORYELLOW;STICKLINE(D1>0,0.1,0,2,0),COLOR00FF00;STICKLINE(D2>0,0.1,0,2,0),COLORFFCC66;STICKLINE(D3>0,0.1,0,2,0),COLORWHITE;。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
MACD背离指标编写公式
DIFF:EMA(CLOSE,12)-EMA(CLOSE,27); DEA:EMA(DIFF,9); MACD:=2*(DIFF-DEA); STICKLINE(MACD>=0,MACD,0,2,1),COLORF00FF0;
STICKLINE(MACD<0,MACD,0,2,1),COLORWHITE;
STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR00AAFF; STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR00BBFF; STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR00CCFF; STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR00DDFF; STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR00EEFF; STICKLINE(MACD<REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR00FFFF; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR0000AA; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR0011BB; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR0022CC; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR0033DD; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR0044EE; STICKLINE(MACD>=REF(MACD,1)AND MACD>0,0,MACD,2,0 ),COLOR0055FF; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORAA00BB; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORBB11BB; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORCC22BB; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORDD33BB; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLOREE44BB; STICKLINE(MACD>REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORFF55BB; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORFFAA00; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORFFBB11; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORFFCC22; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORFFDD33; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORFFEE44; STICKLINE(MACD<=REF(MACD,1)AND MACD<0,0,MACD,2,0 ),COLORFFFF55; IF(DIFF<0,DIFF,0),COLORRED,LINETHICK1;
IF(DIFF<0,0,DIFF),COLORYELLOW,LINETHICK1;
IF(DIFF<DEA,DIFF,DEA),COLOR00FF00,LINETHICK1;
IF(DIFF>DEA,DEA,DEA),COLORWHITE,LINETHICK1; 低位金叉:=CROSS(DIFF,DEA) AND DIFF<-0.1;
STICKLINE(低位金叉,0,-0.18,2,0),COLORYELLOW; DRAWTEXT(低位金叉,-0.1,' 低位金叉'),COLORYELLOW; JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0)); 二次金叉:=CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1; STICKLINE(二次金叉,0,-0.18,2,0),COLORFF00FF; DRAWICON(二次金叉,DEA*1.04,13) DRAWTEXT(二次金叉,-0.1,' 二次金叉'),COLORFF00FF; 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.13,2,0),COLOR00FF00; DRAWLINE(A1=0,DEA,底背离,DEA,0),COLORRED,LINETHICK2; DRAWTEXT(底背离,0.1,' 底背离'),COLOR00FF00; 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;。