最好能按卦名选出股票来。
input:p1(1,0,1),p2(1,0,1);{//P1=0,按常规K线开收定阴阳爻,P1=1,按张东生-常秉义方法定阴阳爻;P2=0,按K线顺序排卦,左为初爻,右为上爻,P2=1,按K线逆序排卦
//在副图上显示证卷代码与证卷名称}
{DRAWTEXT(sysparam(2)=BARSCOUNT(CLOSE),h*1.10,'证卷代码:'+STKLABEL+';'+'证卷名称:'+STKNAME),COLORGREEN,ALIGN4;
//副图指标,绘K线}
STICKLINE(C>O,H,L,0.4,0),COLORRED;
STICKLINE(C>O,O,C,8,1),COLORRED;
STICKLINE(C<=O,H,L,0.4,0),COLORCYAN;
STICKLINE(C<=O,O,C,8,0),COLORCYAN;
{按不同方法定阴阳爻}
aa:=AMOUNT/VOL/100;{//均价}
ai:=if(c=o,aa-ref(aa,1),c-o);{//P1=0,按常规K线开收定阴阳爻}
aj:=if(c=ref(c,1),aa-ref(aa,1),c-ref(c,1));{//P1=1,按张东生-常秉义方法定阴阳爻}
a:=if(p1=0,ai,aj);
{//对特殊阴阳爻作出标记}
DRAWICON((p1=0 and C=O and ai>0) or (p1=1 and C=ref(c,1) and aj>0),L,1),ALIGN0;
DRAWICON((p1=0 and C=O and ai<0) or (p1=1 and C=ref(c,1) and aj<0),L,2),ALIGN0;
{//选定6爻,P2=0,按K线顺序排卦,P2=1,按K线逆序排卦}
a1:=if(p2=0,ref(a,5),a);
a2:=if(p2=0,ref(a,4),ref(a,1));
a3:=if(p2=0,ref(a,3),ref(a,2));
a4:=if(p2=0,ref(a,2),ref(a,3));
a5:=if(p2=0,ref(a,1),ref(a,4));
a6:=if(p2=0,a,ref(a,5));
{//下卦}
x1:=a1>0 and a2>0 and a3>0;{//下卦乾-阳阳阳}
x11:=if(a1>0 and a2>0 and a3>0,1,0);
x2:=a1>0 and a2>0 and a3<0;{//下卦兑-阳阳阴}
x22:=if(a1>0 and a2>0 and a3<0,2,0);
x3:=a1>0 and a2<0 and a3>0;{//下卦离-阳阴阳}
x33:=if(a1>0 and a2<0 and a3>0,3,0);
x4:=a1>0 and a2<0 and a3<0;{//下卦震-阳阴阴}
x44:=if(a1>0 and a2<0 and a3<0,4,0);
x5:=a1<0 and a2>0 and a3>0;{//下卦巽-阴阳阳}
x55:=if(a1<0 and a2>0 and a3>0,5,0);
x6:=a1<0 and a2>0 and a3<0;{//下卦坎-阴阳阴}
x66:=if(a1<0 and a2>0 and a3<0,6,0);
x7:=a1<0 and a2<0 and a3>0;{//下卦艮-阴阴阳}
x77:=if(a1<0 and a2<0 and a3>0,7,0);
x8:=a1<0 and a2<0 and a3<0;{下卦坤-阴阴阴}
x88:=if(a1<0 and a2<0 and a3<0,8,0);

x:(x11+x22+x33+x44+x55+x66+x77+x88),LINETHICK0;
{//上卦}
s1:=a4>0 and a5>0 and a6>0;{上卦乾-阳阳阳}
s11:=if(a4>0 and a5>0 and a6>0,1,0);
s2:=a4>0 and a5>0 and a6<0;{上卦兑-阳阳阴}
s22:=if(a4>0 and a5>0 and a6<0,2,0);
s3:=a4>0 and a5<0 and a6>0;{//上卦离-阳阴阳}
s33:=if(a4>0 and a5<0 and a6>0,3,0);
s4:=a4>0 and a5<0 and a6<0;{//上卦震-阳阴阴}
s44:=if(a4>0 and a5<0 and a6<0,4,0);
s5:=a4<0 and a5>0 and a6>0;{//上卦巽-阴阳阳}
s55:=if(a4<0 and a5>0 and a6>0,5,0);
s6:=a4<0 and a5>0 and a6<0;{//上卦坎-阴阳阴}
s66:=if(a4<0 and a5>0 and a6<0,6,0);
s7:=a4<0 and a5<0 and a6>0;{//上卦艮-阴阴阳}
s77:=if(a4<0 and a5<0 and a6>0,7,0);
s8:=a4<0 and a5<0 and a6<0;{//上卦坤-阴阴阴}
s88:=if(a4<0 and a5<0 and a6<0,8,0);
s:(s11+s22+s33+s44+s55+s66+s77+s88),LINETHICK0;
cc1:=(c-REF(C,1))/REF(C,1)*100;
cc2:=(REF(C,1)-REF(C,2))/REF(C,2)*100;
cc3:=(REF(C,2)-REF(C,3))/REF(C,3)*100;
cc4:=(REF(C,3)-REF(C,4))/REF(C,4)*100;
cc5:=(REF(C,4)-REF(C,5))/REF(C,5)*100;
cc6:=(REF(C,5)-REF(C,6))/REF(C,6)*100;
dd1:=max(abs(cc1),abs(cc2),abs(cc3),abs(cc4),abs(cc5),abs(cc6));{涨跌幅最大日作动爻}
{dn:BARSlast(abs((c-REF(C,1))/REF(C,1)*100)=d1);泥马大智慧用这句直接算错日数,让我废话下面这么多句}
d1:=if(abs(cc1)=dd1,1,0);
d2:=if(abs(cc2)=dd1,2,0);
d3:=if(abs(cc3)=dd1,3,0);
d4:=if(abs(cc4)=dd1,4,0);
d5:=if(abs(cc5)=dd1,5,0);
d6:=if(abs(cc6)=dd1,6,0);
dn:d1+d2+d3+d4+d5+d6,LINETHICK0;{动爻}

{//乾宫八卦,红色系}
DRAWTEXT(x1 and s1,HIGH*1.04,'乾'),ALIGN1,COLOR0000BE;{11乾为天-阳阳阳阳阳阳}
DRAWTEXT(x1 and s2,HIGH*1.04,'夬'),ALIGN1,COLOR0000E4;{21泽天夬-阳阳阳阳阳阴}
DRAWTEXT(x1 and s3,HIGH*1.08,'大 有'),ALIGN1,COLOR0000EA;{31火天大有-阳阳阳阳阴阳}
DRAWTEXT(x1 and s4,HIGH*1.08,'大 壮'),ALIGN1,COLOR0000FF;{41雷天大壮-阳阳阳阳阴阴}
DRAWTEXT(x1 and s5,HIGH*1.08,'小 畜'),ALIGN1,COLOR4441FF;{51风天小畜-阳阳阳阴阳阳}
DRAWTEXT(x1 and s6,HIGH*1.04,'需'),ALIGN1,COLOR436FFF;{61水天需-阳阳阳阴阳阴}
DRAWTEXT(x1 and s7,HIGH*1.08,'大 畜'),ALIGN1,COLOR7A7DFF;{71山天大畜-阳阳阳阴阴阳}
DRAWTEXT(x1 and s8,HIGH*1.04,'泰'),ALIGN1,COLOR7A91FF;{81地天泰-阳阳阳阴阴阴}
{//兑宫八卦,绿色系}
DRAWTEXT(x2 and s1,HIGH*1.04,'履'),ALIGN1,COLOR00A300;{12天泽履-阳阳阴阳阳阳}
DRAWTEXT(x2 and s2,HIGH*1.04,'兑'),ALIGN1,COLOR00FF00;{22兑为泽-阳阳阴阳阳阴}
DRAWTEXT(x2 and s3,HIGH*1.04,'睽'),ALIGN1,COLOR00FF00;{32火泽睽-阳阳阴阳阴阳}
DRAWTEXT(x2 and s4,HIGH*1.08,'归 妹'),ALIGN1,COLOR00FF00;{42雷泽归妹-阳阳阴阳阴阴}
DRAWTEXT(x2 and s5,HIGH*1.08,'中 孚'),ALIGN1,COLOR00FF00;{52风泽中孚-阳阳阴阴阳阳}
DRAWTEXT(x2 and s6,HIGH*1.04,'节'),ALIGN1,COLOR00FF00;{62水泽节-阳阳阴阴阳阴}
DRAWTEXT(x2 and s7,HIGH*1.04,'损'),ALIGN1,COLOR00FF00;{72山泽损-阳阳阴阴阴阳}
DRAWTEXT(x2 and s8,HIGH*1.04,'临'),ALIGN1,COLOR00FF00;{82地泽临-阳阳阴阴阴阴}
{//离宫八卦,黄色系}
DRAWTEXT(x3 and s1,HIGH*1.08,'同 人'),ALIGN1,COLOR00FFFF;{13天火同人-阳阴阳阳阳阳}
DRAWTEXT(x3 and s2,HIGH*1.04,'革'),ALIGN1,COLOR00FFFF;{23泽火革-阳阴阳阳阳阴}
DRAWTEXT(x3 and s3,HIGH*1.04,'离'),ALIGN1,COLOR00FFFF;{33离为火-阳阴阳阳阴阳}
DRAWTEXT(x3 and s4,HIGH*1.04,'丰'),ALIGN1,COLOR00FFFF;{43雷火丰-阳阴阳阳阴阴}
DRAWTEXT(x3 and s5,HIGH*1.08,'家 人'),ALIGN1,COLOR00FFFF;{53风火家人-阳阴阳阴阳阳}
DRAWTEXT(x3 and s6,HIGH*1.08,'既 济'),ALIGN1,COLOR00FFFF;{63水火既济-阳阴阳阴阳阴}
DRAWTEXT(x3 and s7,HIGH*1.04,'贲'),ALIGN1,COLOR00FFFF;{73火山贲-阳阴阳阴阴阳}
DRAWTEXT(x3 and s8,HIGH*1.08,'明 夷'),ALIGN1,COLOR00FFFF;{83地火明夷-阳阴阳阴阴阴}
{//震宫八卦,肉粉色系}
DRAWTEXT(x4 and s1,HIGH*1.08,'无 妄'),ALIGN1,COLORCCCCFF;{14天雷无妄-阳阴阴阳阳阳}
DRAWTEXT(x4 and s2,HIGH*1.04,'随'),ALIGN1,COLORCCCCFF;{24泽雷随-阳阴阴阳阳阴}
DRAWTEXT(x4 and s3,HIGH*1.08,'噬 嗑'),ALIGN1,COLORCCCCFF;{34火雷噬嗑-阳阴阴阳阴阳}
DRAWTEXT(x4 and s4,HIGH*1.04,'震'),ALIGN1,COLORCCCCFF;{44震为雷-阳阴阴阳阴阴}
DRAWTEXT(x4 and s5,HIGH*1.04,'益'),ALIGN1,COLORCCCCFF;{54风雷益-阳阴阴阴阳阳}
DRAWTEXT(x4 and s6,HIGH*1.04,'屯'),ALIGN1,COLORCCCCFF;{64水雷屯-阳阴阴阴阳阴}
DRAWTEXT(x4 and s7,HIGH*1.04,'颐'),ALIGN1,COLORCCCCFF;{74山雷颐-阳阴阴阴阴阳}
DRAWTEXT(x4 and s8,HIGH*1.04,'复'),ALIGN1,COLORCCCCFF;{84地雷复-阳阴阴阴阴阴}
{//巽宫八卦,紫色系}
DRAWTEXT(x5 and s1,HIGH*1.04,'姤'),ALIGN1,COLORFF00FF;{15天风姤-阴阳阳阳阳阳}
DRAWTEXT(x5 and s2,HIGH*1.08,'大 过'),ALIGN1,COLORFF00FF;{25泽风大过-阴阳阳阳阳阴}
DRAWTEXT(x5 and s3,HIGH*1.04,'鼎'),ALIGN1,COLORFF00FF;{35火风鼎-阴阳阳阳阴阳}
DRAWTEXT(x5 and s4,HIGH*1.04,'恒'),ALIGN1,COLORFF00FF;{45雷风恒-阴阳阳阳阴阴}
DRAWTEXT(x5 and s5,HIGH*1.04,'巽'),ALIGN1,COLORFF00FF;{55巽为风-阴阳阳阴阳阳}
DRAWTEXT(x5 and s6,HIGH*1.04,'井'),ALIGN1,COLORFF00FF;{65水风井-阴阳阳阴阳阴}
DRAWTEXT(x5 and s7,HIGH*1.04,'蛊'),ALIGN1,COLORFF00FF;{75山风蛊-阴阳阳阴阴阳}
DRAWTEXT(x5 and s8,HIGH*1.04,'升'),ALIGN1,COLORFF00FF;{85地风升-阴阳阳阴阴阴}
{//坎宫八卦,浅灰色系}
DRAWTEXT(x6 and s1,HIGH*1.04,'讼'),ALIGN1,COLORFFEADD;{16天水讼-阴阳阴阳阳阳}
DRAWTEXT(x6 and s2,HIGH*1.04,'困'),ALIGN1,COLORFFEADD;{26泽水困-阴阳阴阳阳阴}
DRAWTEXT(x6 and s3,HIGH*1.08,'末 济'),ALIGN1,COLORFFEADD;{36火水末济-阴阳阴阳阴阳}
DRAWTEXT(x6 and s4,HIGH*1.04,'解'),ALIGN1,COLORFFEADD;{46雷水解-阴阳阴阳阴阴}
DRAWTEXT(x6 and s5,HIGH*1.04,'涣'),ALIGN1,COLORFFEADD;{56风水涣-阴阳阴阴阳阳}
DRAWTEXT(x6 and s6,HIGH*1.04,'坎'),ALIGN1,COLORFFEADD;{66坎为水-阴阳阴阴阳阴}
DRAWTEXT(x6 and s7,HIGH*1.04,'蒙'),ALIGN1,COLORFFEADD;{76山水蒙-阴阳阴阴阴阳}
DRAWTEXT(x6 and s8,HIGH*1.04,'师'),ALIGN1,COLORFFEADD;{86地水师-阴阳阴阴阴阴}
{//艮宫八卦,浅兰色系}
DRAWTEXT(x7 and s1,HIGH*1.04,'遯'),ALIGN1,COLORFFFF00;{17天山遯-阴阴阳阳阳阳}
DRAWTEXT(x7 and s2,HIGH*1.04,'咸'),ALIGN1,COLORFFF300;{27泽山咸-阴阴阳阳阳阴}
DRAWTEXT(x7 and s3,HIGH*1.04,'旅'),ALIGN1,COLORFFE500;{37火山旅-阴阴阳阳阴阳}
DRAWTEXT(x7 and s4,HIGH*1.08,'小 过'),ALIGN1,COLORFFDB00;{47雷山小过-阴阴阳阳阴阴}
DRAWTEXT(x7 and s5,HIGH*1.04,'渐'),ALIGN1,COLORFFAB00;{57风山渐-阴阴阳阴阳阳}
DRAWTEXT(x7 and s6,HIGH*1.04,'蹇'),ALIGN1,COLORFF9800;{67水山蹇-阴阴阳阴阳阴}
DRAWTEXT(x7 and s7,HIGH*1.04,'艮'),ALIGN1,COLOREE9800;{77艮为山-阴阴阳阴阴阳}
DRAWTEXT(x7 and s8,HIGH*1.04,'谦'),ALIGN1,COLORCC9800;{87地山谦-阴阴阳阴阴阴}
{//坤宫八卦,浅咖啡色系}
DRAWTEXT(x8 and s1,HIGH*1.04,'否'),ALIGN1,COLOR90A9C1;{18天地否-阴阴阴阳阳阳}
DRAWTEXT(x8 and s2,HIGH*1.04,'萃'),ALIGN1,COLOR90A9C1;{28泽地萃-阴阴阴阳阳阴}
DRAWTEXT(x8 and s3,HIGH*1.04,'晋'),ALIGN1,COLOR90A9C1;{38火地晋-阴阴阴阳阴阳}
DRAWTEXT(x8 and s4,HIGH*1.04,'豫'),ALIGN1,COLOR90A9C1;{48雷地豫-阴阴阴阳阴阴}
DRAWTEXT(x8 and s5,HIGH*1.04,'观'),ALIGN1,COLOR90A9C1;{58风地观-阴阴阴阴阳阳}
DRAWTEXT(x8 and s6,HIGH*1.04,'比'),ALIGN1,COLOR90A9C1;{68水地比-阴阴阴阴阳阴}
DRAWTEXT(x8 and s7,HIGH*1.04,'剥'),ALIGN1,COLOR90A9C1;{78山地剥-阴阴阴阴阴阴阳}
DRAWTEXT(x8 and s8,HIGH*1.04,'坤'),ALIGN0,COLOR90A9C1;{88坤为地-阴阴阴阴阴阴};