一大早发布的波浪尺算法代码,评论区讨论热烈,这也从侧面反映出该思路的价值和建立通用性算法的极大意义,不再耽搁,继续分享。
上一文章《惊艳新代码—EBE波浪尺的算法分享》,建立的是EBE的波浪尺,接下来完成BEB波浪尺的算法。
接着延续网友留言中的相反方向,进行算法建立—
网友的留言
思路步骤
依据相反的方向,波浪尺的定义,包含了B2、B1以及E1三个元素;
算法建立
1.
TE2:=CONST(PEAKBARS(1,F,W+1));
TE1:=CONST(PEAKBARS(1,F,W));
TB2:=CONST(TROUGHBARS(2,G,W+1));
TB1:=CONST(TROUGHBARS(2,G,W));
RE1:=IF(CURRBARSCOUNT<=TE1+1 AND RANGE(TE1,TB1,TB2),CONST(PEAK(1,F,W)),DRAWNULL);
RB2:=IF(CURRBARSCOUNT<=TB2+1,CONST(TROUGH(2,G,W+1)),DRAWNULL);
RB1:IF(CURRBARSCOUNT<=TB1+1 AND RB2<CONST(TROUGH(2,G,W)),CONST(TROUGH(2,G,W)),DRAWNULL),COLORYELLOW;
DRAWLINE(CURRBARSCOUNT=CONST(BARSLAST(H=RE1))+1,H,CURRBARSCOUNT=CONST(BARSLAST(L=RB1))+1,L,0),COLORYELLOW;
DRAWLINE(CURRBARSCOUNT=CONST(BARSLAST(L=RB2))+1,L,CURRBARSCOUNT=CONST(BARSLAST(H=RE1))+1,H,0),COLORYELLOW;
DRAWTEXT(CURRBARSCOUNT=CONST(BARSLAST(H=RE1))+1 AND RANGE(TE1,TB1,TB2),H*1.003,’B’),COLORYELLOW;
DRAWTEXT(CURRBARSCOUNT=CONST(BARSLAST(L=RB1))+1,L*0.997,’C’),COLORYELLOW;
DRAWTEXT(CURRBARSCOUNT=CONST(BARSLAST(L=RB2))+1,L*0.997,’A’),COLORYELLOW;
2.
RBE:=RE1-RB2;
3.
RBE0382:RB1+RBE*0.382,DOTLINE;
RBE05:RB1+RBE*0.5,DOTLINE;
RBE0618:RB1+RBE*0.618,DOTLINE;
RBE100:RB1+RBE,COLORYELLOW;
RBE1382:RB1+RBE+RBE*0.382,DOTLINE;
RBE15:RB1+RBE+RBE*0.5,DOTLINE;
RBE1618:RB1+RBE+RBE*0.618,DOTLINE;
RBE200:RB1+RBE*2,COLORYELLOW;
4.
STICKLINE(CURRBARSCOUNT=IF(INTPART((TB1+1)/2)=1,2,INTPART((TB1+1)/2)),RB1,RBE200,0,0),COLORYELLOW;
5.
DRAWNUMBER(ISLASTBAR,RBE0382,RBE0382);
DRAWNUMBER(ISLASTBAR,RBE05,RBE05);
DRAWNUMBER(ISLASTBAR,RBE0618,RBE0618);
DRAWNUMBER(ISLASTBAR,RBE100,RBE100);
DRAWNUMBER(ISLASTBAR,RBE1382,RBE1382);
DRAWNUMBER(ISLASTBAR,RBE15,RBE15);
DRAWNUMBER(ISLASTBAR,RBE1618,RBE1618);
DRAWNUMBER(ISLASTBAR,RBE200,RBE200);
代码流程
江丰鱼的BEB波浪尺代码
效果示意
BEB波浪尺效果示意图
完整代码
{先做筛选再用该算法}
TE2:=CONST(PEAKBARS(1,F,W+1));
TE1:=CONST(PEAKBARS(1,F,W));
TB2:=CONST(TROUGHBARS(2,G,W+1));
TB1:=CONST(TROUGHBARS(2,G,W));
RE1:=IF(CURRBARSCOUNT<=TE1+1 AND RANGE(TE1,TB1,TB2),CONST(PEAK(1,F,W)),DRAWNULL);
RB2:=IF(CURRBARSCOUNT<=TB2+1,CONST(TROUGH(2,G,W+1)),DRAWNULL);
RB1:IF(CURRBARSCOUNT<=TB1+1 AND RB2<CONST(TROUGH(2,G,W)),CONST(TROUGH(2,G,W)),DRAWNULL),COLORYELLOW;
DRAWLINE(CURRBARSCOUNT=CONST(BARSLAST(H=RE1))+1,H,CURRBARSCOUNT=CONST(BARSLAST(L=RB1))+1,L,0),COLORYELLOW;
DRAWLINE(CURRBARSCOUNT=CONST(BARSLAST(L=RB2))+1,L,CURRBARSCOUNT=CONST(BARSLAST(H=RE1))+1,H,0),COLORYELLOW;
DRAWTEXT(CURRBARSCOUNT=CONST(BARSLAST(H=RE1))+1 AND RANGE(TE1,TB1,TB2),H*1.003,’B’),COLORYELLOW;
DRAWTEXT(CURRBARSCOUNT=CONST(BARSLAST(L=RB1))+1,L*0.997,’C’),COLORYELLOW;
DRAWTEXT(CURRBARSCOUNT=CONST(BARSLAST(L=RB2))+1,L*0.997,’A’),COLORYELLOW;
RBE:=RE1-RB2;
RBE0382:RB1+RBE*0.382,DOTLINE;
RBE05:RB1+RBE*0.5,DOTLINE;
RBE0618:RB1+RBE*0.618,DOTLINE;
RBE100:RB1+RBE,COLORYELLOW;
RBE1382:RB1+RBE+RBE*0.382,DOTLINE;
RBE15:RB1+RBE+RBE*0.5,DOTLINE;
RBE1618:RB1+RBE+RBE*0.618,DOTLINE;
RBE200:RB1+RBE*2,COLORYELLOW;
STICKLINE(CURRBARSCOUNT=IF(INTPART((TB1+1)/2)=1,2,INTPART((TB1+1)/2)),RB1,RBE200,0,0),COLORYELLOW;
DRAWNUMBER(ISLASTBAR,RBE0382,RBE0382);
DRAWNUMBER(ISLASTBAR,RBE05,RBE05);
DRAWNUMBER(ISLASTBAR,RBE0618,RBE0618);
DRAWNUMBER(ISLASTBAR,RBE100,RBE100);
DRAWNUMBER(ISLASTBAR,RBE1382,RBE1382);
DRAWNUMBER(ISLASTBAR,RBE15,RBE15);
DRAWNUMBER(ISLASTBAR,RBE1618,RBE1618);
DRAWNUMBER(ISLASTBAR,RBE200,RBE200);
至此,波浪尺算法建立全部完成—后续会依照评论区的反馈进行相应的优化。
我的努力只为达成你的成功,赞赏是相伴前行的动力。
江丰鱼的文章只在今日头条首发,未经授权禁止引用和转载;文中代码均可运行。