VAR1:=SUM(MAX(MAX(HIGH-LOW,ABS(HIGH-REF(CLOSE,1))),ABS(LOW-REF(CLOSE,1))),25);
VAR2:=HIGH-REF(HIGH,1);
VAR3:=REF(LOW,1)-LOW;
VAR4:=SUM(IF(VAR2>0 AND VAR2>VAR3,VAR2,0),25);
VAR5:=SUM(IF(VAR3>0 AND VAR3>VAR2,VAR3,0),25);
VAR6:=VAR4*100/VAR1;
VAR7:=VAR5*100/VAR1;
VAR8:=MA(ABS(VAR7-VAR6)/(VAR7+VAR6)*100,115);
VAR9:=(VAR8+REF(VAR8,15))/2;
A:=(VAR7>VAR6 AND VAR7>25 AND VAR6<25);
B:ZIG(3,7.5/5),COLOR00FF00;
G:MA(B,2),COLORYELLOW;
D:=CROSS(B,G),COLORRED;
W:=CROSS(G,B),COLOR00FF00;
E:=REF(INDEXC,1);
F:=SMA(MAX(INDEXC-E,0),3,1)/SMA(ABS(INDEXC-E),3,1);
VAR10:=F AND F<8;
VAR11:=(CLOSE-LLV(LOW,9))/(HHV(HIGH,9)-LLV(LOW,9))*100;
VAR12:=SMA(VAR11,3,1);
VAR13:=SMA(VAR12,3,1);
VAR14:=VAR13 AND VAR13<20;
MM:=A AND D AND VAR10 AND VAR14 ;
DRAWTEXT(W,HIGH*1.005,'卖' ),COLOR00FF00;
DRAWTEXT(D,LOW*0.998,'买'),COLORWHITE;
A1:=REF(DYNAINFO( 7),1);
B1:=SMA(MAX(DYNAINFO( 7)-A1,0),9,1)/SMA(ABS(DYNAINFO( 7)-A1),9,1)*100;
DRAWICON(CROSS(20,B1),L,4);
DRAWICON(CROSS(B1,80),H,5);
if datatype>=0 then exit;
////////****** 计算指标变换所需的公共数据 *******
rc:=DYNAINFO(3);//前收
q:=datacount;
hh:=DYNAINFO(5);//最高
LL:=DYNAINFO(6);//最低
f:=max(hh-rc,rc-LL);
ff:=f/rc*100;//最大半振幅
////////////////////////////////////////////////////////////////
////////****** ㈠副图1叠加大盘分时线******(共3个步骤完成指标变换)
//副图1变换所需数据
q1h:=if(ff<1,0.9898*rc,rc-f*1.02);//分时副图1最高位置
q1l:=if(ff<1,0.9798*rc,rc-2*f*1.016);//分时副图1最低位置,同时也是分时副图2最高位置
//①以下计算大盘分时线的最大、最小值
R:=INDEXC;
Rh:=hhv(r,0);//最大值
RL:=LLv(r,0);//最小值
//②计算缩放比例、平移值
Rb:=(q1h-q1l)/(RH[q]-RL[q]);//缩放比例
Ry:=(q1h+q1l-rb*(RH[q]+RL[q]))/2;//平移值
//③变换原来的大盘分时到分时副图1
r*rb+ry,COLOR00FF00;//在分时副图1,显示变换后的大盘分时
/////////////////////////////////////////////////////////////////
////////******** ㈡在副图2叠加macd ********
//副图2变换所需数据
q2h:=if(ff<1,0.9797*rc,rc-2*f*1.016);//分时副图2最高位置
q2l:=if(ff<1,0.9697*rc,rc-3*f*1.011);//分时副图2最低位置
//以下清除原始的指标线,并画横坐标线
FILLRGN(1,q2h,q2l),colorblack;
cz:=(q2h-q2l)/6;
q2l,POINTDOT,,COLORWHITE;
q2l+cz,POINTDOT,color0000cc;
q2l+2*cz,POINTDOT,color0000cc;
q2l+3*cz,POINTDOT,color0000cc;
q2l+4*cz,POINTDOT,color0000cc;
q2l+5*cz,POINTDOT,color0000cc;
a1:="macd.diff";
a2:="macd.dea";
a3:="macd.macd";
mh:=hhv(max(a1,a3),0);
mL:=LLv(min(a3,a1),0);
mb:=(q2h-q2l)/(mH[q]-mL[q]);//缩放比例,选macd或diff来计算缩放比例
my:=(q2h+q2l-mb*(mH[q]+mL[q]))/2;//平移值
diff:a1*mb+my,COLORWHITE;//副图2显示原来的diff指标线
dea:a2*mb+my,COLORYELLOW;//副图2显示原来的dea指标线
macd:=a3*mb+my;//副图2显示原来的macd指标线
STICKLINE(macd>my,my,macd,1,1),COLORRED;
STICKLINE(macd<my,my,macd,1,1),COLORCYAN;