黄金分割曲线

本文应用手动取数的方法绘制黄金分割线,请看留言截图:

网友的留言


(资料图片仅供参考)

网友的思路需求是:建立 一个同花顺黄金分割主图标注算法。

(一)、思路步骤:

1.通过变量参数E点、B点,取得对应时间位置的数值;

2.进行黄金分割线的计算;

3.绘制黄金分割曲线。

(二)、算法的建立过程:

1.手动取得对应高点值与低点值

BH: IF ( CURRBARSCOUNT <=B点+ 1 , CONST ( REF ( H ,B点)), DRAWNULL );

CC: IF ( CURRBARSCOUNT <=B点+ 1 , CONST ( REF ( L ,E点)), DRAWNULL );

2.计算并输出相应的黄金分割曲线值

BH0809: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线< 0 ,BH* 0.809 , DRAWNULL ), colorred , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,BH0809,BH0809), colorred ;

DRAWTEXT ( CURRBARSCOUNT =B点,BH0809* 1.005 , "80.9%" ), colorred ;

BH0618: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线<- 1 ,BH* 0.618 , DRAWNULL ), colorred , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,BH0618,BH0618), colorred ;

DRAWTEXT ( CURRBARSCOUNT =B点,BH0618* 1.005 , "61.8%" ), colorred ;

BH050: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线<- 2 ,BH* 0.5 , DRAWNULL ), colorred , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,BH050,BH050), colorred ;

DRAWTEXT ( CURRBARSCOUNT =B点,BH050* 1.005 , "50%" ), colorred ;

BH0382: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线<- 3 ,BH* 0.382 , DRAWNULL ), colorred , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,BH0382,BH0382), colorred ;

DRAWTEXT ( CURRBARSCOUNT =B点,BH0382* 1.005 , "38.2%" ), colorred ;

BH0236: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线<- 4 ,BH* 0.236 , DRAWNULL ), colorred , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,BH0236,BH0236), colorred ;

DRAWTEXT ( CURRBARSCOUNT =B点,BH0236* 1.005 , "23.6%" ), colorred ;

BH0191: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线<- 4 ,BH* 0.191 , DRAWNULL ), colorred , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,BH0191,BH0191), colorred ;

DRAWTEXT ( CURRBARSCOUNT =B点,BH0191* 1.005 , "19.1%" ), colorred ;

CC200: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线>5 ,CC* 2 , DRAWNULL ), colorgreen , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,CC200,CC200), colorgreen ;

DRAWTEXT ( CURRBARSCOUNT =B点,CC200* 1.005 , "200%" ), colorgreen ;

CC1809: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线>4 ,CC* 1.809 , DRAWNULL ), colorgreen , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,CC1809,CC1809), colorgreen ;

DRAWTEXT ( CURRBARSCOUNT =B点,CC1809* 1.005 , "180.9%" ), colorgreen ;

CC1618: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线>3 ,CC* 1.618 , DRAWNULL ), colorgreen , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,CC1618,CC1618), colorgreen ;

DRAWTEXT ( CURRBARSCOUNT =B点,CC1618* 1.005 , "161.8%" ), colorgreen ;

CC150: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线>2 ,CC* 1.5 , DRAWNULL ), colorgreen , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,CC150,CC150), colorgreen ;

DRAWTEXT ( CURRBARSCOUNT =B点,CC150* 1.005 , "150%" ), colorgreen ;

CC1382: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线>1 ,CC* 1.382 , DRAWNULL ), colorgreen , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,CC1382,CC1382), colorgreen ;

DRAWTEXT ( CURRBARSCOUNT =B点,CC1382* 1.005 , "138.2%" ), colorgreen ;

CC1236: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线>0 ,CC* 1.236 , DRAWNULL ), colorgreen , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,CC1236,CC1236), colorgreen ;

DRAWTEXT ( CURRBARSCOUNT =B点,CC1236* 1.005 , "123.6%" ), colorgreen ;

(三)、完整代码:

代码流程

BH:IF(CURRBARSCOUNT<=B点+1,CONST(REF(H,B点)),DRAWNULL);

CC:IF(CURRBARSCOUNT<=B点+1,CONST(REF(L,E点)),DRAWNULL);

BH0809:IF(CURRBARSCOUNT<=B点+1 AND 黄金线<0,BH*0.809,DRAWNULL),colorred,DOTLINE;

