p1=3、1、100
p2=2、1、100
p3=3、1、100
p4=2、1、100
p5=2、1、100

VARA:=IF((C > 150),91.3,0.913);
【下沿】:=(INTPART((C / VARA)) * VARA)colorFF9900;
【上沿】:=(【下沿】 + VARA)color99FF;
【中線】:=((【下沿】 + 【上沿】) / 2)colorFFFFFF;


STICKLINE(((SYSPARAM(1) = BARPOS) AND 【上沿】),【上沿】,【上沿】,50,0),LINETHICK3,color99FF;
STICKLINE(((((SYSPARAM(1) = BARPOS) AND 【下沿】) AND (C > 【下沿】)) AND (C < 【中線】)),【下沿】,【下沿】,50,0),LINETHICK3,COLORBROWN;
STICKLINE(((SYSPARAM(1) = BARPOS) AND 【中線】),【中線】,【中線】,50,0),LINETHICK3,COLORWHITE;
STICKLINE(((((SYSPARAM(1) = BARPOS) AND 【上沿】) AND (C < 【上沿】)) AND (C > 【中線】)),【上沿】,【上沿】,50,0),LINETHICK3,color99FF;
STICKLINE(((SYSPARAM(1) = BARPOS) AND 【下沿】),【下沿】,【下沿】,50,0),LINETHICK3,colorFF9900;


DRAWTEXT(((((SYSPARAM(1) = BARPOS) AND 【上沿】) AND (C < 【上沿】)) AND (C< 【上沿】)),【上沿】,'壓力價'),SHIFT3,color99FF;
DRAWTEXT(((((SYSPARAM(1) = BARPOS) AND 【中線】) AND (C<> 【中線】)) AND (C<> 【中線】)),【中線】,'中線價'),SHIFT3,COLORWHITE;
DRAWTEXT(((((SYSPARAM(1) = BARPOS) AND 【下沿】) AND (C > 【下沿】)) AND (C > 【下沿】)),【下沿】,'支撐價'),SHIFT3,colorFF9900;

棕壓力:【上沿】,LINETHICK0,color99FF;
白中線:【中線】,LINETHICK0,colorFFFFFF;
藍支撐:【下沿】,LINETHICK0,colorFF9900;

DRAWNUMBER(BARSCOUNT(C)=SYSPARAM(1),棕壓力,棕壓力,0),shift12,color99FF;
DRAWNUMBER(BARSCOUNT(C)=SYSPARAM(1),白中線,白中線,0),shift12,COLORWHITE;
DRAWNUMBER(BARSCOUNT(C)=SYSPARAM(1),藍支撐,藍支撐,0),shift12,colorFF9900;

EXPLAIN(1,'【動態多空防守關鍵價】 '),COLORWHITE;
explainex(棕壓力,'▲(棕)壓力線=',棕壓力,0,0)color99FF;
explainex(白中線,'▲(白)白中線價=',白中線,0,0)colorFFFFFF;
explainex(藍支撐,'▲(藍)支撐價=',藍支撐,0,0)colorFF9900;

n1:=sysparam(3);
n:=n1-sysparam(2)+1;
hh:=hhv(H,n);
ll:=llv(L,n);
最高:=hh[n1];
最低:=ll[n1];
安全:最低+(最高-最低)*0.191,POINTDOT,PRECISION2,LINETHICK3,COLORCYAN;
中樞:最低+(最高-最低)*0.5,LINEDOT,PRECISION2,COLORMAGENTA;
危險:最低+(最高-最低)*0.809,LINEDOT,PRECISION2,COLORYELLOW;
explainex(危險,'▲危險=',危險,0,0)COLORYELLOW;
explainex(中樞,'▲中樞=',中樞,0,0)COLORMAGENTA;
explainex(安全,'▲安全=',安全,0,0)COLORCYAN;

//蛟龍出海

