老师,帮我编写一下

1天前发布

DIFF : EMA(CLOSE,12) - EMA(CLOSE,26),COLORGRAY;DEA : EMA(DIFF,9),COLORLIGHTGREY;MACD:2*(DIFF-DEA),CO...


DIFF : EMA(CLOSE,12) - EMA(CLOSE,26),COLORGRAY;
DEA : EMA(DIFF,9),COLORLIGHTGREY;
MACD:2*(DIFF-DEA),COLORSTICK;
JC:=CROSS(DIFF,DEA);
SC:=CROSSDOWN(DIFF,DEA);
DRAWICON(JC,DIFF,4);
DRAWICON(SC,DIFF,5);
N1:=BARSLAST(JC)+1;
N2:=BARSLAST(SC)+1;
HH:=REF(HHV(H,N1),N2);//上次MACD红柱期间合约最大值
HH2:=REF(REF(HH,1),N2);//上上次MACD红柱期间合约最大值
MHD:=VALUEWHEN(SC,HHV(DIFF,N1));//上次MACD红柱期间DIFF最大值
MHD2:=VALUEWHEN(SC,REF(MHD,1));//上上次MACD红柱期间DIFF最大值

LL:=REF(LLV(L,N2),N1);
LL2:=REF(REF(LL,1),N1);
MLD:=VALUEWHEN(JC,LLV(DIFF,N2));
MLD2:=VALUEWHEN(JC,REF(MLD,1));

A:MACD<0&&HH>HH2&&MHDB:MACD>0&&LLMLD2;

DRAWLINE3(CROSS(A,0.5),HHV(DIFF,N1),HHVBARS(DIFF,N1),1,REF(HHV(DIFF,N1),SUMBARS(SC,2)),REF(HHVBARS(DIFF,N1),SUMBARS(SC,2))+SUMBARS(SC,2),0),COLORBLUE,LINETHICK2;
DRAWLINE3(CROSS(B,0.5),LLV(DIFF,N2),LLVBARS(DIFF,N2),1,REF(LLV(DIFF,N2),SUMBARS(JC,2)),REF(LLVBARS(DIFF,N2),SUMBARS(JC,2))+SUMBARS(JC,2),0),COLORBLUE,LINETHICK2;

MH:=VALUEWHEN(SC,HHV(MACD,N1));
MH2:=VALUEWHEN(SC,REF(MH,1));
ML:=VALUEWHEN(JC,LLV(MACD,N2));
ML2:=VALUEWHEN(JC,REF(ML,1));
AA:MACD<0&&HH>HH2&&MHBB:MACD>0&&LLML2;

DRAWLINE3(CROSS(AA,0.5),HHV(MACD,N1),HHVBARS(MACD,N1),1,REF(HHV(MACD,N1),SUMBARS(SC,2)),REF(HHVBARS(MACD,N1),SUMBARS(SC,2))+SUMBARS(SC,2),0),COLORGREEN,LINETHICK2;
DRAWLINE3(CROSS(BB,0.5),LLV(MACD,N2),LLVBARS(MACD,N2),1,REF(LLV(MACD,N2),SUMBARS(JC,2)),REF(LLVBARS(MACD,N2),SUMBARS(JC,2))+SUMBARS(JC,2),0),COLORMAGENTA,LINETHICK2;
给这个MACD的背离加一个声音报警
付费偷看设置
发送
6条回答
文华解答
2楼-- · 1天前

参考

DIFF : EMA(CLOSE,12) - EMA(CLOSE,26),COLORGRAY;
DEA : EMA(DIFF,9),COLORLIGHTGREY;
MACD:2*(DIFF-DEA),COLORSTICK;
JC:=CROSS(DIFF,DEA);
SC:=CROSSDOWN(DIFF,DEA);
DRAWICON(JC,DIFF,4);
DRAWICON(SC,DIFF,5);
N1:=BARSLAST(JC)+1;
N2:=BARSLAST(SC)+1;
HH:=REF(HHV(H,N1),N2);//上次MACD红柱期间合约最大值
HH2:=REF(REF(HH,1),N2);//上上次MACD红柱期间合约最大值
MHD:=VALUEWHEN(SC,HHV(DIFF,N1));//上次MACD红柱期间DIFF最大值
MHD2:=VALUEWHEN(SC,REF(MHD,1));//上上次MACD红柱期间DIFF最大值

