1、通达信指标编写全技巧通达信指标编写全技巧首先,你得初步熟悉通达信的函数、公式编写、指标使用、选股、预警等方法。第一课,如何在通达信里画色彩通达信画色带,没有飞狐轻松随意方便,一点局限性,就是只能定义AB之间的画色带DRAWBAND:画出带状线.用法:DRAWBAND(VAL1,COLOR1,VAL2,COLOR2),当VAL1VAL2时,在VAL1和VAL2之间填充COLOR1;当VAL1O,H,L,0,0),COLORRED;STICKLINE(CO,C,O,3.1,1),COLORRED;STICKLINE(C=O,C,O,3.1,0),COLORCYAN;最后将你想要的赋值的线画出来和变
2、色处理MA20,COLOR00FFFF,LINETHICK2;IF(MA(C,20)REF(MA(C,20),1),MA(C,20),DRAWNULL),COLOR0B0000,LINETHICK2;MA60,COLORFF0090,LINETHICK2;IF(MA(C,60)B,A,B)-就是当A大于B时,显示A,否那么显示B先隐藏赋值,为了能将你想看到的线型的数据显示在指标的当头位置MA20: MA(CLOSE,20),COLORRED,LINETHICK2;MA60: MA(CLOSE,60),COLORFF0090,LINETHICK2;UP:MA20+2*STD(CLOSE,20),
3、LINETHICK1,COLOR404080;DW:MA20-2*STD(CLOSE,20),LINETHICK1,COLORC0C0C0;UP2:MA60+2*STD(CLOSE,60),LINETHICK1,COLOR808080;DW2:MA60-2*STD(CLOSE,60),LINETHICK1,COLOR004000;然后画色带DRAWBAND(MA60,RGB(200,150,30),UP2,RGB(200,150,30);DRAWBAND(MA60,RGB(100,100,150),DW2,RGB(100,100,150);DRAWBAND(MA20,RGB(0,50,150)
4、,DW,RGB(0,50,150);DRAWBAND(MA20,RGB(155,50,50),UP,RGB(155,50,50);IF(UPUP2,UP2,UP)就是当UP大于UP2时,显示UP2,否那么显示UPDRAWBAND(UP,RGB(0,150,50),IF(UPUP2,UP2,UP),RGB(0,150,50);DRAWBAND(DW,RGB(0,150,50),IF(DWO,H,L,0,0),COLORRED;STICKLINE(CO,C,O,3.1,1),COLORRED;STICKLINE(C=O,C,O,3.1,0),COLORCYAN;最后将你想要的赋值的线画出来和变色处
5、理MA20,COLOR00FFFF,LINETHICK2;IF(MA(C,20)REF(MA(C,20),1),MA(C,20),DRAWNULL),COLOR0B0000,LINETHICK2;MA60,COLORFF0090,LINETHICK2;IF(MA(C,60)B,A,B)-就是当A大于B时,显示A,否那么显示B先隐藏赋值,为了能将你想看到的线型的数据显示在指标的当头位置MA20: MA(CLOSE,20),COLORRED,LINETHICK2;MA60: MA(CLOSE,60),COLORFF0090,LINETHICK2;UP:MA20+2*STD(CLOSE,20),LI
6、NETHICK1,COLOR404080;DW:MA20-2*STD(CLOSE,20),LINETHICK1,COLORC0C0C0;UP2:MA60+2*STD(CLOSE,60),LINETHICK1,COLOR808080;DW2:MA60-2*STD(CLOSE,60),LINETHICK1,COLOR004000;然后画色带DRAWBAND(MA60,RGB(200,150,30),UP2,RGB(200,150,30);DRAWBAND(MA60,RGB(100,100,150),DW2,RGB(100,100,150);DRAWBAND(MA20,RGB(0,50,150),D
7、W,RGB(0,50,150);DRAWBAND(MA20,RGB(155,50,50),UP,RGB(155,50,50);IF(UPUP2,UP2,UP)就是当UP大于UP2时,显示UP2,否那么显示UPDRAWBAND(UP,RGB(0,150,50),IF(UPUP2,UP2,UP),RGB(0,150,50);DRAWBAND(DW,RGB(0,150,50),IF(DWO,H,L,0,0),COLORRED;STICKLINE(CO,C,O,3.1,1),COLORRED;STICKLINE(C=O,C,O,3.1,0),COLORCYAN;最后将你想要的赋值的线画出来和变色处理M
8、A20,COLOR00FFFF,LINETHICK2;IF(MA(C,20)REF(MA(C,20),1),MA(C,20),DRAWNULL),COLOR0B0000,LINETHICK2;MA60,COLORFF0090,LINETHICK2;IF(MA(C,60)UP2,UP2,UP)就是当UP大于UP2时,显示UP2,否那么显示UPDRAWBAND(UP,RGB(0,150,50),IF(UPUP2,UP2,UP),RGB(0,150,50);DRAWBAND(DW,RGB(0,150,50),IF(DW=MM0,LL0-(HH0-LL0)*0.2,HH0+(HH0-LL0)*0.2)
9、;此句为便于叠加副图不影响版面,当现价大于中间值时将叠加副图放在主图上沿反之放下沿HH1:=IF(CONST(C)=MM0,LL0,HL0);再次设定叠加副图的最低值HL1:=(HH1+LL1)/2;最后确定副图的中间值位置STICKLINE(MACDZ0,MACDZ*2+HL1,HL1,1,0),COLOR400080;STICKLINE(MACDZ0 AND MACDZREF(MACDZ,1),MACDZ*2+HL1,HL1,1,0),COLOR00FFFF;STICKLINE(MACDZ0,MACDZ*2+HL1,HL1,1,0),COLOR008080;STICKLINE(MACDZR
10、EF(MACDZ,1),MACDZ*2+HL1,HL1,1,0),COLORC080FF;(DIFZ*2+HL1),COLORRED;(DEAZ*2+HL1),COLORFFFFFF;IF(DIFZO,H,L,0,0),COLORRED;STICKLINE(CO,C,O,3.1,1),COLORRED;STICKLINE(C=O,C,O,3.1,0),COLORCYAN;最后将你想要的赋值的线画出来和变色处理MA20,COLOR00FFFF,LINETHICK2;IF(MA(C,20)REF(MA(C,20),1),MA(C,20),DRAWNULL),COLOR0B0000,LINETHIC
11、K2;MA60,COLORFF0090,LINETHICK2;IF(MA(C,60)REF(MA(C,60),1),MA(C,60),DRAWNULL),COLORFFF000,LINETHICK2;如果在主图叠加有最高最低数据限制的副图,这里以叠加RSI为例子RSI的数值最高是100,最低是0,有了这个定义就好办了叠加KDJ性质一样,以叠加MACD的模板继续修改首先我们要做一个叠加副图模板HH:=CONST(HHV(C,120)*1;取现价的N日最大值LL:=CONST(LLV(C,120)*1;取现价的N日最小值HL:=CONST(IF(CONST(HH+LL)/2)CONST(C),HH
12、,HL);当现价小于中间值时以最大值为最高点,反之以HL为最高点LL1:=IF(CONST(HH+LL)/2)CONST(C),LL,HL);当现价小于中间值时以最小值为最低点,反之以HL为最低点HLMAX:=MAX(HH1,LL1);设定所要叠加副图比例的最大值HLMIN:=MIN(HH1,LL1);设定所以叠加副图比例的最小值HLMN1:=(HLMAX+HLMIN)/2;取设定所要叠加副图比例的最大最小值的中间值HLMN2:=HLMAX-HLMIN;取设定所要叠加副图比例的最大最小值的差值HLMN3:=(副图比例最高值-副图比例最低值)/2;HLMN4:=副图比例最高值-副图比例最低值;所
13、叠加副图线:(副图线形-HLMN4)*HLMN2/HLMN3+HLMN1;按比例叠加副图线的计算方式由于所要叠加副图的正常比例最高值是100,最低值是0,所以HLMN3:=(副图比例最高值-副图比例最低值)/2;HLMN4:=副图比例最高值-副图比例最低值;所叠加副图线:(副图线形-HLMN3)*HLMN2/HLMN4+HLMN1;按比例叠加副图线的计算方式可以修改成HLMN3:=(100-0)/2;HLMN4:=100-0;直接简化为所叠加副图线:(副图线形-50)*HLMN2/100+HLMN1;按比例叠加副图线的计算方式模板在此有更详细的解释.55188./viewthread. . 2
14、6amp%3Btypeid%3D38有了以上叠加副图的模板,那么就好办了,就以叠加RSI为例子HH:=CONST(HHV(C,120)*1;LL:=CONST(LLV(C,120)*1;HL:=CONST(IF(CONST(HH+LL)/2)CONST(C),HH,HL);LL1:=IF(CONST(HH+LL)/2)O,H,L,0,0),COLORRED;STICKLINE(CO,C,O,3.1,1),COLORRED;STICKLINE(C=O,C,O,3.1,0),COLORCYAN;M5:MA(C,5);M10:MA(C,10);M20:MA(C,20);M60:MA(C,60);如果
15、你想再复杂点,多叠加那就加啊HH:=CONST(HHV(C,120)*1;LL:=CONST(LLV(C,120)*1;HL:=CONST(IF(CONST(HH+LL)/2)CONST(C),HH,HL);LL1:=IF(CONST(HH+LL)/2)KDJ.D(9,3,3),(KDJ.K(9,3,3)-50)*HLMN2/100+HLMN1,(KDJ.D(9,3,3)-50)*HLMN2/100+HLMN1,1.5,0),COLOR5955FF;STICKLINE(KDJ.K(9,3,3)O,H,L,0,0),COLORRED;STICKLINE(CO,C,O,3.1,1),COLORRE
16、D;STICKLINE(C=O,C,O,3.1,0),COLORCYAN;M5:MA(C,5);M10:MA(C,10);M20:MA(C,20);M60:MA(C,60);有的朋友喜欢双叠加,也做了一个参考MA5:MA(CLOSE,5),COLORFF00FF,LINETHICK0;MA13:MA(C,13),COLOR00FFFF,LINETHICK0;MA34: MA(CLOSE,34),COLORRED,LINETHICK0;MA55: MA(CLOSE,55),COLORFF0090,LINETHICK0;HH0:=CONST(HHV(C,150);LL0:=CONST(LLV(C,
17、150);HL:=CONST(IF(CONST(HH0+LL0)/2)CONST(C),HH0,HL);LL1:=IF(CONST(HH0+LL0)/2)CONST(C),LL0*0.95-(HH0-LL0)*0.1,HH0*0.95+(HH0-LL0)*0.1);HLMAX:=MAX(HH1,LL1);HLMIN:=MIN(HH1,LL1);HLMN1:=(HLMAX+HLMIN)/2;HLMN2:=HLMAX-HLMIN;STICKLINE(C,HH1,(HH1+LL1)/2,5,0),COLOR858500;STICKLINE(C,LL1,(HH1+LL1)/2,5,0),COLOR330000;STICKLINE(C,(0.75-0.5)*HLMN2/0.5+HLMN1,(1-0.5)*HLMN2/0.5+HLMN1,5,0),COLOR000088;STICKLINE(C,(0.25-0.5)*HLMN2/0.5+HLMN1,(0-0.5)*HLMN2/0.5+HLMN1,5,0),COLOR555555;STICKLINE(KDJ.K(9,3,3)KDJ.D(9,3,3),(KDJ.K(9,3,3)/100-0.5)*HLMN2/0.5+HLMN1,(KDJ.D(9,3,3)/100-0.5)*HLMN2/0.5+HLMN1,1.5,0),COLO
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1