MID:MA(CLOSE,21),COLORWHITE;
UPPER:MID + 1.96*STD(CLOSE,21),COLORYELLOW;
LOWER:MID - 1.96*STD(CLOSE,21),COLORYELLOW;
UP:MID + 2.58*STD(CLOSE,21),COLORFF00FF;
LOOW:MID - 2.58*STD(CLOSE,21),COLORFF00FF;
{1.96统计学中为95%可信区间,2.58为99%可信区间,故采用1.96和2.58作为参数}
单边上升:=(C>MID);
单边下降:=(C<MID);
布林线开口:=UP-LOOW;
多头行情:=C>MA(C,5) AND MA(C,5)>MA(C,10);
股价在高位:=((C-LLV(C,30))/(HHV(C,30)-LLV(C,30))>0.6);
股价在低位:=((C-LLV(C,30))/(HHV(C,30)-LLV(C,30))<0.4);
布林线缩口:=((UPPER-MID)/MID<0.05);
STICKLINE(单边上升,MID,UP,6,0),COLOR330066;
STICKLINE(单边下降,LOOW,MID,6,0),COLOR545454;
DRAWTEXT(布林线缩口,MID,'▲'),COLORWHITE;
STICKLINE((OPEN >= CLOSE),OPEN,CLOSE,5,0),COLORCYAN;
STICKLINE((OPEN >= CLOSE),HIGH,LOW,0,0),COLORCYAN;
STICKLINE((OPEN < CLOSE),OPEN,CLOSE,5,0),COLORRED;
STICKLINE((OPEN < CLOSE),HIGH,LOW,0,0),COLORRED;
MID,COLORWHITE;
UPPER,COLORYELLOW;
LOWER,COLORYELLOW;
UP,COLORFF00FF;
LOOW,COLORFF00FF;
drawtext(单边上升 and ref(c,1)>ref(up,1) and c < up ,up*1.08,'减仓'),color00FF00;
drawtext(ref(布林线开口,1)=hhv(布林线开口,20) and 单边上升,up*1.08,'卖出'),colorwhite;
空仓:=(cross(mid,amount/v/100));
drawtext(空仓,up*1.05,'空仓'),coloryellow;
drawtext(BARSLAST(布林线缩口)=1 and c<ma(c,10),up*1.08,'一轮跌势起'),color00FF00;
适当建仓:=(单边上升 and FILTER(多头行情,20) and v>ma(v,3));
drawtext(适当建仓,loow,'适当建仓'),colorred;
加仓:=(单边上升 and ref(c-mid,1)=llv(c-mid,5));
drawtext(加仓 and BARSLAST(适当建仓)<BARSLAST(空仓),loow,'加仓'),colorff00ff;
一波行情起:=(BARSLAST(布林线缩口)<=3 and v>ma(v,3) and 股价在低位 and c>ref(c,1) and c>ma(c,10));
drawtext(FILTER(一波行情起,5),lower,'一波行情起'),colorred;
一波跌势完:=(单边下降 and BARSLAST(ref(布林线开口,1)=hhv(布林线开口,50))<=5 and loow>ref(loow,1) and c <mid) and 股价在低位;
drawtext(FILTER(一波跌势完,5),lower,'抢反弹');