这里选择了评论区网友的3个留言---也就是作业题了,给出简要的算法,以供大家批评。
第一题
第一道题
输出最近的4个峰值与4个谷值,用于数浪使用。
思路步骤
算法建立
1.
TE4:=CONST(PEAKBARS(1,转向比/10,第几个+3));
TE3:=CONST(PEAKBARS(1,转向比/10,第几个+2));
TE2:=CONST(PEAKBARS(1,转向比/10,第几个+1));
TE1:=CONST(PEAKBARS(1,转向比/10,第几个));
TB4:=CONST(TROUGHBARS(2,转向比/10,第几个+3));
TB3:=CONST(TROUGHBARS(2,转向比/10,第几个+2));
TB2:=CONST(TROUGHBARS(2,转向比/10,第几个+1));
TB1:=CONST(TROUGHBARS(2,转向比/10,第几个));
2.
DRAWICON(CURRBARSCOUNT=TE4+1,H*1.005,39);
DRAWICON(CURRBARSCOUNT=TE3+1,H*1.005,39);
DRAWICON(CURRBARSCOUNT=TE2+1,H*1.005,39);
DRAWICON(CURRBARSCOUNT=TE1+1,H*1.005,39);
DRAWICON(CURRBARSCOUNT=TB4+1,L*0.997,38);
DRAWICON(CURRBARSCOUNT=TB3+1,L*0.997,38);
DRAWICON(CURRBARSCOUNT=TB2+1,L*0.997,38);
DRAWICON(CURRBARSCOUNT=TB1+1,L*0.997,38);
三个参数
参数表
效果示意
效果示意
第二题
第二道题
20日内的涨停板的K线,在其开盘价与收盘价向右输出直线,一字板除外。
思路步骤
算法建立
{涨板向右画线}
1.
WZ1:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,20));{WZ 位置}
WZ2:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ1));
WZ3:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ2));
WZ4:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ3));
WZ5:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ4));
WZ6:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ5));
WZ7:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ6));
WZ8:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ7));
WZ9:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ8));
WZ10:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ9));
WZ11:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ10));
WZ12:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ11));
WZ13:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ12));
WZ14:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ13));
WZ15:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ14));
WZ16:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ15));
WZ17:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ16));
WZ18:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ17));
WZ19:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ18));
WZ20:=CONST(BARSSINCEN(C/REF(C,1)>=1.098,WZ19));
2.
WZ1O:IF(CURRBARSCOUNT<=WZ1+1,CONST(REF(O,WZ1)),DRAWNULL),COLORYELLOW;{O 开盘价}
WZ1C:IF(CURRBARSCOUNT<=WZ1+1,CONST(REF(C,WZ1)),DRAWNULL),COLORYELLOW;{C 收盘价}
WZ2O:IF(CURRBARSCOUNT<=WZ2+1,CONST(REF(O,WZ2)),DRAWNULL),COLORWHITE;
WZ2C:IF(CURRBARSCOUNT<=WZ2+1,CONST(REF(C,WZ2)),DRAWNULL),COLORWHITE;
WZ3O:IF(CURRBARSCOUNT<=WZ3+1,CONST(REF(O,WZ3)),DRAWNULL),COLORMAGENTA;
WZ3C:IF(CURRBARSCOUNT<=WZ3+1,CONST(REF(C,WZ3)),DRAWNULL),COLORMAGENTA;
WZ4O:IF(CURRBARSCOUNT<=WZ4+1,CONST(REF(O,WZ4)),DRAWNULL),COLORRED;
WZ4C:IF(CURRBARSCOUNT<=WZ4+1,CONST(REF(C,WZ4)),DRAWNULL),COLORRED;
WZ5O:IF(CURRBARSCOUNT<=WZ5+1,CONST(REF(O,WZ5)),DRAWNULL),COLORGREEN;
WZ5C:IF(CURRBARSCOUNT<=WZ5+1,CONST(REF(C,WZ5)),DRAWNULL),COLORGREEN;
WZ6O:IF(CURRBARSCOUNT<=WZ6+1,CONST(REF(O,WZ6)),DRAWNULL),COLORBLUE;
WZ6C:IF(CURRBARSCOUNT<=WZ6+1,CONST(REF(C,WZ6)),DRAWNULL),COLORBLUE;
WZ7O:IF(CURRBARSCOUNT<=WZ7+1,CONST(REF(O,WZ7)),DRAWNULL),COLORYELLOW;
WZ7C:IF(CURRBARSCOUNT<=WZ7+1,CONST(REF(C,WZ7)),DRAWNULL),COLORYELLOW;
WZ8O:IF(CURRBARSCOUNT<=WZ8+1,CONST(REF(O,WZ8)),DRAWNULL),COLORWHITE;
WZ8C:IF(CURRBARSCOUNT<=WZ8+1,CONST(REF(C,WZ8)),DRAWNULL),COLORWHITE;
WZ9O:IF(CURRBARSCOUNT<=WZ9+1,CONST(REF(O,WZ9)),DRAWNULL),COLORMAGENTA;
WZ9C:IF(CURRBARSCOUNT<=WZ9+1,CONST(REF(C,WZ9)),DRAWNULL),COLORMAGENTA;
WZ10O:IF(CURRBARSCOUNT<=WZ10+1,CONST(REF(O,WZ10)),DRAWNULL),COLORRED;
WZ10C:IF(CURRBARSCOUNT<=WZ10+1,CONST(REF(C,WZ10)),DRAWNULL),COLORRED;
WZ11O:IF(CURRBARSCOUNT<=WZ11+1,CONST(REF(O,WZ11)),DRAWNULL),COLORGREEN;
WZ11C:IF(CURRBARSCOUNT<=WZ11+1,CONST(REF(C,WZ11)),DRAWNULL),COLORGREEN;
WZ12O:IF(CURRBARSCOUNT<=WZ12+1,CONST(REF(O,WZ12)),DRAWNULL),COLORBLUE;
WZ12C:IF(CURRBARSCOUNT<=WZ12+1,CONST(REF(C,WZ12)),DRAWNULL),COLORBLUE;
WZ13O:IF(CURRBARSCOUNT<=WZ13+1,CONST(REF(O,WZ13)),DRAWNULL),COLORYELLOW;
WZ13C:IF(CURRBARSCOUNT<=WZ13+1,CONST(REF(C,WZ13)),DRAWNULL),COLORYELLOW;
WZ14O:IF(CURRBARSCOUNT<=WZ14+1,CONST(REF(O,WZ14)),DRAWNULL),COLORWHITE;
WZ14C:IF(CURRBARSCOUNT<=WZ14+1,CONST(REF(C,WZ14)),DRAWNULL),COLORWHITE;
WZ15O:IF(CURRBARSCOUNT<=WZ15+1,CONST(REF(O,WZ15)),DRAWNULL),COLORMAGENTA;
WZ15C:IF(CURRBARSCOUNT<=WZ15+1,CONST(REF(C,WZ15)),DRAWNULL),COLORMAGENTA;
WZ16O:IF(CURRBARSCOUNT<=WZ16+1,CONST(REF(O,WZ16)),DRAWNULL),COLORRED;
WZ16C:IF(CURRBARSCOUNT<=WZ16+1,CONST(REF(C,WZ16)),DRAWNULL),COLORRED;
WZ17O:IF(CURRBARSCOUNT<=WZ17+1,CONST(REF(O,WZ17)),DRAWNULL),COLORGREEN;
WZ17C:IF(CURRBARSCOUNT<=WZ17+1,CONST(REF(C,WZ17)),DRAWNULL),COLORGREEN;
WZ18O:IF(CURRBARSCOUNT<=WZ18+1,CONST(REF(O,WZ18)),DRAWNULL),COLORBLUE;
WZ18C:IF(CURRBARSCOUNT<=WZ18+1,CONST(REF(C,WZ18)),DRAWNULL),COLORBLUE;
WZ19O:IF(CURRBARSCOUNT<=WZ19+1,CONST(REF(O,WZ19)),DRAWNULL),COLORGREEN;
WZ19C:IF(CURRBARSCOUNT<=WZ19+1,CONST(REF(C,WZ19)),DRAWNULL),COLORGREEN;
WZ20O:IF(CURRBARSCOUNT<=WZ20+1,CONST(REF(O,WZ20)),DRAWNULL),COLORBLUE;
WZ20C:IF(CURRBARSCOUNT<=WZ20+1,CONST(REF(C,WZ20)),DRAWNULL),COLORBLUE;
效果示意
效果示意
第三题
第三道题
在股价上穿MACD最低柱对应的最低价格时,进行数据筛选。
思路步骤
算法建立
原有的参数表
原有的参数表
原有的算法代码,全部赋值:
DIF:=EMA(CLOSE,SHORT)-EMA(CLOSE,LONG);
DEA:=EMA(DIF,MID);
MACD:=(DIF-DEA)*2;
2. 求出昨天的MACD小于0而今天的MACD大于0时,至今天最近的时间距离:
昨天:=CONST(BARSLAST(CONST(MACD)>0 AND REF(MACD,1)<0));
3.昨天发生这样的条件发生,则距今天时间距离为0:
昨天=0;
计算创造价值,分享助你成功。
江丰鱼的文章只在今日头条首发;文中代码均可运行。
联系客服