找回密码
 立即注册

QQ登录

只需一步,快速开始

广告载入中...
查看: 5208|回复: 10

macd顶底背离交易系统(有未来函数,不喜欢的不要用),仅供参考

  [复制链接]
发表于 2010-3-12 08:16 | 显示全部楼层 |阅读模式

马上注册,享用更多功能,让你轻松玩转本论坛。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
input:s(12,1,100),p(26,1,100),m(9,1,100);
DIFF:=EMA(CLOSE,s)-EMA(CLOSE,p);
DEA:=EMA(DIFF,m);
MACD:=2*(DIFF-DEA);
A1:=BARSLAST(CROSS(DEA,DIFF));
A2:=llvbars(diff,A1);
A3:=barslast(A2=1);
A4:=ref(A3,1)+2;
llA1:=min(min(l,ref(l,1)),ref(l,2));
llA2:=min(min(ref(l,A4-1),ref(l,A4)),ref(l,A4+1));
diffA1:=min(min(diff,ref(diff,1)),ref(diff,2));
diffA2:=min(min(ref(diff,A4-1),ref(diff,A4)),ref(diff,A4+1));
背离A:=llA1<llA2 and diffA1>diffA2 and count(cross(dea,diff),A4)=1;
S1:=BARSLAST(CROSS(DIFF ,DEA));
S2:=hhvbars(diff,S1);
S3:=barslast(S2=1);
S4:=ref(S3,1)+2;
HHS1:=MAX(MAX(H,ref(H,1)),ref(H,2));
HHS2:=MAX(MAX(ref(H,S4-1),ref(H,S4)),ref(H,S4+1));
diffS1:=MAX(MAX(diff,ref(diff,1)),ref(diff,2));
diffS2:=MAX(MAX(ref(diff,S4-1),ref(diff,S4)),ref(diff,S4+1));
背离S:=HHS1>HHS2 and diffS1<diffS2 and count(cross(diff, dea),S4)=1;
B1:=BARSLAST(CROSS(DEA,DIFF));
B2:=llvbars(macd,B1);
B3:=barslast(B2=1);
B4:=ref(B3,1)+2;
llB1:=min(min(l,ref(l,1)),ref(l,2));
llB2:=min(min(ref(l,B4-1),ref(l,B4)),ref(l,B4+1));
macdB1:=min(min(macd,ref(macd,1)),ref(macd,2));
macdB2:=min(min(ref(macd,B4-1),ref(macd,B4)),ref(macd,B4+1));
BB:=llB1<llB2 and macdB1>macdB2 and count(cross(dea,diff),B4)=1;
D1:=BARSLAST(CROSS(DIFF, DEA));
D2:=hhvbars(macd,D1);
D3:=barslast(D2=1);
D4:=ref(D3,1)+2;
hhD1:=max(max(h,ref(h,1)),ref(h,2));
hhD2:=max(max(ref(h,D4-1),ref(h,D4)),ref(h,D4+1));
macdD1:=max(max(macd,ref(macd,1)),ref(macd,2));
macdD2:=max(max(ref(macd,D4-1),ref(macd,D4)),ref(macd,D4+1));
DD:=hhD1>hhD2 and macdD1<macdD2 and count(cross(diff,dea),D4)=1;
AA1:=TROUGHBARS(c,5,1)=1;
SS1:=PEAKBARS(c,5,1)=1;
bB1:=TROUGHBARS(c,5,1)=1;
bB2:=barslast(cross(diff,dea))-barslast(cross(dea,diff))<=13 and barslast(cross(diff,dea))-barslast(cross(dea,diff))>0;
bB3:=macd>ref(macd,1) and ref(macd,2)>ref(macd,1);
dD1:=PEAKBARS(c,5,1)=1;
dD2:=barslast(cross(dea,diff))-barslast(cross(diff,dea))<=13 and barslast(cross(dea,diff))-barslast(cross(diff,dea))>0;
dD3:=macd<ref(macd,1) and ref(macd,2)<ref(macd,1);
ENTERLONG:((AA1 or a2=1)  and 背离A)  or ((B2=1 OR AA1) AND BB) OR (BB1 AND BB2 AND BB3);{多头买入}
EXITLONG:((SS1 or s2=1) and 背离S)  or ((D2=1 OR SS1) AND DD) OR (DD1 AND DD2 AND DD3);{多头卖出}
//ENTERSHORT: ,TFILTER; 卖出开仓/空头开仓
//EXITSHORT: ,TFILTER; 买入平仓/空头平仓

发表于 2010-3-12 08:41 | 显示全部楼层
学习学习。

回复

使用道具 举报

发表于 2010-3-12 08:53 | 显示全部楼层
学习学习.谢谢分享.
回复

使用道具 举报

发表于 2010-3-12 10:15 | 显示全部楼层
回复

使用道具 举报

