VARIABLE: ljhs=0,cyc5=0,ljhs2=0,cyc13=0,ljhs3=0,cyc34=0,ljhsm=0,cycmax=0;
mid:=(o+c)/2;
hsl:=if(capital=0,v/sum(v,100),v/capital);
ljhs:=if(BARPOS=1,hsl,ljhs*(1-hsl)*(5-1)/5+hsl);
cyc5:if(BARPOS=1,mid,(mid*hsl+cyc5*ref(ljhs,1)*(1-hsl)*(5-1)/5)/ljhs);
ljhs2:=if(BARPOS=1,hsl,ljhs2*(1-hsl)*(13-1)/13+hsl);
cyc13:if(BARPOS=1,mid,(mid*hsl+cyc13*ref(ljhs2,1)*(1-hsl)*(13-1)/13)/ljhs2);
ljhs3:=if(BARPOS=1,hsl,ljhs3*(1-hsl)*(34-1)/34+hsl);
cyc34:if(BARPOS=1,mid,(mid*hsl+cyc34*ref(ljhs3,1)*(1-hsl)*(34-1)/34)/ljhs3);
ljhsm:=if(BARPOS=1,hsl,ljhsm*(1-hsl)+hsl);
cycmax:if(BARPOS=1,mid,(mid*hsl+cycmax*ref(ljhsm,1)*(1-hsl))/ljhsm);
解答如下:
mid := (OPEN+CLOSE)/2;
hsl:=IF(CAPITAL=0,VOL/SUM(VOL,100),VOL/CAPITAL);
ljhs := hsl;
cyc1 := mid;
ljhs2:= hsl;
cyc2 := mid;
ljhs3:= hsl;
cyc3 := mid;
ljhsm:= hsl;
cycm := mid;
<%
vmid = ffl.vardata("mid")
vhsl = ffl.vardata("hsl")
vljhs = ffl.vardata("ljhs")
vljhs2 = ffl.vardata("ljhs2")
vljhs3 = ffl.vardata("ljhs3")
vljhsm = ffl.vardata("ljhsm")
vcyc1 = ffl.vardata("cyc1")
vcyc2 = ffl.vardata("cyc2")
vcyc3 = ffl.vardata("cyc3")
vcycm = ffl.vardata("cycm")
last=ubound(vmid)
for i=1 to last
vljhs(i) = vljhs(i -1) * (1 - vhsl(i)) * 7 / 8 + vhsl(i)
vcyc1(i) = (vmid(i) * vhsl(i) + vcyc1(i-1) * vljhs(i -1) * (1 - vhsl(i)) * 7 / 8) / vljhs(i)
vljhs2(i) = vljhs2(i -1) * (1 - vhsl(i)) * 20 / 21 + vhsl(i)
vcyc2(i) = (vmid(i) * vhsl(i) + vcyc2(i-1) * vljhs2(i -1) * (1 - vhsl(i)) * 20 / 21) / vljhs2(i)
vljhs3(i) = vljhs3(i -1) * (1 - vhsl(i)) * 59 / 60 + vhsl(i)
vcyc3(i) = (vmid(i) * vhsl(i) + vcyc3(i-1) * vljhs3(i -1) * (1 - vhsl(i)) * 59 / 60) / vljhs3(i)
vljhsm(i) = vljhsm(i -1) * (1 - vhsl(i)) + vhsl(i)
vcycm(i) = (vmid(i) * vhsl(i) + vcycm(i-1) * vljhsm(i -1) * (1 - vhsl(i))) / vljhsm(i)
next
ffl.vardata("ljhs") = vljhs
ffl.vardata("ljhs2") = vljhs2
ffl.vardata("ljhs3") = vljhs3
ffl.vardata("ljhsm") = vljhsm
ffl.vardata("cyc1") = vcyc1
ffl.vardata("cyc2") = vcyc2
ffl.vardata("cyc3") = vcyc3
ffl.vardata("cycm") = vcycm
%>
MAC〔8〕:cyc1,coloryellow;
MAC〔21〕:cyc2,COLORMAGENTA;
MAC〔60〕:cyc3,colorgreen;
MAC〔∞〕:cycm,COLORBLUE,LINETHICK2;