指标到底有没有用,怎么使用指标,指标的赢面有多大(胜率或概率如何),如何优化指标,本文试图粗浅探讨一下指标公式的使用,以下是主要内容:
1.如何从指标公式中提取选股公式
2.指标评测与胜率
3.指标评测结果分析
4.交易策略制定和思路
本节探讨第一部分:如何从指标公式中提取选股公式
看到一个好的指标公式,买入信号比较明确且准确率较高,如何从几千只股票中选出刚触发买入信号的股票?需要提取出选股公式,创建自己的选股指标。
说明:以下指标公式均在通达信中测试通过
例1:MACD买卖指标公式
DIFF:EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:EMA(DIFF,9);
MACD:(DIFF-DEA)*2;
低位金叉:CROSS(DIFF,DEA) AND DIFF<-0.1;
JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));
二次金叉:CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,34)=1;
A1:=BARSLAST(REF(CROSS(DIFF,DEA),1));
底背离:REF(CLOSE,A1+1)>CLOSE AND DIFF>REF(DIFF,A1+1) AND CROSS(DIFF,DEA);
A2:=BARSLAST(REF(CROSS(DEA,DIFF),1));
顶背离:REF(CLOSE,A2+1)DIFF AND CROSS(DEA,DIFF),COLORRED;
强:IF(DIFF>=DEA,DIFF,DRAWNULL),COLORRED,LINETHICK2;
可以看到这个指标中“低位金叉”“二次金叉”“底背离”都是买入信号,“顶背离”是卖出信号。
现在假如用“低位金叉”信号进行选股,选股公式是什么呢?
首先找到“低位金叉”信号这一段:低位金叉:CROSS(DIFF,DEA) AND DIFF<-0.1;
在这段公式中引用了“DIFF”、“DEA”二个变量,由此上溯找到这二个变量,把公式补齐如下:
DIFF:EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:EMA(DIFF,9);
低位金叉:CROSS(DIFF,DEA) AND DIFF<-0.1;
但这样的选股公式是不行的,引用的变量是“:”,只要改成“:=”就可以了(冒号:赋值,并且输出。输出是指在看盘界面画出来。冒号加等号:赋值,不输出。不显示,但可以在指标代码中引用。)因此选股公式如下:
DIFF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
低位金叉:CROSS(DIFF,DEA) AND DIFF<-0.1;
在通达信创建选股公式,选出的股票如下(绿色信号是低位金叉):
是不是很简单?现在我们做“二次金叉”的选股公式,把“二次金叉”的语句找出来,里面引用了“DIFF”、“DEA”、“JCCOUNT”三个变量,把这三个赋“:=”,得到“二次金叉”的选股公式如下:
DIFF:=EMA(CLOSE,12)-EMA(CLOSE,26);
DEA:=EMA(DIFF,9);
JCCOUNT:=COUNT(CROSS(DIFF,DEA),BARSLAST(DEA>=0));
二次金叉:CROSS(DIFF,DEA) AND DEA<0 AND COUNT(JCCOUNT=2,34)=1;
“底背离”的选股公式大家可以做一做(引用了“DIFF”、“DEA”、“A1”)。
这个例子公式还是清晰的,变量名也比较直观,变量名可以随意取只要不是通达信函数名就行,比如好多选股公式最后都是“XG:”“选股:”,而不是“低位金叉:”这种。
总结一下,通过指标提取选股公式,首先找到信号语句(一般是买入信号),然后在这条语句往上追溯引用的变量,把所有变量找出来,按照指标公式原有的顺序把用到变量的语句写下来,最后把引用的变量改成“:=”。(我往往先把指标公式复制粘贴,把无用的语句删除,再把“:”改“:=”)
例2:底部掘金指标公式
趋势:5*SMA((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27))*100,5,1)-3*SMA(SMA((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27))*100,5,1),3,1)-SMA(SMA(SMA((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27))*100,5,1),3,1),2,1),COLOR7F52AF;
趋势1:EMA(MA(趋势,5),3),COLORA6B8C1;
STICKLINE(趋势>=趋势1,趋势,趋势1,1,0),COLOR7F52AF;
STICKLINE(趋势<趋势1,趋势,趋势1,1,0),COLORA6B8C1;
STICKLINE(趋势>108 AND 趋势>=趋势1,趋势,108,1,0),COLORBLUE ;
STICKLINE(趋势1>108 AND 趋势<趋势1,趋势1,108,1,0),COLORWHITE;
STICKLINE(趋势<0 AND 趋势<趋势1,趋势,0,1,0),COLORF00FF0 ;
STICKLINE(趋势1<0 and="">趋势1,趋势1,0,1,0),COLORF0F000;
V1:=MA(C,5)=HHV(MA(C,5),20);
V2:=MA(C,5)>MA(C,20);
V3:=COUNT(MA(C,1)>REF(C,1),3)=3;
风险:IF(V1 AND V2 AND V3,30,0),STICK,COLOR00FF00,LINETHICK8;V11:=MA(C,5)=HHV(MA(C,5),120);
V21:=MA(C,5)>MA(C,120);
V31:=COUNT(MA(C,1)>REF(C,1),3)=3;
风险1:IF(V11 AND V21 AND V31,60,0),STICK,COLORF0F000,LINETHICK4;
底部:0,COLORFF0D00;
抄底:IF(CROSS(趋势,底部),60,0),STICK,COLORYELLOW,LINETHICK8;DRAWTEXT(抄底,1,'抄底'),COLORRED;
天线:108,COLORFF9D00;
逃顶:IF(CROSS(天线,趋势),1,0),STICK,COLORFF9D00;
STICKLINE(CROSS(天线,趋势),90,108,2,0),COLORFF9D00;
看上去很复杂的指标公式,效果也很不错,来看看它的选股公式。
先找买点语句,是黄色柱出现地方,是“抄底”那部分:
抄底:IF(CROSS(趋势,底部),60,0),STICK,COLORYELLOW,LINETHICK8;DRAWTEXT(抄底,1,'抄底'),COLORRED;
忽略这些“STICK,COLOR***,LINETHICK,DRAWTEXT”这些画线函数,剩下的只有:IF(CROSS(趋势,底部),60,0)。在通达信指标公式编辑器里,点击动态翻译,找到该语句翻译为:输出抄底:如果趋势上穿底部,返回60,否则返回0,STICK,画黄色,线宽为8。触发信号就是:CROSS(趋势,底部)。上溯“趋势”和“底部”语句,再加上“抄底”,得到:
趋势:5*SMA((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27))*100,5,1)-3*SMA(SMA((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27))*100,5,1),3,1)-SMA(SMA(SMA((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27))*100,5,1),3,1),2,1),COLOR7F52AF底部:0,COLORFF0D00;
抄底:CROSS(趋势,底部)
去掉COLOR***(颜色)无关参数,把“趋势”和“底部”加上“=”号,最终得到选股公式:
趋势:=5*SMA((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27))*100,5,1)-3*SMA(SMA((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27))*100,5,1),3,1)-SMA(SMA(SMA((CLOSE-LLV(LOW,27))/(HHV(HIGH,27)-LLV(LOW,27))*100,5,1),3,1),2,1);
底部:=0;
抄底:CROSS(趋势,底部);
最后选出的股票如下图:
例3:一年四倍主图指标公式
均5:MA(CLOSE,5), COLOR0000FF;
均10:MA(CLOSE,10) ,COLOR00FF00;
VARC:=SMA(MAX(C-REF(C,1),0),6,1)/SMA(ABS(C-REF(C,1)),6,1)*100;
DRAWICON(CROSS(82,VARC),HIGH,2);
VAR6:=REF(C,1);
VAR7:=SMA(MAX(C-VAR6,0),6,1)/SMA(ABS(C-VAR6),6,1)*100;
DRAWTEXT(CROSS(84,VAR7),H*1.01,'▲逃庄'),COLORGREEN ;
VAR32:=CLOSE/REF(CLOSE, 1)>=1.062 AND HIGH/CLOSE<1.005 AND MA(CLOSE, 90)/CLOSE>=1.150;
VAR33:=VAR32 AND COUNT(VAR32, 20)=1 ;
DRAWTEXT_FIX(C>O,0.01,0.9,0,0),COLORRED;
VAR34:=(INDEXC-REF(INDEXC, 1))/REF(INDEXC, 1);
VAR35:=(CLOSE-REF(CLOSE, 1))/REF(CLOSE, 1);
VAR36:=IF(VAR34>0.010, 0.900, 1) AND IF(VAR34>(-0.025), 1, 1.200);
VAR37:=VAR36*(VAR35-VAR34)*100;
VAR38:=SUM(VAR37, 10);
VAR39:=SMA(VAR38, 40, 1);
VAR310:=VAR38>20;
VAR311:=CROSS(CLOSE, MA(CLOSE*1.055, 3)) AND CLOSE>OPEN*1.060 AND VOL>=REF(VOL, 1)*1.5 AND CLOSE>=MA(CLOSE, 10);
VAR312:=VAR310 AND VAR311 ;
VAR313:=(-100)*(HHV(HIGH, 3)-CLOSE)/(HHV(HIGH, 3)-LLV(LOW, 3));
VAR314:= CROSS(VAR313, (-87)) AND OPEN=1.090*REF(CLOSE, 1) AND INDEXC>0.980*REF(INDEXC, 1) AND CLOSE<=1.470*LLV(CLOSE, 58);
VAR315:=EMA(CLOSE, 12)-EMA(CLOSE, 26);
VAR316:=EMA(VAR315, 9);
VAR317:=2*(VAR315-VAR316);
VAR318:=(CLOSE-LLV(LOW, 9))/(HHV(HIGH, 9)-LLV(LOW, 9))*100;
VAR319:=SMA(VAR318, 3, 1);
VAR320:=SMA(VAR319, 3, 1);
VAR321:=EMA(IF(VAR316>REF(VAR316, 1), 1, (-1)), 14)*14;
VAR322:=EMA(IF(VAR320>REF(VAR320, 1), 1, (-1)), 14)*14*2;
VAR323:=(MA(CLOSE, 5)/MA(CLOSE, 70)-1)*100;
VAR324:=(VAR323+VAR322+VAR321)/3;
VAR325:=MA(CLOSE, 80)-MA(CLOSE, 10)/3;
VAR326:=IF(CLOSE AND MA(VOL, 5)/240 AND CLOSE>REF(CLOSE, 1)*1.0 AND CLOSE,88,0);{VAR38>VAR39;}
VAR327:=IF(CLOSE/REF(CLOSE, 1)>1.050 AND VOL/CAPITAL*100<10 AND CLOSE<17 AND HIGH/CLOSE<1.010 AND VAR326>0, 91, 0);
VAR328:=IF(VAR324>REF(VAR324, 1) AND REF(VAR324, 1)[0 OR VAR327>0, 85, 0);]
VAR329:=IF(VAR327>0 ,95,0), STICK,LINETHICK2;
VAR330:=IF(VAR326>0 OR VAR327>0,91,0), STICK,LINETHICK2;
VAR331:=IF(VAR328>0 OR VAR327>0 OR VAR326>0,88,0), STICK,LINETHICK2;
VAR332:=100*(CLOSE-LLV(LOW,42))/(HHV(HIGH,42)-LLV(LOW,42)),LINETHICK1,COLORGREEN;
VAR333:=COUNT(MA(CLOSE,3)>REF(MA(CLOSE,3),1),1)=1;
VAR334:=(VAR332<93 AND VAR333 AND MAX(MAX(VAR329, VAR330), VAR331))*100;
STICKLINE(VAR327>90,LOW*0.99,LOW*0.95,2,0),COLORYELLOW;
DRAWTEXT(VAR327>90,LOW*0.95,'杀庄'),COLORYELLOW;
DRAWICON(VAR310>0 AND VAR327=0,HIGH*1.01,5);
这是一个主图指标,信号“杀庄”是买入信号,怎么做“杀庄”的选股公式。这个公式没有太明显的变量,都是字母表示,好在“杀庄”信号有汉字,我们找到倒数第二行有'杀庄'二字,该语句是:
DRAWTEXT(VAR327>90,LOW*0.95,'杀庄'),COLORYELLOW;
触发信号就是:VAR327>90。上溯“VAR327”语句,得到:
VAR327:=IF(CLOSE/REF(CLOSE, 1)>1.050 AND VOL/CAPITAL*100<10 AND CLOSE<17 AND HIGH/CLOSE<1.010 and="" var326="">0, 91, 0);
这里又有VAR326>0,再上溯“VAR326”语句,得到:
VAR326:=IF(CLOSE AND MA(VOL, 5)/240 AND CLOSE>REF(CLOSE, 1)*1.0 AND CLOSE,88,0);
这句没有其他变量!
因此选股公式是:
VAR326:=IF(CLOSE AND MA(VOL, 5)/240 AND CLOSE>REF(CLOSE, 1)*1.0 AND CLOSE,88,0);
VAR327:=IF(CLOSE/REF(CLOSE, 1)>1.050 AND VOL/CAPITAL*100<10 AND CLOSE<17 AND HIGH/CLOSE<1.010 and="" var326="">0, 91, 0);
选股:VAR327>90;
最后选出的股票如下图:
END
|