INPUT:N1(5,1,300),N2(10,1,300),N3(30,1,300);
d:=BacKSET(BARSTATUS=2,BArslAST(llv(l,0)=l)+1);
LS:=if(BARSTATUS=2,llv(l,250),9999);;
d1:=BACKSET(BARSTATUS=2,BARSLAST(llv(l,250)=l or BARSTATUS=1));
LD:=llVALL(LS);
qkg:=(l>ref(h,1))*d;;
gqk:=if(d=1 and qkg*ref(h,1)
g:=BACKSET(BARSTATUS=2,BARSLAST(hhv(h,0)=h)+1);
hS:=hhv(h,250);
g1:=BACKSET(BARSTATUS=2,BARSLAST(hS=h)+1);
HG:=HHVALL(g1*hS);
qkd:=(H
dqk:=if(g=1 and qkd*ref(l,1)>HG,qkd,if(g1,qkd,0));
dqks:=sum(dqk,0);
qkZ:=l>ref(h,1) or h
QKS1:=SUM(QKZ,0);
qks:=gqks+dqks;
qklx:=if(href(h,1),2,0));
s:=HHVALL(qks)+1;
ds:s-qks,LINETHICK0;
ll:=L;
hh:=h;
t1:=BARSSINCE(dS=1)+1;
l1:=ref(l,T1);
h1:=ref(H,t1);
s1:=Any(H1>=ll,t1);
x1:=Any(l1<=hh,t1);
t2:=BARSSINCE(dS=2)+1;
L2:=ref(l,T2);
h2:=ref(H,t2);
s2:=Any(H2>=ll,t2);
x2:=Any(l2<=hh,t2);
t3:=BARSSINCE(dS=3)+1;
l3:=ref(l,T3);
h3:=ref(H,t3);
s3:=Any(H3>=ll,t3);
x3:=Any(l3<=hh,t3);
t4:=BARSSINCE(dS=4)+1;
l4:=ref(l,T4);
h4:=ref(H,t4);
s4:=Any(H4>=ll,t4);
x4:=Any(l4<=hh,t4);
t5:=BARSSINCE(dS=5)+1;
l5:=ref(l,T5);
h5:=ref(H,t5);
s5:=Any(H5>=ll,t5);
x5:=Any(l5<=hh,t5);
t6:=BARSSINCE(dS=6)+1;
l6:=ref(l,T6);
h6:=ref(H,t6);
s6:=Any(H6>=ll,t6);
x6:=Any(l6<=hh,t6);
t7:=BARSSINCE(dS=7)+1;
l7:=ref(l,T7);
h7:=ref(H,t7);
s7:=Any(H7>=ll,t7);
x7:=Any(l7<=hh,t7);
t8:=BARSSINCE(dS=8)+1;
l8:=ref(l,T8);
h8:=ref(H,t8);
s8:=Any(H8>=ll,t8);
x8:=Any(l8<=hh,t8);
t9:=BARSSINCE(dS=9)+1;
l9:=ref(l,T9);
h9:=ref(H,t9);
s9:=Any(H9>=ll,t9);
x9:=Any(l9<=hh,t9);
t10:=BARSSINCE(dS=10)+1;
l10:=ref(l,T10);
h10:=ref(H,t10);
s10:=Any(H10>=ll,t10);
x10:=Any(l10<=hh,t10);
t11:=BARSSINCE(dS=11)+1;
l11:=ref(l,T11);
h11:=ref(H,t11);
s11:=Any(H11>=ll,t11);
x11:=Any(l11<=hh,t11);
t12:=BARSSINCE(dS=12)+1;
l12:=ref(l,T12);
h12:=ref(H,t12);
s12:=Any(H12>=ll,t12);
x12:=Any(l12<=hh,t12);
t13:=BARSSINCE(dS=13)+1;
l13:=ref(l,T13);
h13:=ref(H,t13);
s13:=Any(H13>=ll,t13);
x13:=Any(l13<=hh,t13);
t14:=BARSSINCE(dS=14)+1;
l14:=ref(l,T14);
h14:=ref(H,t14);
s14:=Any(H14>=ll,t14);
x14:=Any(l14<=hh,t14);
t15:=BARSSINCE(dS=15)+1;
l15:=ref(l,T15);
h15:=ref(H,t15);
s15:=Any(H15>=ll,t15);
x15:=Any(l15<=hh,t15);
t16:=BARSSINCE(dS=16)+1;
l16:=ref(l,T16);
h16:=ref(H,t16);
s16:=Any(H16>=ll,t16);
x16:=Any(l16<=hh,t16);
t17:=BARSSINCE(dS=17)+1;
l17:=ref(l,T17);
h17:=ref(H,t17);
s17:=Any(H17>=ll,t17);
x17:=Any(l17<=hh,t17);
t18:=BARSSINCE(dS=18)+1;
l18:=ref(l,T18);
h18:=ref(H,t18);
s18:=Any(H18>=ll,t18);
x18:=Any(l18<=hh,t18);
t19:=BARSSINCE(dS=19)+1;
l19:=ref(l,T19);
h19:=ref(H,t19);
s19:=Any(H19>=ll,t19);
x19:=Any(l19<=hh,t19);
t20:=BARSSINCE(dS=20)+1;
l20:=ref(l,T20);
h20:=ref(H,t20);
s20:=Any(H20>=ll,t20);
x20:=Any(l20<=hh,t20);
t21:=BARSSINCE(dS=21)+1;
l21:=ref(l,T21);
h21:=ref(H,t21);
s21:=Any(H21>=ll,t21);
x21:=Any(l21<=hh,t21);
t22:=BARSSINCE(dS=22)+1;
l22:=ref(l,T22);
h22:=ref(H,t22);
s22:=Any(H22>=ll,t22);
x22:=Any(l22<=hh,t22);
t23:=BARSSINCE(dS=23)+1;
l23:=ref(l,T23);
h23:=ref(H,t23);
s23:=Any(H23>=ll,t23);
x23:=Any(l23<=hh,t23);
t24:=BARSSINCE(dS=24)+1;
l24:=ref(l,T24);
h24:=ref(H,t24);
s24:=Any(H24>=ll,t24);
x24:=Any(l24<=hh,t24);
t25:=BARSSINCE(dS=25)+1;
l25:=ref(l,T25);
h25:=ref(H,t25);
s25:=Any(H25>=ll,t25);
x25:=Any(l25<=hh,t25);
t26:=BARSSINCE(dS=26)+1;
l26:=ref(l,T26);
h26:=ref(H,t26);
s26:=Any(H26>=ll,t26);
x26:=Any(l26<=hh,t26);
t27:=BARSSINCE(dS=27)+1;
l27:=ref(l,T27);
h27:=ref(H,t27);
s27:=Any(H27>=ll,t27);
x27:=Any(l27<=hh,t27);
t28:=BARSSINCE(dS=28)+1;
l28:=ref(l,T28);
h28:=ref(H,t28);
s28:=Any(H28>=ll,t28);
x28:=Any(l28<=hh,t28);
t29:=BARSSINCE(dS=29)+1;
l29:=ref(l,T29);
h29:=ref(H,t29);
s29:=Any(H29>=ll,t29);
x29:=Any(l29<=hh,t29);
t30:=BARSSINCE(dS=30)+1;
l30:=ref(l,T30);
h30:=ref(H,t30);
s30:=Any(H30>=ll,t30);
x30:=Any(l30<=hh,t30);
t31:=BARSSINCE(dS=31)+1;
l31:=ref(l,T31);
h31:=ref(H,t31);
s31:=Any(H31>=ll,t31);
x31:=Any(l31<=hh,t31);
t32:=BARSSINCE(dS=32)+1;
l32:=ref(l,T32);
h32:=ref(H,t32);
s32:=Any(H32>=ll,t32);
x32:=Any(l32<=hh,t32);
t33:=BARSSINCE(dS=33)+1;
l33:=ref(l,T33);
h33:=ref(H,t33);
s33:=Any(H33>=ll,t33);
x33:=Any(l33<=hh,t33);
t34:=BARSSINCE(dS=34)+1;
l34:=ref(l,T34);
h34:=ref(H,t34);
s34:=Any(H34>=ll,t34);
x34:=Any(l34<=hh,t34);
t35:=BARSSINCE(dS=35)+1;
l35:=ref(l,T35);
h35:=ref(H,t35);
s35:=Any(H35>=ll,t35);
x35:=Any(l35<=hh,t35);
t36:=BARSSINCE(dS=36)+1;
l36:=ref(l,T36);
h36:=ref(H,t36);
s36:=Any(H36>=ll,t36);
x36:=Any(l36<=hh,t36);
t37:=BARSSINCE(dS=37)+1;
l37:=ref(l,T37);
h37:=ref(H,t37);
s37:=Any(H37>=ll,t37);
x37:=Any(l37<=hh,t37);
t38:=BARSSINCE(dS=38)+1;
l38:=ref(l,T38);
h38:=ref(H,t38);
s38:=Any(H38>=ll,t38);
x38:=Any(l38<=hh,t38);
t39:=BARSSINCE(dS=39)+1;
l39:=ref(l,T39);
h39:=ref(H,t39);
s39:=Any(H39>=ll,t39);
x39:=Any(l39<=hh,t39);
t40:=BARSSINCE(dS=40)+1;
l40:=ref(l,T40);
h40:=ref(H,t40);
s40:=Any(H40>=ll,t40);
x40:=Any(l40<=hh,t40);
t41:=BARSSINCE(dS=41)+1;
l41:=ref(l,T41);
h41:=ref(H,t41);
s41:=Any(H41>=ll,t41);
x41:=Any(l41<=hh,t41);
t42:=BARSSINCE(dS=42)+1;
l42:=ref(l,T42);
h42:=ref(H,t42);
s42:=Any(H42>=ll,t42);
x42:=Any(l42<=hh,t42);
t43:=BARSSINCE(dS=43)+1;
l43:=ref(l,T43);
h43:=ref(H,t43);
s43:=Any(H43>=ll,t43);
x43:=Any(l43<=hh,t43);
t44:=BARSSINCE(dS=44)+1;
l44:=ref(l,T44);
h44:=ref(H,t44);
s44:=Any(H44>=ll,t44);
x44:=Any(l44<=hh,t44);
t45:=BARSSINCE(dS=45)+1;
l45:=ref(l,T45);
h45:=ref(H,t45);
s45:=Any(H45>=ll,t45);
x45:=Any(l45<=hh,t45);
t46:=BARSSINCE(dS=46)+1;
l46:=ref(l,T46);
h46:=ref(H,t46);
s46:=Any(H46>=ll,t46);
x46:=Any(l46<=hh,t46);
t47:=BARSSINCE(dS=47)+1;
l47:=ref(l,T47);
h47:=ref(H,t47);
s47:=Any(H47>=ll,t47);
x47:=Any(l47<=hh,t47);
t48:=BARSSINCE(dS=48)+1;
l48:=ref(l,T48);
h48:=ref(H,t48);
s48:=Any(H48>=ll,t48);
x48:=Any(l48<=hh,t48);
t49:=BARSSINCE(dS=49)+1;
l49:=ref(l,T49);
h49:=ref(H,t49);
s49:=Any(H49>=ll,t49);
x49:=Any(l49<=hh,t49);
t50:=BARSSINCE(dS=50)+1;
l50:=ref(l,T50);
h50:=ref(H,t50);
s50:=Any(H50>=ll,t50);
x50:=Any(l50<=hh,t50);
t51:=BARSSINCE(dS=51)+1;
l51:=ref(l,T51);
h51:=ref(H,t51);
s51:=Any(H51>=ll,t51);
x51:=Any(l51<=hh,t51);
t52:=BARSSINCE(dS=52)+1;
l52:=ref(l,T52);
h52:=ref(H,t52);
s52:=Any(H52>=ll,t52);
x52:=Any(l52<=hh,t52);
t53:=BARSSINCE(dS=53)+1;
l53:=ref(l,T53);
h53:=ref(H,t53);
s53:=Any(H53>=ll,t53);
x53:=Any(l53<=hh,t53);
t54:=BARSSINCE(dS=54)+1;
l54:=ref(l,T54);
h54:=ref(H,t54);
s54:=Any(H54>=ll,t54);
x54:=Any(l54<=hh,t54);
t55:=BARSSINCE(dS=55)+1;
l55:=ref(l,T55);
h55:=ref(H,t55);
s55:=Any(H55>=ll,t55);
x55:=Any(l55<=hh,t55);
t56:=BARSSINCE(dS=56)+1;
l56:=ref(l,T56);
h56:=ref(H,t56);
s56:=Any(H56>=ll,t56);
x56:=Any(l56<=hh,t56);
t57:=BARSSINCE(dS=57)+1;
l57:=ref(l,T57);
h57:=ref(H,t57);
s57:=Any(H57>=ll,t57);
x57:=Any(l57<=hh,t57);
t58:=BARSSINCE(dS=58)+1;
l58:=ref(l,T58);
h58:=ref(H,t58);
s58:=Any(H58>=ll,t58);
x58:=Any(l58<=hh,t58);
t59:=BARSSINCE(dS=59)+1;
l59:=ref(l,T59);
h59:=ref(H,t59);
s59:=Any(H59>=ll,t59);
x59:=Any(l59<=hh,t59);
t60:=BARSSINCE(dS=60)+1;
l60:=ref(l,T60);
h60:=ref(H,t60);
s60:=Any(H60>=ll,t60);
x60:=Any(l60<=hh,t60);
t61:=BARSSINCE(qkS=0)+1;
l61:=ref(l,T61);
h61:=ref(H,t61);
s61:=Any(H61>=ll,t61);
x61:=Any(l61<=hh,t61);
w1:=BARSTATUS=2 and x1=0 or s1=0;
ww1:=if(w1*t1,w1*t1,9999);
w2:=BARSTATUS=2 and x2=0 or s2=0;
ww2:=if(w2*t2,w2*t2,9999);
w3:=BARSTATUS=2 and x3=0 or s3=0;
ww3:=if(w3*t3,w3*t3,9999);
w4:=BARSTATUS=2 and x4=0 or s4=0;
ww4:=if(w4*t4,w4*t4,9999);
w5:=BARSTATUS=2 and x5=0 or s5=0;
ww5:=if(w5*t5,w5*t5,9999);
w6:=BARSTATUS=2 and x6=0 or s6=0;
ww6:=if(w6*t6,w6*t6,9999);
w7:=BARSTATUS=2 and x7=0 or s7=0;
ww7:=if(w7*t7,w7*t7,9999);
w8:=BARSTATUS=2 and x8=0 or s8=0;
ww8:=if(w8*t8,w8*t8,9999);
w9:=BARSTATUS=2 and x9=0 or s9=0;
ww9:=if(w9*t9,w9*t9,9999);
w10:=BARSTATUS=2 and x10=0 or s10=0;
ww10:=if(w10*t10,w10*t10,9999);
w11:=BARSTATUS=2 and x11=0 or s11=0;
ww11:=if(w11*t11,w11*t11,9999);
w12:=BARSTATUS=2 and x12=0 or s12=0;
ww12:=if(w12*t12,w12*t12,9999);
w13:=BARSTATUS=2 and x13=0 or s13=0;
ww13:=if(w13*t13,w13*t13,9999);
w14:=BARSTATUS=2 and x14=0 or s14=0;
ww14:=if(w14*t14,w14*t14,9999);
w15:=BARSTATUS=2 and x15=0 or s15=0;
ww15:=if(w15*t15,w15*t15,9999);
w16:=BARSTATUS=2 and x16=0 or s16=0;
ww16:=if(w16*t16,w16*t16,9999);
w17:=BARSTATUS=2 and x17=0 or s17=0;
ww17:=if(w17*t17,w17*t17,9999);
w18:=BARSTATUS=2 and x18=0 or s18=0;
ww18:=if(w18*t18,w18*t18,9999);
w19:=BARSTATUS=2 and x19=0 or s19=0;
ww19:=if(w19*t19,w19*t19,9999);
w20:=BARSTATUS=2 and x20=0 or s20=0;
ww20:=if(w20*t20,w20*t20,9999);
w21:=BARSTATUS=2 and x21=0 or s21=0;
ww21:=if(w21*t21,w21*t21,9999);
w22:=BARSTATUS=2 and x22=0 or s22=0;
ww22:=if(w22*t22,w22*t22,9999);
w23:=BARSTATUS=2 and x23=0 or s23=0;
ww23:=if(w23*t23,w23*t23,9999);
w24:=BARSTATUS=2 and x24=0 or s24=0;
ww24:=if(w24*t24,w24*t24,9999);
w25:=BARSTATUS=2 and x25=0 or s25=0;
ww25:=if(w25*t25,w25*t25,9999);
w26:=BARSTATUS=2 and x26=0 or s26=0;
ww26:=if(w26*t26,w26*t26,9999);
w27:=BARSTATUS=2 and x27=0 or s27=0;
ww27:=if(w27*t27,w27*t27,9999);
w28:=BARSTATUS=2 and x28=0 or s28=0;
ww28:=if(w28*t28,w28*t28,9999);
w29:=BARSTATUS=2 and x29=0 or s29=0;
ww29:=if(w29*t29,w29*t29,9999);
w30:=BARSTATUS=2 and x30=0 or s30=0;
ww30:=if(w30*t30,w30*t30,9999);
w31:=BARSTATUS=2 and x31=0 or s31=0;
ww31:=if(w31*t31,w31*t31,9999);
w32:=BARSTATUS=2 and x32=0 or s32=0;
ww32:=if(w32*t32,w32*t32,9999);
w33:=BARSTATUS=2 and x33=0 or s33=0;
ww33:=if(w33*t33,w33*t33,9999);
w34:=BARSTATUS=2 and x34=0 or s34=0;
ww34:=if(w34*t34,w34*t34,9999);
w35:=BARSTATUS=2 and x35=0 or s35=0;
ww35:=if(w35*t35,w35*t35,9999);
w36:=BARSTATUS=2 and x36=0 or s36=0;
ww36:=if(w36*t36,w36*t36,9999);
w37:=BARSTATUS=32 and x37=0 or s37=0;
ww37:=if(w37*t37,w37*t37,9999);
w38:=BARSTATUS=2 and x38=0 or s38=0;
ww38:=if(w38*t38,w38*t38,9999);
w39:=BARSTATUS=2 and x39=0 or s39=0;
ww39:=if(w39*t39,w39*t39,9999);
w40:=BARSTATUS=2 and x40=0 or s40=0;
ww40:=if(w40*t40,w40*t40,9999);
w41:=BARSTATUS=2 and x41=0 or s41=0;
ww41:=if(w41*t41,w41*t41,9999);
w42:=BARSTATUS=2 and x42=0 or s42=0;
ww42:=if(w42*t42,w42*t42,9999);
w43:=BARSTATUS=2 and x43=0 or s43=0;
ww43:=if(w43*t43,w43*t43,9999);
w44:=BARSTATUS=2 and x44=0 or s44=0;
ww44:=if(w44*t44,w44*t44,9999);
w45:=BARSTATUS=2 and x45=0 or s45=0;
ww45:=if(w45*t45,w45*t45,9999);
w46:=BARSTATUS=2 and x46=0 or s46=0;
ww46:=if(w46*t46,w46*t46,9999);
w47:=BARSTATUS=2 and x47=0 or s47=0;
ww47:=if(w47*t47,w47*t47,9999);
w48:=BARSTATUS=2 and x48=0 or s48=0;
ww48:=if(w48*t48,w48*t48,9999);
w49:=BARSTATUS=2 and x49=0 or s49=0;
ww49:=if(w49*t49,w49*t49,9999);
w50:=BARSTATUS=2 and x50=0 or s50=0;
ww50:=if(w50*t50,w50*t50,9999);
w51:=BARSTATUS=2 and x51=0 or s51=0;
ww51:=if(w51*t51,w51*t51,9999);
w52:=BARSTATUS=2 and x52=0 or s52=0;
ww52:=if(w52*t52,w52*t52,9999);
w53:=BARSTATUS=2 and x53=0 or s53=0;
ww53:=if(w53*t53,w53*t53,9999);
w54:=BARSTATUS=2 and x54=0 or s54=0;
ww54:=if(w54*t54,w54*t54,9999);
w55:=BARSTATUS=2 and x55=0 or s55=0;
ww55:=if(w55*t55,w55*t55,9999);
w56:=BARSTATUS=2 and x56=0 or s56=0;
ww56:=if(w56*t56,w56*t56,9999);
w57:=BARSTATUS=2 and x57=0 or s57=0;
ww57:=if(w57*t57,w57*t57,9999);
w58:=BARSTATUS=2 and x58=0 or s58=0;
ww58:=if(w58*t58,w58*t58,9999);
w59:=BARSTATUS=2 and x59=0 or s59=0;
ww59:=if(w59*t59,w59*t59,9999);
w60:=BARSTATUS=2 and x60=0 or s60=0;
ww60:=if(w60*t60,w60*t60,9999);
w61:=BARSTATUS=2 and x61=0 or s61=0;
ww61:=if(w61*t61,w61*t61,9999);
min1:=min(ww1,ww2,ww3,ww4,ww5,ww6,ww7,ww8,ww9,ww10,ww11,ww12,ww13,ww14,ww15,ww16);
min2:=min(ww17,ww18,ww19,ww20,ww21,ww22,ww23,ww24,ww25,ww26,ww27,ww28,ww29,ww30,ww31,ww32);
min3:=min(ww33,ww34,ww35,ww36,ww37,ww38,ww39,ww40,ww41,ww42,ww43,ww44,ww45,ww46,ww47,ww48);
min4:=min(ww49,ww50,ww51,ww52,ww53,ww54,ww55,ww56,ww57,ww58,ww59,ww60,ww61,min1,min2,min3);
min5a:=if(min4>=9999,0,min4);
min5:=if(BARSTATUS=2,min4,0);
w:=BACKSET(BARSTATUS=2,min5);
tx:=BARSSINCE(w);
qklx1:=ref(qklx,tx);
qkh:=ref(H,tx+1);
qkl:=ref(l,tx+1);
qkhl:=if(qklx1=2,qkh,if(qklx1=1,qkl,0));
wl:=LLv(L,tx+1);
wh:=hhv(h,tx+1);
wl1:=LLVALL(wl);
wh1:=hhVALL(wh);
whl:=if(qklx1=2,wl1,if(qklx1=1,wh1,0));
DRAWTEXT(tx=0 and qklx=1,qkl,''+NUMTOSTRN(wh1,2)+'-'+NUMTOSTRN(qkl,2)),VALIGN2,colorwhite;
DRAWTEXT(tx=0 and qklx=2,qkh,''+NUMTOSTRN(qkh,2)+'-'+NUMTOSTRN(wl1,2)),VALIGN0,colorwhite;
STICKLINE(w,qkhl,whl,13,0),COLORGRAY,LAYER0;
ma5:ma(c,n1),COLORWHITE,LAYER0;
ma10:ma(c,n2),COLORYELLOW,LAYER0;
ma30:ma(c,n3),COLORMAGENTA,LAYER0;