通达信 两点趋势交易主图源码
此主图信息量大,需细细品味,主图用到辅助趋势画线函数,但关键性算法未用函数(如BS信号、买入卖出、考虑买、找底线等)
用法注解:
1、第一趋势法则:趋势黄线判断;
2、第二区间法则:红区上行,灰区下行调整;
3、第三决策法则:红进、白减、绿清仓;
4、第四辅助法则:有三项
一是BS信号法则,长期坚持只赢不亏;
二是“买入”和“卖出”文字加减仓法则;
三是“找底”和“参考买”两线法则。
{参数1: N, 最小: 1, 最大: 100, 缺省: 5}
X_1:=EMA(CLOSE,2);
X_2:=EMA(SLOPE(CLOSE,21)*20+CLOSE,42);
STICKLINE(X_1>=X_2,REFDATE(HHV(HIGH,0),DATE),REFDATE(LLV(LOW,0),DATE),6,0),COLOR001050;
STICKLINE(X_1 DRAWKLINE(HIGH,OPEN,LOW,CLOSE); X_3:=EMA((EMA(CLOSE,4)+EMA(CLOSE,6)+EMA(CLOSE,12)+EMA(CLOSE,24))/4,2); X_4:=MA(CLOSE,27); B买:IF(CROSS(X_3,X_4) OR CROSS(X_1,X_2),CLOSE,DRAWNULL),NODRAW,COLORMAGENTA; 持仓:IF(X_1>=X_2,CLOSE,DRAWNULL),NODRAW,COLORRED; S卖:IF(CROSS(X_4,X_3) OR CROSS(X_2,X_1),CLOSE,DRAWNULL),NODRAW,COLORLIGRAY; 空仓:IF(X_1 DRAWICON(CROSS(X_1,X_2),LOW-LOW*0.02,7); DRAWICON(CROSS(X_2,X_1),HIGH+HIGH*0.02,8); STICKLINE(X_1>=X_2,LOW,HIGH,0,1),COLORRED; STICKLINE(X_1>=X_2,CLOSE,OPEN,3,1),COLORRED; STICKLINE(X_1 STICKLINE(X_1 看趋势:HHV(CLOSE,55)*0.9,COLORYELLOW,LINETHICK2; X_5:=HHVBARS(CLOSE,60); X_6:=REF(X_5,1)>30 AND CROSS(CLOSE,REF(HHV(HIGH,60),1)); X_7:=VOL/REF(VOL,1)>=2; STICKLINE(X_6,CLOSE,OPEN,1,0),COLORYELLOW; DRAWTEXT(X_6 AND X_7,OPEN,599),COLORYELLOW; 决策线:MA(CLOSE,5),COLORWHITE,LINETHICK3; IF(决策线>REF(决策线,1),决策线,DRAWNULL),COLORRED,LINETHICK3; IF(决策线 X_8:=0.01; X_9:=0; X_10:=0.03; DRAWTEXT_FIX(ISLASTBAR,X_8,X_9,0,STRCAT(STRSPACE(DYBLOCK),HYBLOCK)),COLORCYAN; DRAWTEXT_FIX(ISLASTBAR,X_8,X_9+X_10*2,0,GNBLOCK),COLORCYAN; DRAWTEXT_FIX(ISLASTBAR,X_8,X_9+X_10*4,0,FGBLOCK),COLORYELLOW; DRAWTEXT_FIX(ISLASTBAR,X_8,X_9+X_10*6,0,ZDBLOCK),COLORMAGENTA; STICKLINE(CLOSE>1.095*REF(CLOSE,1),CLOSE,OPEN,2.5,0),COLORYELLOW; STICKLINE(CLOSE<0.905*REF(CLOSE,1),CLOSE,OPEN,2.5,0),COLORGREEN; X_11:=CLOSE-LOW; X_12:=HIGH-LOW; X_13:=CLOSE-HIGH; X_14:=IF(HIGH>LOW,(X_11/X_12+X_13/X_12)*VOL,0); X_15:=SUM(X_14,10)/10000; X_16:=EMA(CLOSE,12)-EMA(CLOSE,26); X_17:=EMA(12,9); X_18:=(12-26)*2; X_19:=UPNDAY(X_18,1); X_20:=REF(HIGH,5)=HHV(HIGH,11); X_21:=REF(LOW,5)=LLV(LOW,11); X_22:=BACKSET(X_20,6)>BACKSET(X_20,5); X_23:=BACKSET(X_21,6)>BACKSET(X_21,5); X_24:=IF(BARSLAST(X_22)=BARSLAST(X_23) AND MA(CLOSE,5)>MA(CLOSE,10),X_22,IF(BARSLAST(X_23)>BARSLAST(X_22),X_22,0)); X_25:=IF(BARSLAST(X_22)=BARSLAST(X_23) AND MA(CLOSE,10)>MA(CLOSE,5),X_23,IF(BARSLAST(X_22)>BARSLAST(X_23),X_23,0)); X_26:=X_24 AND HIGH=HHV(HIGH,BARSLAST(X_25)); X_27:=X_25 AND LOW=LLV(LOW,BARSLAST(X_24)); X_28:=LOW>REF(HIGH,1) AND DAY=REF(DAY,1); X_29:=HIGH X_30:=REF(HIGH,BARSLAST(X_26)); X_31:=REF(LOW,BARSLAST(X_26)); X_32:=REF(HIGH,BARSLAST(X_26)+1); X_33:=REF(LOW,BARSLAST(X_26)+1); X_34:=REF(LOW,BARSLAST(X_26)+2); X_35:=REF(HIGH,BARSLAST(X_27)+2); X_36:=REF(HIGH,BARSLAST(X_27)); X_37:=REF(LOW,BARSLAST(X_27)); X_38:=REF(HIGH,BARSLAST(X_27)+1); X_39:=REF(LOW,BARSLAST(X_27)+1); X_40:=IF(X_32 X_41:=IF(X_39>X_36,X_36,IF(X_36>=X_38,X_35,X_38)); X_42:=X_30>X_41 AND X_26; X_43:=X_37 X_44:=X_42 AND X_30>X_36 AND X_31>X_37 AND X_33>X_37; X_45:=X_43 AND X_37 X_46:=HIGH<=REF(HIGH,1) AND LOW>=REF(LOW,1) OR (HIGH>=REF(HIGH,1) AND LOW<=REF(LOW,1)); X_47:=COUNT(X_46,BARSLAST(X_27)); X_48:=COUNT(X_46,BARSLAST(X_26)); X_49:=COUNT(X_28,BARSLAST(X_27)); X_50:=COUNT(X_29,BARSLAST(X_26)); X_51:=IF(X_47>0,X_47+2,IF(X_48,X_48+2,3)); X_52:=IF(X_49,X_51-X_49,IF(X_50,X_51-X_50,X_51)); X_53:=X_44 AND BARSLAST(X_45)>X_52; X_54:=X_45 AND BARSLAST(X_44)>X_52; X_55:=X_26 AND REF(HIGH,BARSLAST(X_26))>=REF(HIGH,BARSLAST(X_53)) AND BARSLAST(X_54)>BARSLAST(X_53) OR (X_42 AND COUNT(X_28,BARSLAST(X_43))>0 AND REF(HIGH,BARSLAST(X_42))>REF(HIGH,BARSLAST(X_53))); X_56:=X_27 AND REF(LOW,BARSLAST(X_27))<=REF(LOW,BARSLAST(X_54)) AND BARSLAST(X_53)>BARSLAST(X_54) OR (X_43 AND COUNT(X_29,BARSLAST(X_42))>0 AND REF(LOW,BARSLAST(X_43)) X_57:=IF(BARSLAST(X_56)>BARSLAST(X_55),REF(HIGH,BARSLAST(X_55)),REF(HIGH,BARSLAST(X_56))); X_58:=IF(BARSLAST(X_55)>BARSLAST(X_56),REF(LOW,BARSLAST(X_56)),REF(LOW,BARSLAST(X_55))); X_59:=X_55 AND HIGH=HHV(X_57,BARSLAST(X_56)+1) AND HIGH>REF(HIGH,1) AND BARSLAST(X_56)>BARSLAST(X_55); X_60:=X_56 AND LOW=LLV(X_58,BARSLAST(X_55)+1) AND LOWBARSLAST(X_56); X_61:=X_59 OR (X_26 AND REF(HIGH,BARSLAST(X_26))>REF(HIGH,BARSLAST(X_59)) AND BARSLAST(X_60)>BARSLAST(X_59)); X_62:=X_60 OR (X_27 AND REF(LOW,BARSLAST(X_27))BARSLAST(X_60)); 向上 向下 X_63:=DRAWLINE(X_61,HIGH,REF(X_61,1),REF(HIGH,1),1); 找底 DRAWNUMBER(X_62,LOW*0.995,LOW); DRAWNUMBER(X_61,HIGH*1.01,HIGH); X_64:=CROSS(CLOSE,X_63) AND X_63>0 AND X_15 AND X_19; X_65:=9; X_66:=IF(HIGH>PEAK(1,X_65,1),HHV(HIGH,X_65),PEAK(1,X_65,1)); X_67:=IF(LOW X_68:=TROUGHBARS(2,X_65,1); X_69:=PEAKBARS(1,X_65,1); X_70:=IF(X_69 X_71:=SQRT(HIGH*找底); STICKLINE(UPNDAY(HIGH,1) AND HIGH=向上,HIGH,找底,0,0),COLORMAGENTA; STICKLINE(HIGH>REF(HIGH,DAYSTOTODAY<5),HIGH,找底,0,0),COLORRED; STICKLINE(X_61,X_71,X_71,1,0),COLORMAGENTA; DRAWTEXT_FIX(1,0.98,20,1,1),COLOR666666; STICKLINE(HIGH>REF(HIGH,DAYSTOTODAY<5),X_71,X_71,1,0),COLORRED; 考虑买 X_72:=20; X_73:=7; X_74:=79; X_75:=(CLOSE+HIGH+LOW)/3; X_76:=EMA(X_75,10); X_77:=REF(X_76,1); DRAWICON(REF(X_76 DRAWTEXT(REF(X_76 X_78:=(REF(HIGH,1)+REF(LOW,1))/2; X_79:=MA(CLOSE,X_72)+2*STD(CLOSE,X_72); DRAWICON(CROSS(X_78,X_79),HIGH+0.1,2); DRAWTEXT(CROSS(X_78,X_79),HIGH*1.02,749),COLORGREEN; X_80:=REF(CLOSE,1); X_81:=SMA(MAX(CLOSE-X_80,0),X_73,1)/SMA(ABS(CLOSE-X_80),X_73,1)*100; X_82:=CROSS(X_74,X_81); X_83:=FILTER(X_82,4); DRAWICON(X_83,HIGH+0.1,2); DRAWTEXT(X_83,HIGH*1.02,749),COLORGREEN; 特别声明:以上观点仅供参考,不构成投资建议