趋势主图指标源码分享适用期货股市
DRAWGBK(C>0,RGB(0,0,110),RGB(0,25,0),0,' ',0);
Z1:=STRCAT(HYBLOCK,' ');
Z2:=STRCAT(Z1,DYBLOCK);
Z3:=STRCAT(Z2,' ');
DRAWTEXT_FIX(ISLASTBAR,0,0,0,STRCAT(Z3,GNBLOCK)),COLORYELLOW;
DRAWKLINE(H,O,L,C);
SJTJ:=1;
XA_1:=IF(1=1 OR 1=3,HIGH,CLOSE);
XA_2:=IF(1=1 OR 1=3,LOW,CLOSE);
XA_3:=3=1 OR 3=2 OR 3=3;
XA_4:=3=2 OR 3=3;
XA_5:=3=3;
XA_6:=C;
XA_7:=IF(XA_6=1,REF(XA_6,1)-1,IF(XA_6=(-1),REF(XA_6,1)+1,XA_6));
XA_8:=IF(XA_7<0,XA_7+1,XA_7-1);
XA_9:=TROUGHBARS(3,3,1);
XA_10:=PEAKBARS(3,3,1);
XA_11:=IF(XA_9=0,(-1),IF(XA_10=0,1,0));
XA_12:=IF(XA_9=0,XA_10,IF(XA_10=0,-XA_9,IF(XA_9>XA_10,XA_10,-XA_9)));
XA_13:=H;
XA_14:=BARSLAST(XA_13<0);
XA_15:=BARSLAST(XA_13>0);
XA_16:=IF(XA_14=0,(-1),IF(XA_15=0,1,0));
XA_17:=IF(XA_14=0,XA_15,IF(XA_15=0,-XA_14,IF(XA_14>XA_15,XA_15,-XA_14)));
XA_18:=IF(1=2,XA_11,IF(1=3,XA_16,XA_6));
XA_19:=IF(1=2,XA_12,IF(1=3,XA_17,XA_8));
XA_20:=IF(XA_19<0,-XA_19,XA_19);
周期:XA_20,NODRAW,COLORWHITE;
XA_21:=IF(XA_19>0,100*(XA_2/REF(XA_1,XA_20)-1),100*(XA_1/REF(XA_2,XA_20)-1));
涨跌幅:XA_21,NODRAW,COLORWHITE;
XA_22:=INBLOCK(1)=1 AND NOT(NAMEINCLUDE(2));
XA_23:=IF(0=0,XA_20,MIN(XA_20,0));
XA_24:=IF(XA_19>0,100*(XA_2/REF(XA_1,XA_23)-1),100*(XA_1/REF(XA_2,XA_23)-1));
XA_25:=IF(XA_22,AMOUNT/100000000,VOL/100);
XA_26:=SUM(XA_25,XA_23);
XA_27:=XA_26/XA_24/1;
速度指数:XA_27,NODRAW,COLORWHITE;
DRAWLINE(XA_3 AND XA_18=(-1),XA_2,XA_3 AND XA_18=1,XA_1,0),DOTLINE,COLORYELLOW;
DRAWLINE(XA_3 AND XA_18=1,XA_1,XA_3 AND XA_18=(-1),XA_2,0),DOTLINE,COLORYELLOW;
DRAWNUMBER(XA_4 AND XA_18=1,HIGH,ROUND(XA_27)),COLORWHITE,LINETHICK9;
DRAWNUMBER(XA_4 AND XA_18=(-1),LOW,ROUND(XA_27)),COLORWHITE;
XA_28:=BARSLAST(XA_18=1);CHAGULA:SMA(MAX(CLOSE-C,0),7,1)/SMA(ABS(CLOSE-C),7,1)*100,NODRAW;
XA_29:=BARSLAST(XA_18=(-1));
XA_30:=IF(XA_28=0 OR XA_29=0,DRAWNULL,(REF(XA_1,XA_28)+REF(XA_2,XA_29))/2);
R50%:IF(XA_5,XA_30,DRAWNULL),POINTDOT,COLORWHITE;
XA_31:=IF(HIGH<REF(LOW,1),REF(LOW,1),HIGH);
XA_32:=IF(LOW>REF(HIGH,1),REF(HIGH,1),LOW);
XA_33:=HHV(XA_31,3);
XA_34:=LLV(XA_32,3);
XA_35:=BARSLAST(XA_34<REF(XA_34,1));
XA_36:=BARSLAST(XA_33>REF(XA_33,1));
XA_37:=IF(HHV(XA_31,XA_36+1)=XA_31,1,0);
XA_38:=IF(LLV(XA_32,XA_35+1)=XA_32,1,0);
XA_39:=BARSLAST(XA_37);
XA_40:=REF(LLV(XA_32,3),XA_39);
XA_41:=BARSLAST(XA_38);
XA_42:=REF(HHV(XA_31,3),XA_41);
XA_43:=VALUEWHEN(XA_42>0,XA_42);
XA_44:=VALUEWHEN(XA_40>0,XA_40);
XA_45:=IF(CLOSE>XA_43,(-1),IF(CLOSE<XA_44,1,0));
XA_46:=VALUEWHEN(XA_45!=0,XA_45);
XA_47:=BARSLAST(CROSS(0,XA_46));
XA_48:=BARSLAST(CROSS(XA_46,0));
XA_49:=IF(XA_46=1,IF(LLV(XA_43,XA_48+1)=XA_43,XA_43,LLV(XA_43,XA_48+1)),XA_43);
XA_50:=IF(XA_46=(-1),IF(HHV(XA_44,XA_47+1)=XA_44,XA_44,HHV(XA_44,XA_47+1)),XA_44);
XA_51:=IF(CLOSE>XA_49,(-1),IF(CLOSE<XA_50,1,0));
XA_52:=VALUEWHEN(XA_51!=0,XA_51);
XA_53:=BARSLAST(CROSS(0,XA_51));
XA_54:=BARSLAST(CROSS(XA_51,0));
XA_55:=IF(XA_52=1,IF(LLV(XA_49,XA_54+1)=XA_49,XA_49,LLV(XA_49,XA_54+1)),IF(HHV(XA_50,XA_53+1)=XA_50,XA_50,HHV(XA_50,XA_53+1)));
多头止损:IF(XA_5 AND XA_52<0,XA_55,DRAWNULL),COLORRED,LINETHICK2;
空头止损:IF(XA_5 AND XA_52>0,XA_55,DRAWNULL),COLORGREEN,LINETHICK2;
STICKLINE(多头止损 AND C>O,OPEN,CLOSE,-1,1),COLORRED;
{STICKLINE(多头止损,OPEN,H,0.0,0),COLORRED;}
{STICKLINE(多头止损,C,L,0.0,0),COLORRED;}
STICKLINE(多头止损 AND C<O,OPEN,CLOSE,-1,0),COLORRED;
{STICKLINE(多头止损,O,L,0.0,0),COLORRED;
STICKLINE(多头止损,C,H,0.0,0),COLORRED;}
STICKLINE(空头止损 AND C<O,OPEN,CLOSE,-1,1),COLORGREEN;
{STICKLINE(空头止损,OPEN,H,0.0,0),COLORGREEN;}
{STICKLINE(空头止损,C,L,0.0,0),COLORGREEN;}
STICKLINE(空头止损 AND C>O,OPEN,CLOSE,-1,0),COLORGREEN;
{STICKLINE(空头止损,C,H,0.0,0),COLORGREEN;
STICKLINE(空头止损,O,L,0.0,0),COLORGREEN;};
未来函数检测结果如下:
该公式包含未来函数:PEAK
该公式包含未来函数:PEAKBARS
该公式包含未来函数:TROUGH
该公式包含未来函数:TROUGHBARS
解密、定制、编写股票指标请联系QQ或微信同号:88652583
相关股票指标公式
原理解析:
填充背景(C>0,RGB(0,0,110),RGB(0,25,0),0,' ',0)
Z1赋值:STRCAT(HYBLOCK,' ')
Z2赋值:STRCAT(Z1,DYBLOCK)
Z3赋值:STRCAT(Z2,' ')
DRAWTEXT_FIX(ISLASTBAR,0,0,0,STRCAT(Z3,GNBLOCK)),画黄色
DRAWKLINE(H,O,L,C)
SJTJ赋值:1
如果1=1 OR 1=3返回最高价否则返回收盘价
如果1=1 OR 1=3返回最低价否则返回收盘价
XA_3赋值:3=1 OR 3=2 OR 3=3
XA_4赋值:3=2 OR 3=3
XA_5赋值:3=3
XA_6赋值:C
XA_7赋值:IF(XA_6=1,1日前的XA_6-1,IF(XA_6=(-1),1日前的XA_6+1,XA_6))
如果XA_7<0返回XA_7+1否则返回XA_7-1
XA_9赋值:TROUGHBARS(3,3,1)
XA_10:=PEAKBARS(3,3,1)
XA_11:=IF(XA_9=0,(-1),IF(XA_10=0,1,0))
XA_12:=IF(XA_9=0,XA_10,IF(XA_10=0,-XA_9,IF(XA_9>XA_10,XA_10,-XA_9)))
XA_13:=H
XA_14:=上次XA_13<0距今天数
XA_15:=上次XA_13>0距今天数
XA_16:=IF(XA_14=0,(-1),IF(XA_15=0,1,0))
XA_17:=IF(XA_14=0,XA_15,IF(XA_15=0,-XA_14,IF(XA_14>XA_15,XA_15,-XA_14)))
XA_18:=IF(1=2,XA_11,IF(1=3,XA_16,XA_6))
XA_19:=IF(1=2,XA_12,IF(1=3,XA_17,XA_8))
如果XA_19<0返回-XA_19否则返回XA_19
输出周期:XA_20,NODRAW,画白色
XA_21:=IF(XA_19>0,100*(XA_2/XA_20日前的XA_1-1),100*(XA_1/XA_20日前的XA_2-1))
输出涨跌幅:XA_21,NODRAW,画白色
XA_22:=INBLOCK(1)=1 AND NOT(NAMEINCLUDE(2))
XA_23:=IF(0=0,XA_20,XA_20和0的较小值)
XA_24:=IF(XA_19>0,100*(XA_2/XA_23日前的XA_1-1),100*(XA_1/XA_23日前的XA_2-1))
如果XA_22返回成交额/100000000否则返回成交量/100
XA_26:=XA_23的XA_25日累和
XA_27:=XA_26/XA_24/1
输出速度指数:XA_27,NODRAW,画白色
DRAWLINE(XA_3 AND XA_18=(-1),XA_2,XA_3 AND XA_18=1,XA_1,0),DOTLINE,画黄色
DRAWLINE(XA_3 AND XA_18=1,XA_1,XA_3 AND XA_18=(-1),XA_2,0),DOTLINE,画黄色
DRAWNUMBER(XA_4 AND XA_18=1,最高价,ROUND(XA_27)),画白色,LINETHICK9
DRAWNUMBER(XA_4 AND XA_18=(-1),最低价,ROUND(XA_27)),画白色
XA_28:=上次XA_18=1距今天数
输出CHAGULA:SMA(收盘价-C和0较大值,7,1)/SMA(收盘价-C的绝对值,7,1)*100,NODRAW
XA_29:=上次XA_18=(-1距今天数)
XA_30:=IF(XA_28=0 OR XA_29=0,DRAWNULL,(XA_28日前的XA_1+XA_29日前的XA_2)/2)
如果XA_5返回XA_30否则返回DRAWNULL
XA_31:=IF(最高价<1日前的最低价,1日前的最低价,最高价)
XA_32:=IF(最低价>1日前的最高价,1日前的最高价,最低价)
XA_33:=3日内XA_31最高值
XA_34:=3日内XA_32最低值
XA_35:=上次XA_34<1日前的XA_34距今天数
XA_36:=上次XA_33>1日前的XA_33距今天数
XA_37:=IF(XA_36+1日内XA_31最高值=XA_31,1,0)
XA_38:=IF(XA_35+1日内XA_32最低值=XA_32,1,0)
XA_39:=上次XA_37距今天数
XA_40:=REF(3日内XA_32最低值,XA_39)
XA_41:=上次XA_38距今天数
XA_42:=REF(3日内XA_31最高值,XA_41)
XA_43:=VALUEWHEN(XA_42>0,XA_42)
XA_44:=VALUEWHEN(XA_40>0,XA_40)
XA_45:=IF(收盘价>XA_43,(-1),IF(收盘价XA_46:=VALUEWHEN(XA_45!=0,XA_45)
XA_47:=上次0上穿XA_46距今天数
XA_48:=上次XA_46上穿0距今天数
XA_49:=IF(XA_46=1,IF(XA_48+1日内XA_43最低值=XA_43,XA_43,XA_48+1日内XA_43最低值),XA_43)
XA_50:=IF(XA_46=(-1),IF(XA_47+1日内XA_44最高值=XA_44,XA_44,XA_47+1日内XA_44最高值),XA_44)
XA_51:=IF(收盘价>XA_49,(-1),IF(收盘价XA_52:=VALUEWHEN(XA_51!=0,XA_51)
XA_53:=上次0上穿XA_51距今天数
XA_54:=上次XA_51上穿0距今天数
XA_55:=IF(XA_52=1,IF(XA_54+1日内XA_49最低值=XA_49,XA_49,XA_54+1日内XA_49最低值),IF(XA_53+1日内XA_50最高值=XA_50,XA_50,XA_53+1日内XA_50最高值))
如果XA_5 AND XA_52<0返回XA_55否则返回DRAWNULL
如果XA_5 AND XA_52>0返回XA_55否则返回DRAWNULL
当满足条件多头止损 AND C>O时,在开盘价和收盘价之间画柱状线
当满足条件多头止损时,在开盘价和H之间画柱状线
当满足条件多头止损时,在C和L之间画柱状线
当满足条件多头止损 AND C当满足条件多头止损时,在O和L之间画柱状线
当满足条件多头止损时,在C和H之间画柱状线
当满足条件空头止损 AND C当满足条件空头止损时,在开盘价和H之间画柱状线
当满足条件空头止损时,在C和L之间画柱状线
当满足条件空头止损 AND C>O时,在开盘价和收盘价之间画柱状线
当满足条件空头止损时,在C和H之间画柱状线
当满足条件空头止损时,在O和L之间画柱状线
}