通达信指标公式源码好厉害的MACD背离(通达信副图指标)
MACD顶底背离通达信指标公式源码
MACD顶底背离通达信指标公式源码/*头文件引用*/#include "stdafx.h"#include "SetIndexData.h"/*背离判断函数*/BOOL BackwardJudge(int n, float *dd, float *top, float *bottom)int i, t_pos = 0;float maxval = 0, minval = 0;for(i=0;i<n;i++)if(maxval < dd[i])maxval = dd[i];t_pos = i;}}maxval = dd[t_pos];minval = dd[t_pos];for(i=t_pos;i>=0;i--)if(maxval < dd[i])maxval = dd[i];if(minval > dd[i])minval = dd[i];}*top = maxval;*bottom = minval;if(maxval == dd[0])return TRUE;else if(minval == dd[0])return FALSE;elsereturn FALSE;/*MACD顶底背离判断函数*/Export int MACDBackward(int n)int i;float *DIFF, *DEA, *MACD, *dd;float top = 0, bottom = 0;BOOL bType = FALSE;SetEmptyBarCount(FALSE); /*不跳过空记录*/DIFF = GetDiff(;DEA = GetDea(;MACD = GetMacd(;malloc(dd, sizeof(float)*n);bType = BackwardJudge(n, DEA, &top, &bottom);if(bType)for(i=0;i<n;i++)dd[i] = DIFF[i];bType = BackwardJudge(n, dd, &top, &bottom);if(bType)return 1; /*底背离*/elsereturn 2; /*顶背离*/}elsereturn 0; /*无背离*/上述代码是通达信公式语言的源码。
通达信综合背离副图指标公式
通达信综合背离副图指标公式安装后如下图,友情提示(指标只是辅助,不作建议)所有程序均为免费分享。
不会安装点击安装指南步骤操作。
{MACD背离}DIFF:EMA(CLOSE,12) - EMA(CLOSE,26);DEA:EMA(DIFF,9);MACD:2*(DIFF-DEA), COLORSTICK,DRAWABOVE;MACD金叉:=BARSLAST(REF(CROSS(DIFF,DEA),1));MACD死叉:=BARSLAST(REF(CROSS(DEA,DIFF),1));MACD上次金叉:=SUMBARS(REF(CROSS(DIFF,DEA),1),2);MACD上次死叉:=SUMBARS(REF(CROSS(DEA,DIFF),1),2);{MACD底背离}MACD次低点:=LLV(DIFF,MACD金叉);MACD最低点:=LLV(DIFF,MACD上次死叉);MACD底背离:=REF(CLOSE,MACD金叉+1)>CLOSE AND MACD次低点>MACD最低点 AND CROSS(DIFF,DEA);DRAWLINE(MACD金叉=0,DEA,MACD底背离,DEA,0),COLORRED,LINETHICK2;{MACD顶背离}MACD次高点:=HHV(DIFF,MACD金叉);MACD最高点:=HHV(DIFF,MACD上次金叉);MACD顶背离:=REF(CLOSE,MACD死叉+1)<CLOSE AND MACD次高点<MACD最高点 AND CROSS(DEA,DIFF);DRAWLINE(MACD死叉=0,DEA,MACD顶背离,DEA,0),COLORGREEN,LINETHICK2;红面积:SUM(MACD,BARSLAST(MACD<0))*(MACD>0),COLOR0000FF, NODRAW;绿面积:SUM(MACD,BARSLAST(MACD>0))*(MACD<0),COLORFFFF00, NODRAW;AA:=ROUND(REF(绿面积,1)*100);BB:=ROUND(REF(红面积,1)*100);DRAWNUMBER(CROSS(0,MACD),0.04,ABS(BB)),COLORMAG ENTA;DRAWNUMBER(CROSS(MACD,0),-0.01,ABS(AA)),COLORGREEN;{CCI}TYP:=(HIGH+LOW+CLOSE)/3;CCI:=(TYP-MA(TYP,14))/(0.015*AVEDEV(TYP,14));{BOLL}BOLL:=MA(CLOSE,20);UB:=BOLL+2*STD(CLOSE,20);LB:=BOLL-2*STD(CLOSE,20);{KDJ}RSV:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;K:=SMA(RSV,3,1);D:=SMA(K,3,1);J:=3*K-2*D;PP:=CCI<-160 AND CLOSE<LB AND J<20;QQ:=CCI>160 AND J>100;{KDJ中J值在0-90间为黄色,小于0为绿色,大于90为红色} {显示J值和CCI值}{CCI值小于160且收盘价在BOLL下轨一下,J值小于20为红色箭头,CCI大于160且J值大于100为绿色箭头}DRAWICON(QQ,0,2);DRAWICON(PP,0,1);KDJ金叉:=BARSLAST(REF(CROSS(J,D),1));KDJ死叉:=BARSLAST(REF(CROSS(D,J),1));KDJ上次金叉:=SUMBARS(REF(CROSS(J,D),1),2);KDJ上次死叉:=SUMBARS(REF(CROSS(D,J),1),2);{KDJ底背离}AAA1:=BARSLAST(REF(CROSS(J,D),1));KDJ次低点:=LLV(J,AAA1);KDJ最低点:=LLV(J,KDJ上次死叉);KDJ底背离:=REF(CLOSE,AAA1+1)>CLOSE AND KDJ次低点>KDJ最低点 AND CROSS(J,D);DRAWTEXT(KDJ底背离,MACD,'KDJ底'),COLORRED;STICKLINE(KDJ底背离,MACD,0,2,0),COLORRED;{KDJ顶背离}BBB1:=BARSLAST(REF(CROSS(D,J),1));KDJ次高点:=HHV(J,AAA1);KDJ最高点:=HHV(J,KDJ上次金叉);KDJ顶背离:=REF(CLOSE,BBB1+1)<CLOSE AND KDJ次高点<KDJ最高点 AND CROSS(D,J);DRAWTEXT(KDJ顶背离,MACD,'KDJ顶'),COLORGREEN;STICKLINE(KDJ顶背离,MACD,0,2,0),COLORGREEN;{九转}A1:=C>=REF(C,4);A2:=C<REF(C,4);A3:=C<REF(C,4) AND REF(A1,1);T:=BARSLAST(A3),NODRAW;M0:=(T=0 AND REFX(T=1 AND NOT(A2),1)) OR (REFX(T=2 AND NOT(A2),2)) OR (REFX(T=3 AND NOT(A2),3)) OR (REFX(T=4 AND NOT(A2),4)) OR (REFX(T=5 AND NOT(A2),5)) OR (REFX(T=6 AND NOT(A2),6)) OR (REFX(T=7 AND NOT(A2),7)) OR (REFX(T=8 AND NOT(A2),8));M1:=T=1 AND REFX(T=2 AND NOT(A2),1) OR (REFX(T=3AND NOT(A2),2)) OR (REFX(T=4 AND NOT(A2),3)) OR (REFX(T=5 AND NOT(A2),4)) OR (REFX(T=6 AND NOT(A2),5)) OR (REFX(T=7 AND NOT(A2),6)) OR (REFX(T=8 AND NOT(A2),7));M2:=T=2 AND REFX(T=3 AND NOT(A2),1) OR (REFX(T=4 AND NOT(A2),2)) OR (REFX(T=5 AND NOT(A2),3)) OR (REFX(T=6 AND NOT(A2),4)) OR (REFX(T=7 AND NOT(A2),5)) OR (REFX(T=8 AND NOT(A2),6));M3:=T=3 AND REFX(T=4 AND NOT(A2),1)OR (REFX(T=5 AND NOT(A2),2)) OR (REFX(T=6 AND NOT(A2),3)) OR (REFX(T=7 AND NOT(A2),4)) OR (REFX(T=8 AND NOT(A2),5));M4:=T=4 AND REFX(T=5 AND NOT(A2),1) OR (REFX(T=6 AND NOT(A2),2)) OR (REFX(T=7 AND NOT(A2),3)) OR (REFX(T=8 AND NOT(A2),4));M5:=T=5 AND REFX(T=6 AND NOT(A2),1) OR (REFX(T=7 AND NOT(A2),2)) OR (REFX(T=8 AND NOT(A2),3));M6:=T=6 AND REFX(T=7 AND NOT(A2),1) OR (REFX(T=8 AND NOT(A2),2));M7:=T=7 AND REFX(T=8 AND NOT(A2),1);N0:=T=1 AND REF(T=0 AND A3,1) AND A2;N1:=T=2 AND REF(N0,1) AND A2;N2:=T=3 AND REF(N1,1) AND A2;N3:=T=4 AND REF(N2,1) AND A2;N4:=T=5 AND REF(N3,1) AND A2;N5:=T=6 AND REF(N4,1) AND A2;N6:=T=7 AND REF(N5,1) AND A2;N7:=T=8 AND REF(N6,1) AND A2;WZD:=DEA;WZG:=DEA;DRAWTEXT(N6 AND NOT(M7),WZD,'8'),COLORGREEN;DRAWTEXT(N7,WZG,'9'),COLORMAGENTA;B1:=C<=REF(C,4);B2:=C>REF(C,4);B3:=C>REF(C,4) AND REF(B1,1);T1:=BARSLAST(B3),NODRAW;M8:=(T1=0 AND REFX(T1=1 AND NOT(B2),1)) OR (REFX(T1=2 AND NOT(B2),2)) OR (REFX(T1=3 AND NOT(B2),3)) OR (REFX(T1=4 AND NOT(B2),4)) OR (REFX(T1=5 AND NOT(B2),5)) OR (REFX(T1=6 AND NOT(B2),6)) OR (REFX(T1=7 AND NOT(B2),7)) OR (REFX(T1=8 AND NOT(B2),8));M9:=T1=1 AND REFX(T1=2 AND NOT(B2),1) OR (REFX(T1=3 AND NOT(B2),2)) OR (REFX(T1=4 AND NOT(B2),3)) OR (REFX(T1=5 AND NOT(B2),4)) OR (REFX(T1=6 AND NOT(B2),5)) OR (REFX(T1=7 AND NOT(B2),6)) OR (REFX(T1=8 AND NOT(B2),7));M10:=T1=2 AND REFX(T1=3 AND NOT(B2),1) OR (REFX(T1=4 AND NOT(B2),2)) OR (REFX(T1=5 AND NOT(B2),3)) OR (REFX(T1=6 AND NOT(B2),4)) OR (REFX(T1=7 AND NOT(B2),5)) OR (REFX(T1=8 AND NOT(B2),6));M11:=T1=3 AND REFX(T1=4 AND NOT(B2),1)OR (REFX(T1=5 AND NOT(B2),2)) OR (REFX(T1=6 AND NOT(B2),3)) OR (REFX(T1=7 AND NOT(B2),4)) OR (REFX(T1=8 AND NOT(B2),5));M12:=T1=4 AND REFX(T1=5 AND NOT(B2),1) OR (REFX(T1=6 AND NOT(B2),2)) OR (REFX(T1=7 AND NOT(B2),3)) OR (REFX(T1=8 AND NOT(B2),4));M13:=T1=5 AND REFX(T1=6 AND NOT(B2),1) OR (REFX(T1=7 AND NOT(B2),2)) OR (REFX(T1=8 AND NOT(B2),3));M14:=T1=6 AND REFX(T1=7 AND NOT(B2),1) OR (REFX(T1=8 AND NOT(B2),2));M15:=T1=7 AND REFX(T1=8 AND NOT(B2),1);N8:=T1=1 AND REF(T1=0 AND B3,1) AND B2;N9:=T1=2 AND REF(N8,1) AND B2;N10:=T1=3 AND REF(N9,1) AND B2;N11:=T1=4 AND REF(N10,1) AND B2;N12:=T1=5 AND REF(N11,1) AND B2;N13:=T1=6 AND REF(N12,1) AND B2;N14:=T1=7 AND REF(N13,1) AND B2;N15:=T1=8 AND REF(N14,1) AND B2;DRAWTEXT(N14 AND NOT(M15),WZG,'8'),COLOR9900CC; DRAWTEXT(N15 ,WZD,'9'),COLORGREEN;指标先生有话说:用完记得多多分享文章哦!感谢您的支持!需要把上面公式改写成选股公式大声呼唤我!。
MACD背离自动画线通达信指标公式源码
DIF:MACD.DIF(12,26,9),LINETHICK2;DEA:MACD.DEA(12,26,9);MACD:(DIF-DEA)*2,COLORSTICK;DRAWICON(REF(DIF,1)>REF(DIF,2) AND DIF<REF(DIF,1) AND DIF>0 AND DIF>DEA,DIF*1.1,2),COLORGREEN;DRAWICON(CROSS(DEA,DIF) AND DIF>0,DIF,37),COLORGREEN;DRAWICON(REF(DIF,1)<REF(DIF,2) AND DIF>REF(DIF,1) AND DIF<0 AND DIF<DEA,DIF*1.1,1),COLORRED;DRAWICON(CROSS(DIF,DEA) AND DIF<0,DIF,36),COLORRED;XA_1:=MACD<0 AND MACD>REF(MACD,1) AND REF(MACD,1)<REF(MACD,2) AND REF(MACD,2)<REF(MACD,3) AND REF(MACD,3)<REF(MACD,4);STICKLINE(XA_1,0,MACD,0.3,0),COLORRED;XA_2:=MACD>0 AND MACD<REF(MACD,1) AND REF(MACD,1)>REF(MACD,2) AND REF(MACD,2)>REF(MACD,3) AND REF(MACD,3)>REF(MACD,4);STICKLINE(XA_2,0,MACD,0.3,0),COLORGREEN;XA_3:=100-100*(HHV(HIGH,34)-CLOSE)/(HHV(HIGH,34)-LLV(LOW,34))-50;XA_4:=EMA(XA_3,3);NOTEXTLU:IF(XA_4>24.99,DIF,DRAWNULL),COLORRED,LINETHICK2;NOTEXTLU2:IF(XA_4<(-40.009998),DIF,DRAWNULL),COLORGREEN,LINETHICK2; NOTEXT0:0,DOTLINE,COLORLIGRAY;XA_5:=IF(PERIOD=0,0.7,IF(PERIOD=1,1.2,IF(PERIOD=2,2,IF(PERIOD=3,2.5,IF(PERIOD =4,3,IF(PERIOD=5,5.5,IF(PERIOD=6,6,IF(PERIOD=7,7,IF(PERIOD=8,3.5,4)))))))));XA_6:=BARSLAST(CROSS(MACD,0));XA_7:=REF(XA_6,1)>0 AND XA_6=0;XA_8:=BARSLAST(XA_7);XA_9:=REF(XA_6,XA_8+1);XA_10:=HHVBARS(MACD,XA_8+XA_9);XA_11:=IF(XA_10>XA_8,REF(MACD,XA_10),0);XA_12:=IF(XA_10>XA_8,REF(HIGH,XA_10),0);XA_13:=IF(REF(HIGH,1)=HHV(HIGH,XA_8+XA_9),REF(HIGH,1),0);XA_14:=(XA_13-XA_12)/XA_12*100;XA_15:=COUNT(CROSS(0,MACD),XA_8+XA_9);XA_16:=MACD>0 AND MACD<XA_11 AND HIGH=HHV(HIGH,XA_8+XA_9) AND XA_11>0 AND XA_15=1;XA_17:=REF(XA_16,1) AND HIGH<REF(HIGH,1) AND MACD>0 AND XA_11>0;XA_18:=LLVBARS(MACD,XA_8+XA_9);XA_19:=IF(XA_18>XA_8,REF(MACD,XA_18),0);XA_20:=IF(XA_18>XA_8,REF(LOW,XA_18),0);XA_21:=IF(REF(LOW,1)=LLV(LOW,XA_8+XA_9),REF(LOW,1),0);XA_22:=(XA_20-XA_21)/XA_20*100;XA_23:=COUNT(CROSS(MACD,0),XA_8+XA_9);XA_24:=MACD<0 AND MACD>XA_19 AND LOW=LLV(LOW,XA_8+XA_9) AND XA_19<0 AND COUNT(CROSS(MACD,0),XA_8+XA_9)<=3;XA_25:=REF(XA_24,1) AND LOW>REF(LOW,1) AND MACD<0 AND XA_19<0;前高:IF(XA_17,XA_12,DRAWNULL),NODRAW,COLOR7FFF00;现高:IF(XA_17,XA_13,DRAWNULL),NODRAW,COLORGREEN;幅度_顶:IF(XA_17,XA_14,DRAWNULL),NODRAW,COLORYELLOW;原低:IF(XA_25,XA_20,DRAWNULL),NODRAW,COLORLIMAGENTA;现低:IF(XA_25,XA_21,DRAWNULL),NODRAW,COLORRED;幅度_底:IF(XA_25,XA_22,0),NODRAW,COLORYELLOW;DRAWICON(XA_25,MACD,26);DRAWICON(XA_17,MACD,27);XA_26:=BACKSET(XA_17,XA_10+1);XA_27:=BACKSET(XA_25,XA_18+1);NOTEXTMACDL:DRAWLINE(REF(XA_27,1)=0 AND XA_27=1 AND MACD<0,MACD,XA_25,MACD,0),COLORRED;NOTEXTMACDH:DRAWLINE(REF(XA_26,1)=0 AND XA_26=1 AND MACD>0,MACD,XA_17,MACD,0),COLORGREEN;涨家数:INDEXADV,NODRAW,COLORRED;跌家数:INDEXDEC,NODRAW,COLORGREEN;正量能:涨家数/(涨家数+跌家数)*100,NODRAW,COLORMAGENTA;负量能:跌家数/(涨家数+跌家数)*100,NODRAW,COLORYELLOW;。
自动画MACD背离线通达信指标公式源码
自动画MACD背离线通达信指标公式源码以下是通达信软件中计算MACD背离指标的源码:```/*功能:计算MACD背离线指标公式:当股价形成新高而MACD指标不形成新高时,出现向下背离当股价形成新低而MACD指标不形成新低时,出现向上背离参数:无返回值:无*/indicator fn_DEVIATION_MACDMA1:=EMA(CLOSE,12);MA2:=EMA(CLOSE,26);DIFF:=MA1-MA2;DEA:=EMA(DIFF,9);MACD:=2*(DIFF-DEA);PeakArr:=[];TroughArr:=[];PeakCount:=0;TroughCount:=0;//寻找股价的峰值和谷底Loop:=BARSSINCE(HIGHESTBARS(HIGH,9)) + 1;FOR i FROM Loop TO BARCOUNT-1BEGINIFHIGH[i]>REF(HIGH,1)[i]ANDHIGH[i]>HIGH[i+1]THENBEGINPeakCount := PeakCount + 1;PeakArr[PeakCount] := i;END;IFLOW[i]<REF(LOW,1)[i]ANDLOW[i]<LOW[i+1]THENBEGINTroughCount := TroughCount + 1;TroughArr[TroughCount] := i;END;END;//判断是否存在背离BEARTrend := IF(REF(MACD,1) > REF(MACD,2),1,-1); // 1表示下跌趋势,-1表示上涨趋势PeakPos := 0;TroughPos := 0;Signal := "";FOR i FROM 1 TO MIN(PeakCount, TroughCount) BEGINIF BEARTrend = 1 THENBEGINIF HIGH[PeakArr[i]] > HIGH[PeakArr[i-1]] THEN BEGINIF LOW[TroughArr[i]] > LOW[TroughArr[i-1]] THEN BEGINPeakPos := PeakArr[i];TroughPos := TroughArr[i];Signal := "向下背离";BREAK;END;END;END;ELSE IF BEARTrend = -1 THENBEGINIF HIGH[PeakArr[i]] < HIGH[PeakArr[i-1]] THENBEGINIF LOW[TroughArr[i]] < LOW[TroughArr[i-1]] THENBEGINPeakPos := PeakArr[i];TroughPos := TroughArr[i];Signal := "向上背离";BREAK;END;END;END;END;//输出背离信号IF PeakPos > 0 AND TroughPos > 0 THENBEGINDRAWICON(PeakPos, HIGH[PeakPos], CONCAT(Signal, "顶背离"),IC_TRIANGLE, 0, RED);DRAWICON(TroughPos, LOW[TroughPos], CONCAT(Signal, "底背离"), IC_TRIANGLE, 1, GREEN);END;//返回背离信号位置RETURN PeakPos, TroughPos;```以上代码使用通达信魔法公式语言编写,通过计算MACD指标的DIF、DEA、MACD三个值,并寻找股价的峰值和谷底来判断是否存在背离信号。
MACD背离自动画线通达信指标公式源码
MACD背离自动画线通达信指标公式源码MACD(Moving Average Convergence Divergence)是一种常用的股票技术指标,用于分析股票的趋势和交易信号。
MACD背离是一种常见的技术分析方法,用于判断趋势的反转点,即价格走势与MACD指标走势不一致的情况。
下面是使用通达信编写MACD背离自动画线指标的源码。
```c/*MACD背离自动画线指标*功能:自动识别MACD背离点并在图表中标注出来*/#include "stdafx.h"#include "stdio.h"#include "string.h"#include "windows.h"//确定最低点、最高点时使用的价格周期数#define MIN_PRICE_DURATION 9#define MAX_PRICE_DURATION 10/**输入参数:*MACD:一个包含MACD数据的数组* price:一个包含价格数据的数组*返回值:*0:没有背离*1:向上背离*-1:向下背离*/int CheckDivergence(float *MACD, float *price) int i, j, k;int start, end;int low_index, high_index;float min_price, max_price;int MACD_bottom, MACD_top;int price_bottom, price_top;float MACD_bottom_value, MACD_top_value;float price_bottom_value, price_top_value;/**阶段1:寻找MACD底背离*/start = MAX_PRICE_DURATION + 1;end = start + MIN_PRICE_DURATION;low_index = -1;high_index = -1;min_price = price[start];max_price = price[start];for (i = start; i < end; i++)//查找最低点if (price[i] < min_price)low_index = i;min_price = price[i];}//查找最高点if (price[i] > max_price)high_index = i;max_price = price[i];}}//无法找到底背离点if (low_index == -1 , high_index == -1)}MACD_bottom = 0;price_bottom = 0;//寻找MACD底背离for (i = start; i < end; i++)if (i == low_index)//找到最低点对应的MACD数值MACD_bottom = i;MACD_bottom_value = MACD[i];}if (i == high_index)//找到最高点对应的MACD数值price_bottom = i;price_bottom_value = price[i];}}//如果最低点出现在最高点之后,则没有底背离if (MACD_bottom > price_bottom)}/**阶段2:寻找MACD顶背离*/start = MAX_PRICE_DURATION + 1; end = start + MIN_PRICE_DURATION; low_index = -1;high_index = -1;min_price = price[start];max_price = price[start];for (i = start; i < end; i++)//查找最低点if (price[i] < min_price)low_index = i;min_price = price[i];}//查找最高点if (price[i] > max_price)max_price = price[i];}}//无法找到顶背离点if (low_index == -1 , high_index == -1) return 0;}MACD_top = 0;price_top = 0;//寻找MACD顶背离for (i = start; i < end; i++)if (i == low_index)//找到最低点对应的MACD数值MACD_top = i;MACD_top_value = MACD[i];}if (i == high_index)//找到最高点对应的MACD数值price_top_value = price[i];}}//如果最高点出现在最低点之后,则没有顶背离if (MACD_top > price_top)return 0;}//判断背离类型if (price_bottom_value < price_top_value && MACD_bottom_value > MACD_top_value)return 1; // 向上背离}if (price_bottom_value > price_top_value && MACD_bottom_value < MACD_top_value)return -1; // 向下背离}return 0;int mainfloat MACD[100] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 4.0, 3.0, 2.0, 1.0};float price[100] = {1.0, 2.0, 3.0, 4.0, 3.0, 2.0, 1.0, 0.0, -1.0, -2.0};int result = CheckDivergence(MACD, price);printf("Result: %d\n", result);return 0;```该源码实现了一个简单的MACD背离自动画线指标。
通达信软件指标公式源码常用的MACD三次背离副图指标通达信源码.docx
常用的MACD三次背离副图指标通达信源码自己常用的MACD,严重底背离红柱子和底背离绿柱子,三次背离底部划线等, 主要看图比较清晰!DIFIF1:(EMA(CLOSE,12) - EMA(CLOSE,26))*100/EMA(CLOSE Z26); DEAEA1:EMA(DIFIF1,9);MACD1:=2*(DIFIF1-DEAEA1),STICK;MACD2:=EMA(MACD1,3);STICKLINE(MACD 1 >MACD2 AND MACD1>0,0,MACD1,3,0),COLORRED; STICKLINE(MACD 1 >MACD2 AND MACD1<O Z O,MACD1,3,0),COLORGREEN; STICKLINE(MACD1<MACD2,0,MACD1Z3,0),COLORCBCBCO;STICKLINE(MACDl>=0 OR MACDl<=O z O z O z50,l)z COLORWHITE;DIFIF1,COLOR33FF33,LINETHICK2;DEAEAl’COLORYELLOW 丄INETHICK2;MACD: MACD1,NODRAW,COLORMAGENTA;强:IF(DIFIF1>=DEAEA1,DIFIF1QRAWNULL),COLORRED 丄INETHICK2;弱:IF(DEAEA1>=DIFIF1Z DEAEA1,DRAWNULL)Z COLORFF9900,LINETHICK2; DRAWICON(CROSS(DIFIF1,DEAEA1),DIFIF1+O.l,l);DRAWICON(CROSS(DEAEA1,DIFIF1),0.4,2);Al:=BARSLAST(REF(CROSS(n MACD. DIF H z n MACD. DEA n)z 1));B1:=REF(C,A1+1)>C AND REF(H MACD.DIF,,,Al+l)<H MACD.DIF n AND CROSS(n MACD.DIF,,,n MACD.DEA n);DRAWTEXT(Bl>0z-0.8;MACD 底背'),COLORFFOOFF;A2:=BARSLAST(REF(CROSS(,,KDJ.K,,/,,KDJ.D,,)Z1));B2:=REF(C,A2+1)>C AND REF(^^KDJ.K^,,A24-1)<^^KDJ.K,, ANDCROSS(,,KDJ.K,,z,,KDJ.D n);DRAWTEXT(B2z-0.6;KDJ 底离'),COLORYELLOW;{KDJ 底背离};A3:=BARSLAST(REF(CROSS(,,RSLRSI1,,Z,,RSI.RSI2,,),1));B3:=REF(C,A3+1)>C AND REF(,,RSLRSIl,,z A3+l)<,,RSI.RSir,AND CROSS(”RSI・RSI1TRSI・RSI2J;DRAWTEXT(B3>0,-0.3z'RSI 底离'),COLORCYAN;{RSI 底背离};C1:=BARSLAST(REF(CROSS(,,MACD.DEA,,/,MACD.DIF,,),1));Dl:=REF(C,Cl+l)vC AND [^=(“1^。
MACD三背离通达信指标公式源码
MACD三背离通达信指标公式源码以下是通达信软件中MACD三背离指标的公式源码:```python#定义变量VAR1:=CLOSE-REF(CLOSE,1);VAR2:=EMA(VAR1,12);VAR3:=EMA(VAR1,26);VAR5:=(VAR2-VAR3)/VAR2*100;VAR6:=EMA(VAR5,9);VAR7:=IF(VAR5>0,VAR5,VAR6);VAR8:=EMA(VAR7,9);VAR4:=(VAR7-VAR8);#计算背离判断DIVERGENCE1:=IF(VAR5>0,IF(CROSS(VAR7,VAR8),1,-1),0);DIVERGENCE2:=IF(VAR5>0,IF(CROSS(VAR7,0),-1,IF(CROSS(VAR4,0),1,0)),0);DIVERGENCE:=IF(DIVERGENCE1==-1ORDIVERGENCE2==-1,-1,0);#输出背离信号DRAWTEXT(DIVERGENCE,'背离',60,DIVERGENCE);```该源码主要是计算MACD三背离的指标,其中包括了MACD线和信号线的计算,以及背离的判断和输出。
首先,VAR1是计算当日收盘价与前一日收盘价的差值。
VAR2和VAR3分别是VAR1的12日指数移动平均值和26日指数移动平均值。
然后,VAR5是MACD线的计算,即VAR2和VAR3的差值除以VAR2后乘以100。
接下来,VAR6是VAR5的9日指数移动平均值,并通过IF语句将VAR5和VAR6的较大值赋给VAR7,以确保VAR7始终大于零。
VAR8是VAR7的9日指数移动平均值。
最后,VAR4是VAR7和VAR8的差值,即MACD柱。
DIVERGENCE1和DIVERGENCE2分别计算第一类背离和第二类背离。
第一类背离是根据MACD线和信号线的交叉情况判断,如果MACD线由上方向下穿信号线,则为1,反之为-1、第二类背离是根据MACD柱的变化情况判断,如果MACD柱由正值变为负值,则为-1,反之如果MACD柱由负值变为正值,则为1最后,根据背离的判断结果,使用DRAWTEXT函数在图表上绘制背离信号。
通达信指标公式源码 H超级KMACD 副图源码
{通达信'H超级KMACD'源码}H0:=0.25;L0:=(H+L+C)/3;L1:=H0*(L0-MA(L0,21))/(AVEDEV(L0,21));超级K:SMA(L1,3,1);超级D:SMA(超级K,3,1);超级J:超级K*3-超级D*2,COLORCC66BB;H1:=3.809*H0+REVERSE(EMA(超级J,1));H2:=-2.809*H0+REVERSE(EMA(超级J,1));IF(超级J>H1,超级J,DRAWNULL),COLORAAAA33,LINETHICK3;做顶:IF(超级J>H1,1,0),COLORCYAN,NODRAW;IF(超级J<H2,1,0),COLOR880088,NODRAW;筑底:IF(超级J<H2,超级J,DRAWNULL),COLORDD00DD,LINETHICK3;H3:=CROSS(超级K,超级D);H4:=超级J<REF(超级J,1) AND REF(超级J,1)>REF(超级D,1) AND 超级J<=超级D; H5:=超级J>H1 AND NOT(REF(超级J>H1,1));拉升为1:IF(H5,1,0),COLORFFFFCC,NODRAW;金叉:IF(H3,1,0),COLORRED,NODRAW;死叉:IF(H4,1,0),COLORGREEN,NODRAW;【选股基准线】:CONST(HHV(MAX(MAX(超级K,超级D),超级J),0))*1.1,COLORLIRED; DIF0:=EMA(DCLOSE,8)-EMA(DCLOSE,22);DEA0:=EMA(DIF0,7);MACD:=2*(DIF0-DEA0);D0:=HHV(ABS(MACD),100);M0:=COUNT(CROSS(DIF0,DEA0),BARSLAST(DEA0>=0));M1:=BARSLAST(REF(CROSS(MACD,0),1));M2:=BARSLAST(REF(CROSS(DEA0,DIF0),1));M3:=LLV(MACD,4)>0 AND MACD<REF(MACD,1) AND REF(MACD,1)>REF(MACD,2) AND REF(MACD,2)>REF(MACD,3);M4:=HHV(MACD,4)<0 AND MACD>REF(MACD,1) AND REF(MACD,1)<REF(MACD,2)AND REF(MACD,2)<REF(MACD,3);低位金叉:IF(CROSS(DIF0,DEA0) AND DIF0<-0.1,D0*0.4+【选股基准线】,0+【选股基准线】),COLORFF00FF;二次金叉:IF(CROSS(DIF0,DEA0) AND DEA0<0 AND COUNT(M0=2,21)=1,D0*0.8+【选股基准线】,0+【选股基准线】),COLORFFFF00;启点:IF(FILTER(MACD>0 AND MACD>5*REF(MACD,1),2),D0+【选股基准线】,0+【选股基准线】),COLOR0044FF;底背离:=REF(CLOSE,M1+1)>CLOSE AND MACD>REF(MACD,M1+1),COLORGREEN;D1:=7;D2:=30;D3:=6;DIF1:=EMA(C,D1)-EMA(C,D2),COLORFFFFFF;DEA1:=EMA(DIF1,D3),COLORFF6666;MACD1:=(DIF1-DEA1)*2,COLORSTICK,COLORRED;F0:=V*(O+C+H+L)/4;F1:=IF(V>0,F0/V,(O+C+H+L)/4);F2:=(F1-LLV(F1,5))/(HHV(F1,5)-LLV(F1,5));F3:=SMA(F2,13,1);F4:=SMA(F3,13,1);F5:=3*F3-2*F4;F6:=2*F5-0.5;F7:=F1*(1-(F6-F4)/40);F8:=CROSS(F1,F7) AND C/REF(C,1)<1.03 AND SUM(DYNAINFO(23),5)>=3000; MACD拉升:IF(FILTER(F8,10) AND MACD1>0,D0*1.2+【选股基准线】,0+【选股基准线】),COLOR6600FF;MACD选长:=IF(CROSS(DIF1,DEA1),HHV(ABS(MACD1),100)+【选股基准线】,0),COLORLIRED;DIF:DIF0+【选股基准线】,COLORFFFFFF;DEA:DEA0+【选股基准线】,COLOR00AAAA;0,COLOR888888,POINTDOT;DRAWTEXT(FILTER(F8,10) AND MACD1>0,D0*1.1+【选股基准线】,'拉'),COLOR6600FF; STICKLINE(H5,超级J*1.2,超级J*0.8,0,-1),COLORFFFFCC;DRAWTEXT(H5,超级J*1.25,'拉'),COLORFFFFCC;DRAWICON(H4,超级K*1.3,2);DRAWICON(H3,超级K*0.7,1);STICKLINE(MACD>=0 AND MACD>=REF(MACD,1),0+【选股基准线】,MACD+【选股基准线】,1,0),COLOR6699FF;STICKLINE(MACD>=0 AND MACD<=REF(MACD,1),0+【选股基准线】,MACD+【选股基准线】,1,-1),COLOR008800;STICKLINE(MACD<=0 AND MACD>=REF(MACD,1),0+【选股基准线】,MACD/2+【选股基准线】,1,0),COLORAAAAAA;STICKLINE(MACD<=0 AND MACD<=REF(MACD,1),0+【选股基准线】,MACD/2+【选股基准线】,1,-1),COLORCC6600;DRAWTEXT(FILTER(M3,3),-0.15+【选股基准线】,'转空'),COLOR00FF00; DRAWTEXT(FILTER(M4,3),D0*0.5+【选股基准线】,'转多'),COLORFFFFBB;DRAWTEXT(CROSS(DIF0,DEA0) AND DIF0<-0.1,D0*0.3+【选股基准线】,'低位X'),COLORFF00FF;DRAWTEXT(CROSS(DIF0,DEA0) AND DEA0<0 AND COUNT(M0=2,21)=1,D0*0.7+【选股基准线】,'二次X'),COLORFFFF00;DRAWTEXT(FILTER(MACD>0 AND MACD>5*REF(MACD,1),2),D0*0.9+【选股基准线】,'启'),COLOR0044FF;。
通达信指标公式源码彩色MACD指标副图源码
通达信指标公式源码彩色MACD指标副图源码[object Object]彩色MACD指标是一种技术分析指标,用于判断股票或其他金融资产价格的趋势和买卖信号。
它是在传统的MACD指标基础上进行改进,通过在MACD指标的柱状图上添加颜色来增加指标的可读性和直观性。
下面是通达信软件中彩色MACD指标的源码:```python#定义彩色MACD指标函数def Colorful_MACD(ema1, ema2, dea, color1, color2):DIFF = ema1 - ema2DEA = deaMACD=2*(DIFF-DEA)color = [color1 if diff >= 0 else color2 for diff in DIFF]return MACD, DIFF, DEA, color#使用彩色MACD指标函数计算指标数值MACD, DIFF, DEA, color = Colorful_MACD(EMA(CLOSE, 12),EMA(CLOSE, 26), EMA(MACD, 9), COLORRED, COLORGREEN)#绘制彩色MACD指标副图PlotBar(MACD, DIFF, DEA, 0, color, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)```上述代码中,Colorful_MACD函数用于计算彩色MACD指标的数值。
函数的输入参数分别为短期指数移动平均(EMA)和长期EMA的数值,以及MACD的DEA数值。
函数根据DIFF(短期EMA减去长期EMA)的正负来确定颜色,如果DIFF大于等于0,则使用color1(例如COLORRED)作为颜色,否则使用color2(例如COLORGREEN)作为颜色。
函数的输出为MACD、DIFF、DEA和color四个变量。
通达信指标公式源码 顶底背离MACD副图指标
VAR1:=EMA(SLOPE(C,21)+C,55);VAR2:=EMA(SLOPE(O,21)+O,55);VAR3:=EMA(SLOPE(H,21)+H,55);VAR4:=EMA(SLOPE(L,21)+L,55);VAR5:=EMA(C,3);VAR6:=EMA(O,3);VAR7:=EMA(H,3);VAR8:=EMA(L,3);VAR9:=VAR1-VAR5,LINETHICK2;VAR10:=VAR2-VAR6,LINETHICK2;VAR11:=VAR3-VAR7,LINETHICK2;VAR12:=VAR4-VAR8,LINETHICK2;ZJC:=REVERSE(VAR9);ZJO:=REVERSE(VAR10);ZJH:=REVERSE(VAR11);ZJL:=REVERSE(VAR12);DIF:EMA(ZJC*5,12)-EMA(ZJC*5,26);DEA:EMA(DIF,9);MACD:(DIF-DEA)*2,COLORSTICK;STICKLINE(MACD>REF(MACD,1) AND MACD>0,0,MACD,0,0),COLORRED; STICKLINE(MACD<REF(MACD,1) AND MACD>0,0,MACD,0,0),COLORMAGENTA;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),COLORLIGREEN; STICKLINE(ZJC> ZJO,ZJH,ZJL,0.0,0),COLORFF66FF;STICKLINE(ZJC> ZJO,ZJC,ZJO,2.1,0),COLORAA00AA;STICKLINE(ZJC> ZJO,ZJC,ZJO,1.9,0),COLORCC11CC;STICKLINE(ZJC> ZJO,ZJC,ZJO,1.6,0),COLORFF22FF;STICKLINE(ZJC> ZJO,ZJC,ZJO,1.2,0),COLORFF44FF;STICKLINE(ZJC> ZJO,ZJC,ZJO,0.7,0),COLORFF66FF;STICKLINE(ZJC> ZJO,ZJC,ZJO,0.2,0),COLORFF99FF;STICKLINE(ZJC<=ZJO,ZJL,ZJC,0.0,0),COLORGREEN;STICKLINE(ZJC<=ZJO,ZJO,ZJC,2.1,0),COLOR005500;STICKLINE(ZJC<=ZJO,ZJO,ZJC,1.9,0),COLOR007700;STICKLINE(ZJC<=ZJO,ZJO,ZJC,1.6,0),COLOR009900;STICKLINE(ZJC<=ZJO,ZJO,ZJC,1.2,0),COLOR00BB00;STICKLINE(ZJC<=ZJO,ZJO,ZJC,0.7,0),COLOR00DD00;STICKLINE(ZJC<=ZJO,ZJO,ZJC,0.2,0),COLOR44FF00;ZTB:=(C-REF(C,1))/REF(C,1)*100>9.9;DRAWTEXT(ZTB,IF(ZJC<0,ZJC*0.9,ZJC*1.1),'涨停板')COLORYELLOW; STICKLINE(ZTB,ZJC,ZJO,2.1,0),COLOR006666;STICKLINE(ZTB,ZJC,ZJO,1.9,0),COLOR008888;STICKLINE(ZTB,ZJC,ZJO,1.6,0),COLOR00AAAA;STICKLINE(ZTB,ZJC,ZJO,1.2,0),COLOR00CCCC;STICKLINE(ZTB,ZJC,ZJO,0.7,0),COLOR00EEEE;STICKLINE(ZTB,ZJC,ZJO,0.2,0),COLOR33FFFF;DTB:=(C-REF(C,1))/REF(C,1)*100<-9.9;DRAWTEXT(DTB,IF(ZJC>0,ZJC*0.9,ZJC*1.1),'跌停板')COLORFF8800; STICKLINE(DTB,ZJO,ZJC,2.1,0),COLORFF0000;{蓝色}STICKLINE(DTB,ZJO,ZJC,1.9,0),COLORFF2200;STICKLINE(DTB,ZJO,ZJC,1.6,0),COLORFF4400;STICKLINE(DTB,ZJO,ZJC,1.2,0),COLORFF6600;STICKLINE(DTB,ZJO,ZJC,0.7,0),COLORFF8800;STICKLINE(DTB,ZJO,ZJC,0.2,0),COLORFFAA00;。
MACD背离自动画线通达信指标公式源码
MACD背离自动画线通达信指标公式源码通达信(MetaStock)是一种常用的股票分析软件,提供了丰富的指标库。
在通达信中编写指标公式可以使用通达信自带的公式语言-支持C语言语法。
为了实现MACD背离自动画线指标,我们首先要计算MACD指标的数值,并判断是否出现背离。
接下来,我们可以使用通达信的画线函数实现在背离点位置上自动画线。
下面是该指标的示例源码:```javascript/*时间:2024-01-01*/#include "stdio.h"#include "stdlib.h"#include "string.h"#include "windows.h"/*定义MACD指标相应变量*/double EMA_SHORT;double EMA_LONG;double DIFF;double DEA;double MACD;/*初始化操作,在指标开始计算之前调用*/void InitEMA_SHORT=0;EMA_LONG=0;DIFF=0;DEA=0;MACD=0;/*计算MACD指标的数值*/void CalculateMACD(double close[], int n, int shortPeriod, int longPeriod, int signalPeriod)double EMA_SHORT_SMOOTH = 2.0 / (shortPeriod + 1);double EMA_LONG_SMOOTH = 2.0 / (longPeriod + 1);//计算短期EMAdouble emaShortPrev = close[0];for (int i = 0; i < shortPeriod; i++)emaShortPrev = emaShortPrev * (1 - EMA_SHORT_SMOOTH) +close[i] * EMA_SHORT_SMOOTH;}//计算长期EMAdouble emaLongPrev = close[0];for (int i = 0; i < longPeriod; i++)emaLongPrev = emaLongPrev * (1 - EMA_LONG_SMOOTH) + close[i] * EMA_LONG_SMOOTH;}//计算DIFF和DEADIFF = emaShortPrev - emaLongPrev;DEA=0;double DEA_SMOOTH = 2.0 / (signalPeriod + 1);for (int i = 0; i < signalPeriod; i++)DEA=DEA*(1-DEA_SMOOTH)+DIFF*DEA_SMOOTH;}//计算MACDMACD=(DIFF-DEA)*2;/*判断是否出现背离*/int IsDivergence(double close[], int n, int direction)for (int i = 2; i < n; i++)double prevClose1 = close[i - 2];double prevClose2 = close[i - 1];double currentClose = close[i];if (direction == 1) // 上涨背离:前两个低点价格下降,当前高点价格上升if (prevClose1 > prevClose2 && prevClose2 > currentClose) return i;}}else if (direction == -1) // 下跌背离:前两个高点价格上升,当前低点价格下降if (prevClose1 < prevClose2 && prevClose2 < currentClose)return i;}}}return -1;/*自动画线函数,在背离位置上自动画线*/void AutoDrawLine(int barIndex, int direction)//自动画线的相关处理,这里仅做示例printf("在第 %d 根K线上画上涨背离线。
通达信指标公式源码 macd副图指标,逃顶抄底,买卖利器
RSV:=(CLOSE-LLV(LOW,11))/(HHV(HIGH,11)-LLV(LOW,11))*100;DIF:EMA(CLOSE,12)-EMA(CLOSE,26);DEA:EMA(DIF,9);MACD:(DIF-DEA)*2,COLORSTICK;DIFF:=EMA(CLOSE,12)-EMA(CLOSE,27);DEA1:=EMA(DIFF,9);MACD1:=2*(DIFF-DEA1),COLORSTICK,LINETHICK2;趋势:=MA(MACD,1);DRAWICON(MACD1>REF(MACD1,1) AND 趋势>0 ,趋势,1);低位金叉:=CROSS(DIF,DEA) AND DIF<-0.1;JCCOUNT:=COUNT(CROSS(DIF,DEA),BARSLAST(DEA>=0));二次金叉:=CROSS(DIF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,21)=1;K:=SMA(RSV,3,1);D:=SMA(K,3,1);J:=(3*K-2*D);DRAWTEXT(二次金叉,DEA*1,'低二叉'),COLORYELLOW;周DIF:="MACD.DIF#WEEK"(12,26,9);周DEA:="MACD.DEA#WEEK"(12,26,9);周MACD:="MACD.MACD#WEEK"(12,26,9);DIF周金叉:=CROSS(周DIF,周DEA);DRAWTEXT(DIF周金叉,0,'周叉'),COLORYELLOW;DRAWTEXT(CROSS(周DEA,周DIF),0,'周死'),COLORGREEN;MACD周金叉:=CROSS(周MACD,周DIF) AND 周MACD>=(0-0.05) AND 周MACD<=0.02; VARR:=EMA(EMA(CLOSE,13),13);控盘:=(VARR-REF(VARR,1))/REF(VARR,1)*1000;A10:=CROSS(控盘,0);控盘B:=FILTER(IF(A10,1,0),5);JJ:=DYNAINFO(11);P:=55;S:=8;M1:=3;刘:=(EMA(CLOSE,S)-EMA(CLOSE,P))*10;剑:=EMA(刘,M1);BTJ11:=(C-JJ)/JJ<-0.03;BTJ2:=控盘>REF(控盘,1) AND 控盘<-0.2;BTJ3:=CROSS(刘,剑) AND 刘<-0.3;BTJ811:=FILTER(BTJ11 AND BTJ2 AND BTJ3,13);庄:= BTJ11 AND BTJ2 AND BTJ3;有庄:=FILTER(庄,55),COLORWHITE;DRAWTEXT(BTJ811,-0.2,'★有庄'),COLORYELLOW;DRAWTEXT(CROSS(J,-3),DIF,'出击'),COLORWHITE;A1:=BARSLAST(REF(CROSS(EMA(CLOSE,12)-EMA(CLOSE,26),EMA(EMA(CLOSE,12)-EMA( CLOSE,26),9)),1));底背离:=REF(CLOSE,A1+1)>CLOSE AND EMA(CLOSE,12)-EMA(CLOSE,26)>REF(EMA(CLOSE,12)-EMA(CLOSE,26),A1+1) AND CROSS(EMA(CLOSE,12)-EMA(CLOSE,26),EMA(EMA(CLOSE,12)-EMA(CLOSE,26),9));底背:DRAWLINE(A1=0,DEA,底背离,DEA,0),COLORMAGENTA,LINETHICK2;A2:=BARSLAST(REF(CROSS(EMA(EMA(CLOSE,12)-EMA(CLOSE,26),9),EMA(CLOSE,12)-E MA(CLOSE,26)),1));顶背离:=REF(CLOSE,A2+1)<CLOSE AND REF(EMA(CLOSE,12)-EMA(CLOSE,26),A2+1)>EMA(CLOSE,12)-EMA(CLOSE,26) AND CROSS(EMA(EMA(CLOSE,12)-EMA(CLOSE,26),9),EMA(CLOSE,12)-EMA(CLOSE,26));顶背:DRAWLINE(A2=0,DEA,顶背离,DEA,0),COLORGREEN,LINETHICK2;。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
好厉害的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;
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;。