以下是通达信黄金法则源码(无源码的请下载附件导入)
{公式名称: 黄金法则
公式描述: 张GL作品;黄金法则;
参数数量: 2
参数1: T, 最小: 0, 最大: 150, 缺省: 30
参数2: K, 最小: 0, 最大: 1, 缺省: 0
公式类型: 技术指标公式-图表型
画线方法: 主图叠加
公式版本: 0
显示小数: 缺省位数
坐标线位置: 自动
额外Y轴分界: 无
参数精灵:
请设置计算参数:
T: Param#0 (0.00--150.00)
K: Param#1 (0.00--1.00)
用法注释:
黄金法则:
————————————————————————;
本公式与撑压线为一母双胎指标;都是以缠论高点母本;
本指标是撑压线的简化指标;
与撑压线不同的是:
1.去掉撑压线划线指标;
2.增加单阳测顶与单阴测底;
————————————————————————;
本指标包含以下五大功能(废除两项):
————————————————————————;
一:黄金分割(自动判断是下跌还是上涨):
1.黄金分割有两种算法,一种用高低区间;一种用低位算法;
2.本公式采用高低区间算法,具体如下:
高位下跌:a:计算高位和前低位的区间;
b:H-区间*黄金分割点;
低位上涨:a:计算低位和前高位的区间;
b:L+区间*黄金分割点;
高位下跌为浅粉红色;
低位上涨为浅姜黄色;
————————————————————————;
即下跌有;高位下跌的黄金分割;
上涨也有;低位上涨的黄金分割;
————————————————————————;
二:十等分(废除);
————————————————————————;
三:单阴测底与单阳测顶(参数写死,不能修改);
采用徐小明的算法:进行测算;
大盘采用正负3%为模;参数:X;
个股采用正负6%为模;参数:Y;
取模周期为低点5T天;参数:D;
总周期为30T, 参数:T;
**参数k可以设置是否显示:1显示,0隐藏**
————————————————————————;
四:高低点提示(废除):
1.灰色横线:高点压力低点支撑;
2.白色数字:高低点价格;
高低点线可以看出中枢(箱体)上下沿;
————————————————————————;
五:集成简化版九转提示:
黄点:九转“8”;
笑脸哭脸:九转“9”;
……;
—————————————————————————————;
2016-7-23日更新:
1.去除黄金分割的多余显示;即显示低位,前面显示高位的标志-竖线;
2.增加参数K;设置是否显示单阳测顶,单阴测底;
3.增加显示多转显示,默认18,即重点显示9-13-18;
—————————————————————————————;
公式源码:}
X_1:=BACKSET(LLV(LOW,5)<REF(LLV(LOW,4),1),4);
X_2:=BACKSET(X_1=0 AND REF(X_1,1)=1,2);
X_3:=IF(X_2=1 AND REF(X_2,1)=0,(-1),0);
X_4:=BACKSET(HHV(HIGH,5)>REF(HHV(HIGH,4),1),4);
X_5:=BACKSET(X_4=0 AND REF(X_4,1)=1,2);
X_6:=IF(X_5=1 AND REF(X_5,1)=0,1,0);
X_7:=IF(LOW>REF(HIGH,1),1,IF(HIGH<REF(LOW,1),(-1),0));
X_8:=BARSLAST(X_6=1);
X_9:=BARSLAST(X_3=(-1));
X_10:=LOWRANGE(LOW);
X_11:=TOPRANGE(HIGH);
X_12:=IF(X_3=(-1) AND REF(X_8,1)>REF(X_9,1) AND LLV(LOW,X_8+1)<REF(LLV(LOW,X_8+1),1),(-1),0);
X_13:=IF(X_3=(-1) AND REF(X_8,1)<=REF(X_9,1) AND (X_8>=4 OR LLV(X_7,X_8)=(-1) OR LLV(LOW,X_9+2)<REF(LLV(LOW,X_9+1),1)),(-1),0);
X_14:=IF(X_12=(-1) OR X_13=(-1) AND LOW<REF(HIGH,X_8+1),(-1),0);
X_15:=IF(X_9<4 AND HHV(X_7,X_9)!=1 OR REF(X_14,X_9)=0,1,0);
X_16:=IF(X_6=1 AND REF(X_9,1)<=REF(X_8,1) AND X_15=1 AND X_11>REF(X_10,X_9+1) AND X_11>REF(X_10,X_9) AND X_11>REF(X_11,X_8),1,0);
X_17:=IF(X_6=1 AND REF(X_9,1)>REF(X_8,1) AND HHV(HIGH,X_9+1)>REF(HHV(HIGH,X_9+1),1),1,0);
X_18:=IF(X_6=1 AND REF(X_9,1)<=REF(X_8,1) AND REF(X_14,X_9)=(-1) AND (X_9>=4 OR HHV(X_7,X_9)=1),1,0);
X_19:=IF(X_17=1 OR X_18=1 OR X_16=1 AND HIGH>REF(LOW,X_9+1),1,0);
X_20:=IF(X_8<4 AND HHV(X_7,X_8)!=1 OR REF(X_19,X_8)=0,1,0);
X_21:=IF(X_3=(-1) AND REF(X_8,1)<=REF(X_9,1) AND X_20=1 AND X_10>REF(X_11,X_8+1) AND X_10>REF(X_11,X_8) AND X_10>REF(X_10,X_9),(-1),0);
X_22:=IF(X_3=(-1) AND REF(X_8,1)>REF(X_9,1) AND LLV(LOW,X_8+1)<REF(LLV(LOW,X_8+1),1),(-1),0);
X_23:=IF(X_3=(-1) AND REF(X_8,1)<=REF(X_9,1) AND (X_8>=4 OR LLV(X_7,X_8)=(-1) OR X_21=(-1)),(-1),0);
X_24:=IF(X_22=(-1) OR X_23=(-1) AND LOW<REF(HIGH,X_8+1),(-1),0);
X_25:=BARSLAST(X_19=1);
X_26:=BARSLAST(X_24=(-1));
X_27:=IF(X_26<4 AND HHV(X_7,X_26)!=1 OR REF(X_24,X_26)=0,1,0);
X_28:=IF(X_6=1 AND REF(X_26,1)<=REF(X_25,1) AND X_27=1 AND X_11>REF(X_10,X_26+1) AND X_11>REF(X_10,X_26) AND X_11>REF(X_11,X_25),1,0);
X_29:=IF(X_6=1 AND REF(X_26,1)>REF(X_25,1) AND HHV(HIGH,X_26+1)>REF(HHV(HIGH,X_26+1),1),1,0);
X_30:=IF(X_6=1 AND REF(X_26,1)<=REF(X_25,1) AND REF(X_24,X_26)=(-1) AND (X_26>=4 OR HHV(X_7,X_26)=1),1,0);
X_31:=IF(X_29=1 OR X_30=1 OR X_28=1 AND HIGH>REF(LOW,X_26+1),1,0);
X_32:=IF(X_25<4 AND HHV(X_7,X_25)!=1 OR REF(X_29,X_25)=0,1,0);
X_33:=IF(X_3=(-1) AND REF(X_25,1)<=REF(X_26,1) AND X_32=1 AND X_10>REF(X_11,X_25+1) AND X_10>REF(X_11,X_25) AND X_10>REF(X_10,X_26),(-1),0);
X_34:=IF(X_3=(-1) AND REF(X_25,1)>REF(X_26,1) AND LLV(LOW,X_25+1)<REF(LLV(LOW,X_25+1),1),(-1),0);
X_35:=IF(X_3=(-1) AND REF(X_25,1)<=REF(X_26,1) AND (X_25>=4 OR LLV(X_7,X_25)=(-1) OR X_33=(-1)),(-1),0);
X_36:=IF(X_34=(-1) OR X_35=(-1) AND LOW<REF(HIGH,X_25+1),(-1),0);
X_37:=BARSLAST(X_31=1);
X_38:=BARSLAST(X_36=(-1));
X_39:=IF(X_38<4 AND HHV(X_7,X_38)!=1 OR REF(X_36,X_38)=0,1,0);
X_40:=IF(X_6=1 AND REF(X_38,1)<=REF(X_37,1) AND X_39=1 AND X_11>REF(X_10,X_38+1) AND X_11>REF(X_10,X_38) AND X_11>REF(X_11,X_37),1,0);
X_41:=IF(X_6=1 AND REF(X_38,1)>REF(X_37,1) AND HHV(HIGH,X_38+1)>REF(HHV(HIGH,X_38+1),1),1,0);
X_42:=IF(X_6=1 AND REF(X_38,1)<=REF(X_37,1) AND REF(X_36,X_38)=(-1) AND (X_38>=4 OR HHV(X_7,X_38)=1),1,0);
X_43:=IF(X_41=1 OR X_42=1 OR X_40=1 AND HIGH>REF(LOW,X_38+1),1,0);
X_44:=IF(X_37<4 AND HHV(X_7,X_37)!=1 OR REF(X_41,X_37)=0,1,0);
X_45:=IF(X_3=(-1) AND REF(X_37,1)<=REF(X_38,1) AND X_44=1 AND X_10>REF(X_11,X_37+1) AND X_10>REF(X_11,X_37) AND X_10>REF(X_10,X_38),(-1),0);
X_46:=IF(X_3=(-1) AND REF(X_37,1)>REF(X_38,1) AND LLV(LOW,X_37+1)<REF(LLV(LOW,X_37+1),1),(-1),0);
X_47:=IF(X_3=(-1) AND REF(X_37,1)<=REF(X_38,1) AND (X_37>=4 OR LLV(X_7,X_37)=(-1) OR X_45=(-1)),(-1),0);
X_48:=IF(X_46=(-1) OR X_47=(-1) AND LOW<REF(HIGH,X_37+1),(-1),0);
X_49:=IF(X_43=1 AND X_48=(-1) AND HIGH>REF(HIGH,REF(X_37,1)+2),1,IF(X_43=1 AND X_48=(-1) AND LOW<REF(LOW,REF(X_38,1)+2),(-1),0));
X_50:=IF(X_49=0,X_43+X_48,X_49);
X_51:=IF(DATE<1161215,1,0);
X_52:=IF(X_50=(-1),LOW,IF(X_50=1,HIGH,DRAWNULL));
X_53:=DRAWLINE(X_50=(-1),X_52,X_50=1,X_52,0);
X_54:=DRAWLINE(X_50=1,X_52,X_50=(-1),X_52,0);
X_55:=X_53=X_54 AND X_4 AND X_50=1;
X_56:=IF(X_55,HIGH*X_51,DRAWNULL);
X_57:=X_53=X_54 AND X_1 AND X_50=(-1);
X_58:=IF(X_57,LOW*X_51,DRAWNULL);
X_59:=LLV(LOW,T)=X_58*X_51;
X_60:=BARSLAST(X_59);
X_61:=HHV(HIGH,T)=X_56*X_51;
X_62:=BARSLAST(X_61);
X_63:=IF(X_62>X_60,0,1);
X_64:=BACKSET(ISLASTBAR,X_62+1);
X_65:=BARSLAST(X_64=1 AND REF(X_64,1)=0);
X_66:=BACKSET(ISLASTBAR,X_60+1);
X_67:=BARSLAST(X_66=1 AND REF(X_66,1)=0);
X_68:=IF(X_65>X_67,0,1);
X_69:=IF(X_63=0 AND X_68=0,REF(HIGH,X_62)-REF(LOW,X_60),DRAWNULL);
STICKLINE(X_66=1 AND REF(X_66,1)=0 AND X_63=0 AND X_68=0,REF(LOW,X_60),REF(LOW,X_60)+X_69*1,0.5,(-1)),COLOR0065CA;
NOTEXT0:IF(X_63=0 AND X_68=0,DRAWLINE(X_59,LOW,ISLASTBAR,REF(LOW,X_60)+X_69*0,(-1)),DRAWNULL),DOTLINE,COLOR0065CA;
DRAWNUMBER(ISLASTBAR AND X_63=0 AND X_68=0,NOTEXT0,REF(LOW,X_60)),COLOR0065CA;
DRAWNUMBER(X_59 AND X_63=0 AND X_68=0,NOTEXT0,0),COLOR0065CA;
NOTEXT1:IF(X_63=0 AND X_68=0,DRAWLINE(X_59,LOW+X_69*0.191,ISLASTBAR,REF(LOW,X_60)+X_69*0.191,(-1)),DRAWNULL),DOTLINE,COLOR0065CA;
DRAWNUMBER(ISLASTBAR AND X_63=0 AND X_68=0,NOTEXT1,REF(LOW,X_60)+X_69*0.191),COLOR0065CA;
DRAWNUMBER(X_59 AND X_63=0 AND X_68=0,NOTEXT1,0.191),COLOR0065CA;
NOTEXT3:IF(X_63=0 AND X_68=0,DRAWLINE(X_59,LOW+X_69*0.382,ISLASTBAR,REF(LOW,X_60)+X_69*0.382,(-1)),DRAWNULL),DOTLINE,COLOR0065CA;
DRAWNUMBER(ISLASTBAR AND X_63=0 AND X_68=0,NOTEXT3,REF(LOW,X_60)+X_69*0.382),COLOR0065CA;
DRAWNUMBER(X_59 AND X_63=0 AND X_68=0,NOTEXT3,0.382),COLOR0065CA;
NOTEXT5:IF(X_63=0 AND X_68=0,DRAWLINE(X_59,LOW+X_69*0.5,ISLASTBAR,REF(LOW,X_60)+X_69*0.5,(-1)),DRAWNULL),DOTLINE,COLOR0065CA;
DRAWNUMBER(ISLASTBAR AND X_63=0 AND X_68=0,NOTEXT5,REF(LOW,X_60)+X_69*0.5),COLOR0065CA;
DRAWNUMBER(X_59 AND X_63=0 AND X_68=0,NOTEXT5,0.5),COLOR0065CA;
NOTEXT6:IF(X_63=0 AND X_68=0,DRAWLINE(X_59,LOW+X_69*0.618,ISLASTBAR,REF(LOW,X_60)+X_69*0.618,(-1)),DRAWNULL),DOTLINE,COLOR0065CA;
DRAWNUMBER(ISLASTBAR AND X_63=0 AND X_68=0,NOTEXT6,REF(LOW,X_60)+X_69*0.618),COLOR0065CA;
DRAWNUMBER(X_59 AND X_63=0 AND X_68=0,NOTEXT6,0.618),COLOR0065CA;
NOTEXT8:IF(X_63=0 AND X_68=0,DRAWLINE(X_59,LOW+X_69*0.809,ISLASTBAR,REF(LOW,X_60)+X_69*0.809,(-1)),DRAWNULL),DOTLINE,COLOR0065CA;
DRAWNUMBER(ISLASTBAR AND X_63=0 AND X_68=0,NOTEXT8,REF(LOW,X_60)+X_69*0.809),COLOR0065CA;
DRAWNUMBER(X_59 AND X_63=0 AND X_68=0,NOTEXT8,0.809),COLOR0065CA;
NOTEXT2:IF(X_63=0 AND X_68=0,DRAWLINE(X_59,REF(HIGH,X_62),ISLASTBAR,REF(LOW,X_60)+X_69*1,(-1)),DRAWNULL),DOTLINE,COLOR0065CA;
DRAWNUMBER(ISLASTBAR AND X_63=0 AND X_68=0,NOTEXT2,REF(LOW,X_60)+X_69*1),COLOR0065CA;
DRAWNUMBER(X_59 AND X_63=0 AND X_68=0,NOTEXT2,1),COLOR0065CA;
X_70:=IF(X_63=1 AND X_68=1,REF(HIGH,X_62)-REF(LOW,X_60),DRAWNULL);
STICKLINE(X_64=1 AND REF(X_64,1)=0 AND X_63=1 AND X_68=1,REF(HIGH,X_62),REF(HIGH,X_62)-X_70*1,0.5,(-1)),COLORC080FF;
NOTEXTH0:IF(X_63=1 AND X_68=1,DRAWLINE(X_61,HIGH,ISLASTBAR,REF(HIGH,X_62)-X_70*0,(-1)),DRAWNULL),DOTLINE,COLORC080FF;
DRAWNUMBER(ISLASTBAR AND X_63=1 AND X_68=1,NOTEXTH0,REF(HIGH,X_62)),COLORC080FF;
DRAWNUMBER(X_61 AND X_63=1 AND X_68=1,NOTEXTH0,0),COLORC080FF;
NOTEXTH1:IF(X_63=1 AND X_68=1,DRAWLINE(X_61,HIGH-X_70*0.191,ISLASTBAR,REF(HIGH,X_62)-X_70*0.191,(-1)),DRAWNULL),DOTLINE,COLORC080FF;
DRAWNUMBER(ISLASTBAR AND X_63=1 AND X_68=1,NOTEXTH1,REF(HIGH,X_62)-X_70*0.191),COLORC080FF;
DRAWNUMBER(X_61 AND X_63=1 AND X_68=1,NOTEXTH1,0.191),COLORC080FF;
NOTEXTH3:IF(X_63=1 AND X_68=1,DRAWLINE(X_61,HIGH-X_70*0.382,ISLASTBAR,REF(HIGH,X_62)-X_70*0.382,(-1)),DRAWNULL),DOTLINE,COLORC080FF;
DRAWNUMBER(ISLASTBAR AND X_63=1 AND X_68=1,NOTEXTH3,REF(HIGH,X_62)-X_70*0.382),COLORC080FF;
DRAWNUMBER(X_61 AND X_63=1 AND X_68=1,NOTEXTH3,0.382),COLORC080FF;
NOTEXTH5:IF(X_63=1 AND X_68=1,DRAWLINE(X_61,HIGH-X_70*0.5,ISLASTBAR,REF(HIGH,X_62)-X_70*0.5,(-1)),DRAWNULL),DOTLINE,COLORC080FF;
DRAWNUMBER(ISLASTBAR AND X_63=1 AND X_68=1,NOTEXTH5,REF(HIGH,X_62)-X_70*0.5),COLORC080FF;
DRAWNUMBER(X_61 AND X_63=1 AND X_68=1,NOTEXTH5,0.5),COLORC080FF;
NOTEXTH6:IF(X_63=1 AND X_68=1,DRAWLINE(X_61,HIGH-X_70*0.618,ISLASTBAR,REF(HIGH,X_62)-X_70*0.618,(-1)),DRAWNULL),DOTLINE,COLORC080FF;
DRAWNUMBER(ISLASTBAR AND X_63=1 AND X_68=1,NOTEXTH6,REF(HIGH,X_62)-X_70*0.618),COLORC080FF;
DRAWNUMBER(X_61 AND X_63=1 AND X_68=1,NOTEXTH6,0.618),COLORC080FF;
NOTEXTH8:IF(X_63=1 AND X_68=1,DRAWLINE(X_61,HIGH-X_70*0.809,ISLASTBAR,REF(HIGH,X_62)-X_70*0.809,(-1)),DRAWNULL),DOTLINE,COLORC080FF;
DRAWNUMBER(ISLASTBAR AND X_63=1 AND X_68=1,NOTEXTH8,REF(HIGH,X_62)-X_70*0.809),COLORC080FF;
DRAWNUMBER(X_61 AND X_63=1 AND X_68=1,NOTEXTH8,0.809),COLORC080FF;
NOTEXTH2:IF(X_63=1 AND X_68=1,DRAWLINE(X_61,REF(HIGH,X_62)-X_70*1,ISLASTBAR,REF(HIGH,X_62)-X_70*1,(-1)),DRAWNULL),DOTLINE,COLORC080FF;
DRAWNUMBER(ISLASTBAR AND X_63=1 AND X_68=1,NOTEXTH2,REF(HIGH,X_62)-X_70*1),COLORC080FF;
DRAWNUMBER(X_61 AND X_63=1 AND X_68=1,NOTEXTH2,1),COLORC080FF;
X_71:=3;
X_72:=3;
X_73:=5;
X_74:=IF(CLOSE>500,X_71,X_72);
X_75:=(CLOSE-REF(CLOSE,1))/REF(CLOSE,1)*100;
X_76:=IF(X_60<=X_73,HHV(X_75,X_60+1),DRAWNULL);
X_77:=IF(X_60<=X_73,HHVBARS(X_75,X_60+1),DRAWNULL);
X_78:=IF(REF(X_75,X_77)>=X_74,REF(CLOSE,X_77)*REF(CLOSE,X_77)/REF(CLOSE,X_77+1)/0.9,DRAWNULL);
X_79:=BACKSET(REF(X_75,X_77)>=X_74 AND X_60<=X_73,X_77+1);
X_80:=BARSLAST(X_79=1 AND REF(X_79,1)=0);
X_81:=BACKSET(ISLASTBAR,X_80+1);
STICKLINE(X_81=1 AND REF(X_81,1)=0 AND K=1,HIGH,X_78,0.5,(-1)),COLORYELLOW;
NOTEXT测顶:IF(K=1,DRAWLINE(X_81=1 AND REF(X_81,1)=0,X_78,ISLASTBAR,REF(CLOSE,X_80)*REF(CLOSE,X_80)/REF(CLOSE,X_80+1)/0.9,(-2)),DRAWNULL),DOTLINE,COLORYELLOW;
DRAWNUMBER(X_81=1 AND REF(X_81,1)=0 AND K=1,X_78,X_78),COLORYELLOW;
X_82:=IF(X_62<=X_73,LLV(X_75,X_62+1),DRAWNULL);
X_83:=IF(X_62<=X_73,LLVBARS(X_75,X_62+1),DRAWNULL);
X_84:=IF(REF(X_75,X_83)<=(-X_74),REF(CLOSE,X_83)*REF(CLOSE,X_83)/REF(CLOSE,X_83+1)/1.1,DRAWNULL);
X_85:=BACKSET(REF(X_75,X_83)<=(-X_74) AND X_62<=X_73,X_83+1);
X_86:=BARSLAST(X_85=1 AND REF(X_85,1)=0);
X_87:=BACKSET(ISLASTBAR,X_86+1);
STICKLINE(X_87=1 AND REF(X_87,1)=0 AND K=1,LOW,X_84,0.5,(-1)),COLORCYAN;
NOTEXT测底:IF(K=1,DRAWLINE(X_87=1 AND REF(X_87,1)=0,X_84,ISLASTBAR,REF(CLOSE,X_86)*REF(CLOSE,X_86)/REF(CLOSE,X_86+1)/1.1,(-2)),DRAWNULL),DOTLINE,COLORCYAN;
DRAWNUMBER(X_87=1 AND REF(X_87,1)=0 AND K=1,X_84,X_84),COLORCYAN;
X_88:=CLOSE>REF(CLOSE,4);
X_89:=BARSLASTCOUNT(X_88);
X_90:=X_89=18;
X_91:=ISLASTBAR AND BETWEEN(X_89,1,17);
X_92:=(BACKSET(X_90>0,18) OR BACKSET(X_91>0,X_89))*X_89;
DRAWNUMBER(X_92>0,HIGH*1.02,X_92),COLORMAGENTA;
DRAWNUMBER(X_89=9,HIGH*1.02,9),COLORGREEN;
DRAWNUMBER(X_89=13,HIGH*1.02,13),COLORYELLOW;
DRAWNUMBER(X_89=18,HIGH*1.02,18),COLORYELLOW;
DRAWICON(X_89=8,HIGH*1.01,41);
X_93:=CLOSE<REF(CLOSE,4);
X_94:=BARSLASTCOUNT(X_93);
X_95:=X_94=18;
X_96:=ISLASTBAR AND BETWEEN(X_94,1,17);
X_97:=(BACKSET(X_95>0,18) OR BACKSET(X_96>0,X_94))*X_94;
DRAWNUMBER(X_97>0,LOW*0.98,X_97),COLORMAGENTA;
DRAWNUMBER(X_94=9,LOW*0.98,9),COLORGREEN;
DRAWNUMBER(X_94=13,LOW*0.98,13),COLORYELLOW;
DRAWNUMBER(X_94=18,LOW*0.98,18),COLORYELLOW;
DRAWICON(X_94=8,LOW*0.99,41);
DRAWKLINE(HIGH,OPEN,LOW,CLOSE);
716455249.jpg
|