//定义ATR
TR:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR0:=MA(TR,26);
ATR:=ROUND((ATR0/MINPRICE),0)*MINPRICE;
合约倍数:UNIT,NODRAW;
//定义BOLL
MID:=ROUND(MA(C,26)/MINPRICE,0)*MINPRICE;
TMP2:=ROUND(STD(C,26)/MINPRICE,0)*MINPRICE;
TOP:=MID+2*TMP2;
BOT:=MID-2*TMP2;
//画线并显示上中下轨
上轨:TOP,LINETHICK2;
中轨:MID,LINETHICK2;
下轨:BOT,LINETHICK2,COLORBLACK;
//定义趋势,上涨=3,盘整=2,下跌=1
SZXH:=BARSLAST(CROSS(H,REF(TOP,1)) OR H>=REF(TOP,1)),NODRAW;
PZDM0:=BARSLAST(CROSSDOWN(L,REF(MID,1)) OR L<=REF(MID,1)),NODRAW;
PZDM:=IF(PZDM0>=0,PZDM0,999),NODRAW;
PZUM0:=BARSLAST(CROSS(H,REF(MID,1)) OR H>=REF(MID,1)),NODRAW;
PZUM:=IF(PZUM0>=0,PZUM0,999),NODRAW;
XDXH:=BARSLAST(CROSSDOWN(L,REF(BOT,1)) OR L<=REF(BOT,1)),NODRAW;
QSSZ:=IF(PZDM>SZXH,3,2),NODRAW;
QSXD:=IF(PZUM>XDXH,1,2),NODRAW;
QS:=IF(C>=REF(TOP,1),3,IF(C<=REF(BOT,1),1,IF(C>REF(MID,1),QSSZ,QSXD))),NODRAW;
//趋势启动和结束位置显示小图标提示
DRAWICON(QS=3 AND REF(QS,1)<>3,H+0.3*ATR,"ICO4");
DRAWICON(QS=1 AND REF(QS,1)<>1,L-0.6*ATR,"ICO5");
DRAWICON(QS=2 AND REF(QS,1)<>2 AND REF(C,1)>REF(MID,1),L-0.6*ATR,"ICO16");
DRAWICON(QS=2 AND REF(QS,1)<>2 AND REF(C,1)<REF(MID,1),H+0.3*ATR,"ICO16");
//开仓计算器
首仓TBMK:ROUND(TBMK_首仓/UNIT/ABS(TOP-MID),0),NODRAW,COLORBLUE;
//首仓CMK:ROUND(CMK_首仓/UNIT/ABS(C-MID),0),NODRAW,COLORBLUE;
底仓手数:底仓手数_1,NODRAW,COLORBLUE;
初始止损:=初始止损_1,NODRAW;
中轨总实盈:底仓手数*ABS(MID-初始止损)*UNIT,NODRAW,COLORBLUE;
冻结总实盈:冻结总实盈_1,NODRAW,COLORRED;
可用实盈:=中轨总实盈–冻结总实盈,NODRAW,COLORBLUE;
Q3可加手数:可用实盈/UNIT/Q3止损倍数_1/ATR,NODRAW,COLORBLUE;
Q3实加手数:Q3实加手数_1,NODRAW,COLORRED;
Q3实加实盈:Q3实加手数*ATR*Q3止损倍数_1*UNIT,NODRAW,COLORBLUE;
Q3止损位:IF(QS=3,C-Q3止损倍数_1*ATR,IF(QS=1,C+Q3止损倍数_1*ATR,0)),NODRAW,COLORBLUE;
DRAWICON(QS=3 AND C>TOP,L-0.3*ATR,"IC11");
DRAWICON(QS=1 AND C<BOT,H+0.3*ATR,"IC11");
(来源:文华财经)