DRAWNUMBER(ISLASTBAR,BH0809,BH0809),colorred;

DRAWTEXT(CURRBARSCOUNT=B点,BH0809*1.005,"80.9%"),colorred;

BH0618:IF(CURRBARSCOUNT<=B点+1 AND 黄金线<-1,BH*0.618,DRAWNULL),colorred,DOTLINE;

DRAWNUMBER(ISLASTBAR,BH0618,BH0618),colorred;

DRAWTEXT(CURRBARSCOUNT=B点,BH0618*1.005,"61.8%"),colorred;

BH050:IF(CURRBARSCOUNT<=B点+1 AND 黄金线<-2,BH*0.5,DRAWNULL),colorred,DOTLINE;

DRAWNUMBER(ISLASTBAR,BH050,BH050),colorred;

DRAWTEXT(CURRBARSCOUNT=B点,BH050*1.005,"50%"),colorred;

BH0382:IF(CURRBARSCOUNT<=B点+1 AND 黄金线<-3,BH*0.382,DRAWNULL),colorred,DOTLINE;

DRAWNUMBER(ISLASTBAR,BH0382,BH0382),colorred;

DRAWTEXT(CURRBARSCOUNT=B点,BH0382*1.005,"38.2%"),colorred;

BH0236:IF(CURRBARSCOUNT<=B点+1 AND 黄金线<-4,BH*0.236,DRAWNULL),colorred,DOTLINE;

DRAWNUMBER(ISLASTBAR,BH0236,BH0236),colorred;

DRAWTEXT(CURRBARSCOUNT=B点,BH0236*1.005,"23.6%"),colorred;

BH0191:IF(CURRBARSCOUNT<=B点+1 AND 黄金线<-4,BH*0.191,DRAWNULL),colorred,DOTLINE;

DRAWNUMBER(ISLASTBAR,BH0191,BH0191),colorred;

DRAWTEXT(CURRBARSCOUNT=B点,BH0191*1.005,"19.1%"),colorred;

CC200:IF(CURRBARSCOUNT<=B点+1 AND 黄金线>5,CC*2,DRAWNULL),colorgreen,DOTLINE;

DRAWNUMBER(ISLASTBAR,CC200,CC200),colorgreen;

DRAWTEXT ( CURRBARSCOUNT =B点,CC200* 1.005 , "200%" ), colorgreen ;

CC1809: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线>4 ,CC* 1.809 , DRAWNULL ), colorgreen , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,CC1809,CC1809), colorgreen ;

DRAWTEXT ( CURRBARSCOUNT =B点,CC1809* 1.005 , "180.9%" ), colorgreen ;

CC1618: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线>3 ,CC* 1.618 , DRAWNULL ), colorgreen , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,CC1618,CC1618), colorgreen ;

DRAWTEXT ( CURRBARSCOUNT =B点,CC1618* 1.005 , "161.8%" ), colorgreen ;

CC150: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线>2 ,CC* 1.5 , DRAWNULL ), colorgreen , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,CC150,CC150), colorgreen ;

DRAWTEXT ( CURRBARSCOUNT =B点,CC150* 1.005 , "150%" ), colorgreen ;

CC1382: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线>1 ,CC* 1.382 , DRAWNULL ), colorgreen , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,CC1382,CC1382), colorgreen ;

DRAWTEXT ( CURRBARSCOUNT =B点,CC1382* 1.005 , "138.2%" ), colorgreen ;

CC1236: IF ( CURRBARSCOUNT <=B点+ 1 AND 黄金线>0 ,CC* 1.236 , DRAWNULL ), colorgreen , DOTLINE ;

DRAWNUMBER ( ISLASTBAR ,CC1236,CC1236), colorgreen ;

DRAWTEXT ( CURRBARSCOUNT =B点,CC1236* 1.005 , "123.6%" ), colorgreen ;

(四)、效果示意图:

效果示意图

关键词:

推荐DIY文章
主机存在磨损或划痕风险 PICO4便携包宣布召回
穿越湖海!特斯拉Cybertruck电动皮卡可以当“船”用
vivoXFold+折叠旗舰开售 配备蔡司全焦段旗舰四摄
飞凡R7正式上市 全系标配换电架构
中兴Axon30S开售 拥有黑色蓝色两款配色
荣耀MagicBookV14 2022正式开售 搭载TOF传感器
it