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