发表于 2010-3-12 10:24 | 显示全部楼层
DIFF:=EMA(CLOSE,s)-EMA(CLOSE,p);
DEA:=EMA(DIFF,m);
MACD:=2*(DIFF-DEA);
A1:=BARSLAST(CROSS(DEA,DIFF));
A2:=llvbars(diff,A1);
A3:=barslast(A2=1);
A4:=ref(A3,1)+2;
llA1:=min(min(l,ref(l,1)),ref(l,2));
llA2:=min(min(ref(l,A4-1),ref(l,A4)),ref(l,A4+1));
diffA1:=min(min(diff,ref(diff,1)),ref(diff,2));
diffA2:=min(min(ref(diff,A4-1),ref(diff,A4)),ref(diff,A4+1));
背离A:=llA1<llA2 and diffA1>diffA2 and count(cross(dea,diff),A4)=1;


S1:=BARSLAST(CROSS(DIFF ,DEA));
S2:=hhvbars(diff,S1);
S3:=barslast(S2=1);
S4:=ref(S3,1)+2;
HHS1:=MAX(MAX(H,ref(H,1)),ref(H,2));
HHS2:=MAX(MAX(ref(H,S4-1),ref(H,S4)),ref(H,S4+1));
diffS1:=MAX(MAX(diff,ref(diff,1)),ref(diff,2));
diffS2:=MAX(MAX(ref(diff,S4-1),ref(diff,S4)),ref(diff,S4+1));
背离S:=HHS1>HHS2 and diffS1<diffS2 and count(cross(diff, dea),S4)=1;


B1:=BARSLAST(CROSS(DEA,DIFF));
B2:=llvbars(macd,B1);
B3:=barslast(B2=1);
B4:=ref(B3,1)+2;
llB1:=min(min(l,ref(l,1)),ref(l,2));
llB2:=min(min(ref(l,B4-1),ref(l,B4)),ref(l,B4+1));
macdB1:=min(min(macd,ref(macd,1)),ref(macd,2));
macdB2:=min(min(ref(macd,B4-1),ref(macd,B4)),ref(macd,B4+1));
BB:=llB1<llB2 and macdB1>macdB2 and count(cross(dea,diff),B4)=1;


D1:=BARSLAST(CROSS(DIFF, DEA));
D2:=hhvbars(macd,D1);
D3:=barslast(D2=1);
D4:=ref(D3,1)+2;
hhD1:=max(max(h,ref(h,1)),ref(h,2));
hhD2:=max(max(ref(h,D4-1),ref(h,D4)),ref(h,D4+1));
macdD1:=max(max(macd,ref(macd,1)),ref(macd,2));
macdD2:=max(max(ref(macd,D4-1),ref(macd,D4)),ref(macd,D4+1));
DD:=hhD1>hhD2 and macdD1<macdD2 and count(cross(diff,dea),D4)=1;

AA1:=TROUGHBARS(c,5,1)=1;
SS1:=PEAKBARS(c,5,1)=1;

bB1:=TROUGHBARS(c,5,1)=1;
bB2:=barslast(cross(diff,dea))-barslast(cross(dea,diff))<=13 and barslast(cross(diff,dea))-barslast(cross(dea,diff))>0;
bB3:=macd>ref(macd,1) and ref(macd,2)>ref(macd,1);
dD1:=PEAKBARS(c,5,1)=1;
dD2:=barslast(cross(dea,diff))-barslast(cross(diff,dea))<=13 and barslast(cross(dea,diff))-barslast(cross(diff,dea))>0;
dD3:=macd<ref(macd,1) and ref(macd,2)<ref(macd,1);




ENTERLONG:(AA1 or a2=1)  and 背离A)  or ((B2=1 OR AA1) AND BB) OR (BB1 AND BB2 AND BB3);{多头买入}
EXITLONG:(SS1 or s2=1) and 背离S)  or ((D2=1 OR SS1) AND DD) OR (DD1 AND DD2 AND DD3);{多头卖出}
//ENTERSHORT: ,TFILTER; 卖出开仓/空头开仓
//EXITSHORT: ,TFILTER; 买入平仓/空头平仓
回复

使用道具 举报

发表于 2010-3-15 00:40 | 显示全部楼层
谢谢......当前公式 : MACD背离 (指标画线公式)  
错误句 : INPUT:S(12,1,100),P(26,1,100),M(9,1,100)
详细信息 : 您在括号前写的不是函数、公式等,
且缺少必要的运算符!
错误起始位置 : 0 ; 长度: 0
回复

使用道具 举报

发表于 2011-11-15 09:56 | 显示全部楼层
谢谢分享学习了
回复

使用道具 举报

发表于 2012-6-23 11:09 | 显示全部楼层
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;
回复

使用道具 举报

发表于 2014-3-15 16:32 | 显示全部楼层
学习一下啦
回复

使用道具 举报

发表于 2018-11-20 12:13 | 显示全部楼层
进退有据,速战急归,一柱一线,快乐赚钱
回复

使用道具 举报

发表于 2019-2-13 13:52 | 显示全部楼层

进退有据,速战急归,一柱一线,快乐赚钱
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|股海明灯官网 ( 京ICP备18020431号 )

GMT+8, 2024-11-24 07:43 , Processed in 0.093914 second(s), Total 12, Slave 11 queries , Gzip On, MemCached On.

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表