N:=8;
趋势:=zig(3,N);
DRAWBAND(趋势,RGB(255,255,255),趋势,RGB(255,255,255));
↑转向:=TROUGHBARS(3,N,1);
↓转向:=PEAKBARS(3,N,1);
L低:=IF(↑转向=0,C,IF(↓转向<↑转向,TROUGH(3,N,1),REF(TROUGH(3,N,1),1)));
H高:=IF(↓转向=0,C,IF(↑转向<↓转向,PEAK(3,N,1),REF(PEAK(3,N,1),1)));
低高运行:=REF(BArslAST(趋势<REF(趋势,1)),BARSLAST(↓转向=0));
高低运行:=REF(BARSLAST(趋势>REF(趋势,1)),BARSLAST(↑转向=0));
现区间运行天数:IF(↑转向<↓转向,BARSLAST(趋势<REF(趋势,1)),BARSLAST(趋势>REF(趋势,1))),COLORFF00FF,NODRAW;
前1区间运行:=IF(↑转向<↓转向,高低运行,低高运行);
高低距:=REF(H高-L低,BARSLAST(↓转向<↑转向 AND ↓转向>0 AND 趋势>L低));
低高距:=REF(H高-L低,BARSLAST(↑转向<↓转向 AND ↑转向>0 AND 趋势<H高));
前1区间距:=IF(↑转向>↓转向,高低距,低高距);
区间涨%:=IF(↑转向<↓转向,(C/L低-1)*100,REF((C/L低-1)*100,↓转向));
区间跌%:=IF(↓转向<↑转向,(C/H高-1)*100,REF((C/H高-1)*100,↑转向));
现区间涨跌:IF(ISLASTBAR AND 趋势<REF(趋势,1),区间跌%,区间涨%),COLORFFFF00,NODRAW;
上:IF(趋势>REF(趋势,1),趋势,DRAWNULL),COLORRED,LINETHICK2;
下:IF(趋势<REF(趋势,1),趋势,DRAWNULL),COLORGREEN,LINETHICK2;
STICKLINE(↑转向=0,L*0.95,H高,0,0),COLOR00FF00;
STICKLINE(↓转向=0,H*1.03,L低,0,0),COLORFF00FF;
STICKLINE(BETWEEN(↑转向,0,7),L低,L低,3,1),COLOR00FFFF;
STICKLINE(BETWEEN(↓转向,0,7),H高,H高,3,1),COLOR00FF00;
STICKLINE(↑转向<↓转向,L低,L低,1,1),COLOR00FFFF;
STICKLINE(↓转向<↑转向,H高,H高,1,1),COLOR00FF00;
DRAWNUMBER(↑转向=0,L*0.98,前1区间运行),COLORFFFFFF;
DRAWNUMBER(↑转向=0,H高,Abs(H高-L低)),COLORFF0000;
DRAWNUMBER(↑转向=0,(H高+L低)/2,区间跌%),COLORFFFF00;
DRAWNUMBER(↓转向=0,H*1.02,前1区间运行),COLORFFFFFF;
DRAWNUMBER(↓转向=0,(H高+L低)/2,区间涨%),COLORFFFF00;
DRAWNUMBER(↓转向=0,L低,ABS(H高-L低)),COLORFF0000;
DRAWNUMBER(ISLASTBAR AND 趋势<REF(趋势,1),(H高+趋势)/2,区间跌%),COLORFFFF00;
DRAWNUMBER(ISLASTBAR AND 趋势>REF(趋势,1),(趋势+L低)/2,区间涨%),COLORFFFF00;
DRAWTEXT_FIX(ISLASTBAR,0,0.01,0,'■前区间运行天数。'),COLORFFFFFF;
DRAWTEXT_FIX(ISLASTBAR,0,0.05,0,'■前区间运行价差。'),COLORFF0000;
DRAWTEXT_FIX(ISLASTBAR,0,0.09,0,'■前区间涨跌幅度。'),COLORFFFF00;