LL:=REF(LLV(L,N2),N1);
LL2:=REF(REF(LL,1),N1);
MLD:=VALUEWHEN(JC,LLV(DIFF,N2));
MLD2:=VALUEWHEN(JC,REF(MLD,1));

A:MACD<0&&HH>HH2&&MHDB:MACD>0&&LLMLD2;

DRAWLINE3(CROSS(A,0.5),HHV(DIFF,N1),HHVBARS(DIFF,N1),1,REF(HHV(DIFF,N1),SUMBARS(SC,2)),REF(HHVBARS(DIFF,N1),SUMBARS(SC,2))+SUMBARS(SC,2),0),COLORBLUE,LINETHICK2;
DRAWLINE3(CROSS(B,0.5),LLV(DIFF,N2),LLVBARS(DIFF,N2),1,REF(LLV(DIFF,N2),SUMBARS(JC,2)),REF(LLVBARS(DIFF,N2),SUMBARS(JC,2))+SUMBARS(JC,2),0),COLORBLUE,LINETHICK2;

MH:=VALUEWHEN(SC,HHV(MACD,N1));
MH2:=VALUEWHEN(SC,REF(MH,1));
ML:=VALUEWHEN(JC,LLV(MACD,N2));
ML2:=VALUEWHEN(JC,REF(ML,1));
AA:MACD<0&&HH>HH2&&MHBB:MACD>0&&LLML2;
CROSS(AA,0.5),SOUND('A');
CROSS(BB,0.5),SOUND('A');
DRAWLINE3(CROSS(AA,0.5),HHV(MACD,N1),HHVBARS(MACD,N1),1,REF(HHV(MACD,N1),SUMBARS(SC,2)),REF(HHVBARS(MACD,N1),SUMBARS(SC,2))+SUMBARS(SC,2),0),COLORGREEN,LINETHICK2;
DRAWLINE3(CROSS(BB,0.5),LLV(MACD,N2),LLVBARS(MACD,N2),1,REF(LLV(MACD,N2),SUMBARS(JC,2)),REF(LLVBARS(MACD,N2),SUMBARS(JC,2))+SUMBARS(JC,2),0),COLORMAGENTA,LINETHICK2;

文期王华
3楼-- · 1天前
老师,帮我把这个编写成主图附属指标,隐藏所有指标线,当背离形成时,在发生背离的前高点/低点,用一根横线标注,长度为100
文华解答
4楼-- · 1天前

参考

DIFF := EMA(CLOSE,12) - EMA(CLOSE,26),COLORGRAY;
DEA := EMA(DIFF,9),COLORLIGHTGREY;
MACD:=2*(DIFF-DEA),COLORSTICK;
JC:=CROSS(DIFF,DEA);
SC:=CROSSDOWN(DIFF,DEA);
N1:=BARSLAST(JC)+1;
N2:=BARSLAST(SC)+1;
HH:=REF(HHV(H,N1),N2);//上次MACD红柱期间合约最大值
HH2:=REF(REF(HH,1),N2);//上上次MACD红柱期间合约最大值
MHD:=VALUEWHEN(SC,HHV(DIFF,N1));//上次MACD红柱期间DIFF最大值
MHD2:=VALUEWHEN(SC,REF(MHD,1));//上上次MACD红柱期间DIFF最大值

LL:=REF(LLV(L,N2),N1);
LL2:=REF(REF(LL,1),N1);
MLD:=VALUEWHEN(JC,LLV(DIFF,N2));
MLD2:=VALUEWHEN(JC,REF(MLD,1));

A:MACD<0&&HH>HH2&&MHDB:MACD>0&&LLMLD2;


