趋势买卖主图指标公式源码
VAR6:=(2*C+H+L)/4;
VAR8:=LLV(L,34);
VARA:=HHV(H,34);
BM:=EMA((VAR6-VAR8)/(VARA-VAR8)*100,3);
BM1:=EMA(BM,3);
AA:=BM-BM1>=0;
BB:=BM-BM1<0;
M20:=MA(C,18);
乖离 20:=ABS((2*C+H+L)/4-M20)/M20;
乖离线:=DMA(CLOSE,乖离 20);
止盈:乖离线*1.06,COLOR00FFFF,LINETHICK1;{20 天均线乖离+6%}
止损:乖离线*0.94,COLOR00FF00,LINETHICK1;{20 天均线乖离-6%}
DRAWBAND(止盈,RGB(0,0,255),乖离线,RGB(0,0,255));
DRAWBAND(乖离线,RGB(0,0,155),止损,RGB(0,0,155));
DRAWBAND(止盈,RGB(100,0,100),止盈*1.05,RGB(100,0,100));
DRAWBAND(止损,RGB(0,80,0),止损*0.95,RGB(0,180,0));
DMA(CLOSE,乖离 20);
乖离线*1.06,COLOR00FFFF,LINETHICK1;
乖离线*0.94,COLOR00FF00,LINETHICK1;
乖离线*1.06*1.05,COLOR0077FF,LINETHICK1;
乖离线*0.94*0.95,COLORFF9900,LINETHICK1;
{MA5}
重心:WMA((2*C+H+L)/4,2),COLOR00FFFF,LINETHICK0;
MA5:WMA(重心,5),COLOR00FF00,DOTLINE;
IF(MA5>REF(MA5,1),MA5,DRAWNULL),COLORRED,LINETHICK3;
DRAWICON(CROSS(AA,BB),(LOW * 0.98),34);
DRAWICON(CROSS(BB,AA),(H*1.01),35);
{K 线}
STICKLINE(CLOSE>OPEN OR CLOSE=OPEN AND
CLOSE>REF(CLOSE,1),LOW,HIGH,0.0,0),COLORRED;
STICKLINE(CLOSE<OPEN OR CLOSE=OPEN AND
CLOSE<=REF(CLOSE,1),LOW,HIGH,0.0,0),COLORCYAN;
STICKLINE(OPEN>=CLOSE ,CLOSE ,OPEN,3,0 ),COLOR008800;
STICKLINE(OPEN>=CLOSE ,CLOSE ,OPEN,2,0 ),COLOR00AA00;
STICKLINE(OPEN>=CLOSE ,CLOSE ,OPEN,1,0 ),COLOR00DD00;
STICKLINE(OPEN>=CLOSE ,CLOSE ,OPEN,0,0 ),COLOR00FF00;
STICKLINE(CLOSE>OPEN,CLOSE,OPEN,3,0) ,COLOR000088;
STICKLINE(CLOSE>OPEN,CLOSE,OPEN,2,0) ,COLOR0000AA;
STICKLINE(CLOSE>OPEN,CLOSE,OPEN,1,0) ,COLOR0000DD;
STICKLINE(CLOSE>OPEN,CLOSE,OPEN,0,0) ,COLOR0000FF;
主图趋势线指标源码
DIFF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
N1:=BARSLAST(CROSS(DIFF,DEA))+1;{最近一次满足条件 DIFF 上穿 DEA 的 K线到当前的
距离}
N2:=BARSLAST(CROSS(DEA,DIFF))+1;{最近一次满足条件 DIFF 下穿 DEA 的 K线到当前的
距离}
{当前是 DIFF>DEA 的状态, 连结最近两个 DIFF>DEA 区间(不包含当前区间) 内最高点的
趋势线}
A1:=BACKSET(ISLASTBAR &&
N1<N2,REF(REF(HHVBARS(H,N1)+1,N2),N2)+REF(N2,N2)+N2);
B1:=BACKSET(ISLASTBAR && N1<N2,REF(HHVBARS(H,N1),N2)+N2+1);
DRAWLINE(CROSS(A1,0.5),H,CROSS(B1,0.5),H,1),COLORRED;
{当前是 DIFF>DEA 的状态, 连结最近两个 DIFF<DEA 区间内最低点的趋势线}
A2:=BACKSET(ISLASTBAR &&
N1<N2,REF(REF(LLVBARS(L,N2)+1,N1),N2)+REF(N1,N2)+N2);
B2:=BACKSET(ISLASTBAR && N1<N2,REF(LLVBARS(L,N2)+1,N1)+N1);
DRAWLINE(CROSS(A2,0.5),L,CROSS(B2,0.5),L,1),COLORGREEN;
{当前是 DIFF<DEA 的状态, 连结最近两个 DIFF<DEA 区间(不包含当前区间) 内最低点的
趋势线}
A3:=BACKSET(ISLASTBAR &&
N1>N2,REF(REF(LLVBARS(L,N2)+1,N1),N1)+REF(N1,N1)+N1);
B3:=BACKSET(ISLASTBAR && N1>N2,REF(LLVBARS(L,N2),N1)+N1+1);
DRAWLINE(CROSS(A3,0.5),L,CROSS(B3,0.5),L,1),COLORGREEN;
{当前是 DIFF<DEA 的状态, 连结最近两个 DIFF>DEA 区间内最高点的趋势线}
A4:=BACKSET(ISLASTBAR &&
N1>N2,REF(REF(HHVBARS(H,N1)+1,N2),N1)+REF(N2,N1)+N1);
B4:=BACKSET(ISLASTBAR && N1>N2,REF(HHVBARS(H,N1)+1,N2)+N2);
DRAWLINE(CROSS(A4,0.5),H,CROSS(B4,0.5),H,1),COLORRED;
评论(0)