d1:"yngs.B1";
d2:"yngs.B2";
d3:"yngs.B3";
d4:"yngs.B4";
fillrgn(d3>d4,d3,d4),Color8000FF;
fillrgn(d3<d4,d3,d4),Color00FF80;
fillrgn(d1>d2,d1,d2),Color0080FF;
fillrgn(d1<d2,d1,d2),ColorFF8000;
explainex(d1,'▲d1=',d1,0,0)COLORYELLOW;
explainex(d2,'▲d2=',d2,0,0)COLORYELLOW;
explainex(d3,'▲d3=',d3,0,0)COLORYELLOW;
explainex(d4,'▲d4=',d4,0,0)COLORYELLOW;


AA:=((2*CLOSE)+HIGH+LOW)/4;
DI3:=MA(AA,p1);
DZ7:=ZIG(DI3,p2);

StickLine( IsUP AND DZ7>=REF(DZ7,1) , HIGH , LOW , 0 , 0 ) , COLORRED ;
StickLine(IsUp AND DZ7>=REF(DZ7,1), CLOSE , OPEN ,7 , 0 ) , Colorred ;
StickLine(IsDown AND DZ7>=REF(DZ7,1), HIGH , LOW ,0, 1 ) , Colorred;
StickLine(IsDown AND DZ7>=REF(DZ7,1), CLOSE , OPEN ,7 , 1 ) , Colorred ;

StickLine(IsUP AND DZ7<REF(DZ7,1) , HIGH , LOW , 0 , 1 ) ,COLORBLUE ;
StickLine(IsUp AND DZ7<REF(DZ7,1), CLOSE , OPEN ,7 , 1 ) , COLORBLUE ;
StickLine(IsDown AND DZ7<REF(DZ7,1), HIGH , LOW ,0, 0 ) , COLORBLUE ;
StickLine(IsDown AND DZ7<REF(DZ7,1), CLOSE , OPEN ,7 , 0 ) , COLORBLUE ;

StickLine( IsEqual and DZ7>=REF(DZ7,1) , HIGH , LOW , 0,1) , Colorred ;
StickLine( IsEqual and DZ7>=REF(DZ7,1) , CLOSE , OPEN , 7, 1 ) , Colorred ;
StickLine( IsEqual and DZ7<REF(DZ7,1) , HIGH , LOW , 0 ,1 ) , COLORBLUE ;
StickLine( IsEqual and DZ7<REF(DZ7,1) , CLOSE , OPEN , 7 ,1 ) , COLORBLUE ;

X:=Barscount( Close ) ;
{ 以下是描繪第一個交易日的K線,以補前面含蓋的不足 }
StickLine( IsEqual and X = 1 , HIGH, LOW,7, 0 ) , Color5050FF ;
StickLine( IsEqual and X = 1 , CLOSE , OPEN ,7, 0 ) , Color5050FF ;


MA20:MA(CLOSE,P3),COLORYELLOW;


DZ7升% : ((DZ7-TROUGH(DZ7,p2,1))/TROUGH(DZ7,p2,1))*100,colorred,LINETHICK0;
DZ7跌% : ((DZ7-PEAK(DZ7,p2,1))/PEAK(DZ7,p2,1))*100,colorgreen,LINETHICK0;

DRAWICON(DZ7<REF(DZ7,1) AND REF(DZ7,1)>REF(DZ7,2),HIGH,5),PXUP20;
DRAWICON(DZ7>REF(DZ7,1) AND REF(DZ7,1)<REF(DZ7,2),LOW,4),PXDN10;
Var7B:=(DZ7<REF(DZ7,1) AND REF(DZ7,1)>REF(DZ7,2));
Var8B:=(DZ7>REF(DZ7,1) AND REF(DZ7,1)<REF(DZ7,2));
DRAWTEXT(Var7B,H,'波段賣出'),PXUP40,COLORCYAN{color0080FF};
DRAWTEXT(Var8B,L,'波段買進'),PXDN30,color0080FF;