MH:=VALUEWHEN(SC,HHV(MACD,N1));
MH2:=VALUEWHEN(SC,REF(MH,1));
ML:=VALUEWHEN(JC,LLV(MACD,N2));
ML2:=VALUEWHEN(JC,REF(ML,1));
AA:MACD<0&&HH>HH2&&MHBB:MACD>0&&LLML2;
CROSS(AA,0.5),SOUND('A');
CROSS(BB,0.5),SOUND('A');
X:=CROSS(BACKSET(REFX(A||AA,1),HHVBARS(H,N1)+1),0.5);
Y:=CROSS(BACKSET(REFX(B||BB,1),LLVBARS(L,N2)+1),0.5);
DRAWSL(CROSS(X,0.5),H,0,100,0,COLORRED);
DRAWSL(CROSS(Y,0.5),L,0,100,0,COLORGREEN);

文期王华
5楼-- · 1天前
老师,帮我再改动一下,默认每个横线自动延伸到屏幕最右边,当向上背离第二次成立时,前面的横线自动缩短到破位线,当向下背离第二次成立时,前面的横线自动缩短到破位线
文期王华
6楼-- · 1天前
老师就在4楼基础上,改动,使最后一根红线和最后一根绿线保持100长度,前面的线都自动缩短,
文华解答
7楼-- · 1天前
这样看下

DIFF := EMA(CLOSE,12) - EMA(CLOSE,26),COLORGRAY;
DEA := EMA(DIFF,9),COLORLIGHTGREY;
MACD:=2*(DIFF-DEA),COLORSTICK;
JC:=CROSS(DIFF,DEA);
SC:=CROSSDOWN(DIFF,DEA);
N1:=BARSLAST(JC)+1;
N2:=BARSLAST(SC)+1;
HH:=REF(HHV(H,N1),N2);//上次MACD红柱期间合约最大值
HH2:=REF(REF(HH,1),N2);//上上次MACD红柱期间合约最大值
MHD:=VALUEWHEN(SC,HHV(DIFF,N1));//上次MACD红柱期间DIFF最大值
MHD2:=VALUEWHEN(SC,REF(MHD,1));//上上次MACD红柱期间DIFF最大值

LL:=REF(LLV(L,N2),N1);
LL2:=REF(REF(LL,1),N1);
MLD:=VALUEWHEN(JC,LLV(DIFF,N2));
MLD2:=VALUEWHEN(JC,REF(MLD,1));

A:=MACD<0&&HH>HH2&&MHD
B:=MACD>0&&LLMLD2;


MH:=VALUEWHEN(SC,HHV(MACD,N1));
MH2:=VALUEWHEN(SC,REF(MH,1));
ML:=VALUEWHEN(JC,LLV(MACD,N2));
ML2:=VALUEWHEN(JC,REF(ML,1));
AA:=MACD<0&&HH>HH2&&MH
BB:=MACD>0&&LLML2;
CROSS(AA,0.5),SOUND('A');
CROSS(BB,0.5),SOUND('A');
X:=CROSS(BACKSET(REFX(A||AA,1),HHVBARS(H,N1)+1),0.5);
Y:=CROSS(BACKSET(REFX(B||BB,1),LLVBARS(L,N2)+1),0.5);
//DRAWSL(1,VALUEWHEN(CROSS(X,0.5),H),0,100,0,COLORRED);
//DRAWSL(1,VALUEWHEN(CROSS(Y,0.5),L),0,100,0,COLORGREEN);

DRAWHORIZONTALLINE(CROSS(X,0.5),H,COLORRED);
DRAWHORIZONTALLINE(CROSS(Y,0.5),L,COLORGREEN);
DRAWSL(CROSS(X,0.5)&&BACKSET(ISLASTBAR,BARSLAST(CROSS(X,0.5))+1),H,0,100,0,COLORRED);
DRAWSL(CROSS(Y,0.5)&&BACKSET(ISLASTBAR,BARSLAST(CROSS(Y,0.5))+1),L,0,100,0,COLORGREEN);