全方位黄金分割+数浪(自动划线公式源码)
{时间黄金分割}{☆殊途同归☆ by天津 x1835}
{☆§提示:1计算机画线不能代替手工作图。
2确定历史数据完整。}
{精确的黄金分割是二分之根号五减一,即0.618=(SQRT(5)-1)/2}
{注释里有黄金分割的解释}
input:左侧右移(0),右侧左移(0),开关(1,1,2);
t1:=barpos=sysparam(2)+左侧右移;
t2:=barpos=sysparam(3)-右侧左移;
t11:=sysparam(2)+左侧右移;
t21:=sysparam(3)-右侧左移;
ymd:=date;
D1:ymd[t11],linethick0;
D2:ymd[t21],linethick0;
{D2:hhv(if(t2,date,0),0),linethick0;}
VERTLINE(t1),color00ffff,LINEDOT;
VERTLINE(t2),color00ffff,LINEDOT;
{d1:=if(t1 or t2,barpos,0);
dd:=d1;
x835:=SORTPOS(dd,1,1,datacount);
间隔:abs(d1[dd[1]]-d1[dd[2]]),linethick0;}
间隔:t21-t11,linethick0;
{ccc:ref(BARSTATUS=2,右侧左移);}
x1:=间隔*(0.191);
x8:=间隔*(0.382);
x05:=间隔*(0.5);
x3:=间隔*(0.618);
x5:=间隔*(0.809);
x1831:=sysparam(2)+左侧右移+ROUND(x1);
tx1:=BARPOS=x1831;
VERTLINE(tx1),colorffff33,LINEDOT;
D191:ymd[x1831],linethick0;
x1838:=t11+ROUND(x8);
tx8:=BARPOS=x1838;
VERTLINE(tx8),color00aaaa,LINEDOT;
D382:ymd[x1838],linethick0;
x18305:=t11+ROUND(x05);
tx05:=BARPOS=x18305;
VERTLINE(tx05),color0000ff,LINEDOT;
D05:ymd[x18305],linethick0;
x1833:=t11+ROUND(x3);
tx3:=BARPOS=x1833;
VERTLINE(tx3),color00aaaa,LINEDOT;
D618:ymd[x1833],linethick0;
x1835:=t11+ROUND(x5);
tx5:=BARPOS=x1835;
VERTLINE(tx5),colorffff33,LINEDOT;
D809:ymd[x1835],linethick0;
ph:=SYSPARAM(4);
pl:=SYSPARAM(5);
drawtext(t1,pl,STRLEFT(NUMTOSTR(d1+19000000,0),4)+STRRIGHT(NUMTOSTR(d1,0),4)),color00ffff;
drawtext(t2,pl,STRLEFT(NUMTOSTR(d2+19000000,0),4)+STRRIGHT(NUMTOSTR(d2,0),4)),color00ffff,align2;
drawtext(tx1,pl,STRLEFT(NUMTOSTR(d191+19000000,0),4)+STRRIGHT(NUMTOSTR(d191,0),4)),colorffff33;
drawtext(tx8,pl,STRLEFT(NUMTOSTR(d382+19000000,0),4)+STRRIGHT(NUMTOSTR(D382,0),4)),color00aaaa;
drawtext(tx05,pl,STRLEFT(NUMTOSTR(d05+19000000,0),4)+STRRIGHT(NUMTOSTR(D05,0),4)),color0000ff;
drawtext(tx3,pl,STRLEFT(NUMTOSTR(d618+19000000,0),4)+STRRIGHT(NUMTOSTR(D618,0),4)),color00aaaa;
drawtext(tx5,pl,STRLEFT(NUMTOSTR(d809+19000000,0),4)+STRRIGHT(NUMTOSTR(d809,0),4)),colorffff33;
drawtext(t1,ph*0.99,'0点'),color00ffff;
drawtext(t2,ph*0.99,'99.99%'),color00ffff,align2;
drawtext(tx1,ph*0.99,'0.191'),colorffff33;
drawtext(tx8,ph*0.99,'0.382'),color00aaaa;
drawtext(tx05,ph*0.99,'0.5'),color0000ff;
drawtext(tx3,ph*0.99,'0.618'),color00aaaa;
drawtext(tx5,ph*0.99,'0.809'),colorffff33;
if 开关=2 then
begin
x236:=间隔*(0.236);
x764:=间隔*(0.764);
x236:=sysparam(2)+左侧右移+ROUND(x236);
tx236:=BARPOS=x236;
VERTLINE(tx236),coloraaaaaa,LINEDOT;
D236:ymd[x236],linethick0;
x764:=t11+ROUND(x764);
tx764:=BARPOS=x764;
VERTLINE(tx764),coloraaaaaa,LINEDOT;
D764:ymd[x764],linethick0;
pllh:=(pl*4+ph)/5;
phhl:=(pl+ph*4)/5;
drawtext(tx236,pllh,STRLEFT(NUMTOSTR(d236+19000000,0),4)+STRRIGHT(NUMTOSTR(d236,0),4)),coloraaaaaa;
drawtext(tx764,pllh,STRLEFT(NUMTOSTR(d764+19000000,0),4)+STRRIGHT(NUMTOSTR(d764,0),4)),coloraaaaaa;
drawtext(tx236,phhl,'0.236'),coloraaaaaa;
drawtext(tx764,phhl,'0.764'),coloraaaaaa;
end;
{§历史影响现在,现在影响未来。§}
input:n(30,1,1000);
HH:HHV(H,N);
LL:LLV(L,N);
<%
VH=FFL.VARDATA("HH")
VL=FFL.VARDATA("LL")
VN=FFL.VARDATA("N")
LAST=UBOUND(VH)
IF VN>LAST THEN VN=LAST+1
FOR I=LAST TO LAST-VN+1 STEP-1
VH(I)=VH(LAST)
VL(I)=VL(LAST)
NEXT
FFL.VARDATA("HH")=VH
FFL.VARDATA("LL")=VL
FFL.VARSTARTINDEX("HH")=LAST-VN+1
FFL.VARSTARTINDEX("LL")=LAST-VN+1
%>
HH,color009999;
DRAWTEXT(c>0 and ISLASTBAR=1,HH,'【黄金分割】↑'),color009999;
DRAWNUMBER(BARSCOUNT(LL)=N-(N-1),HH,HH,2),align2,color009999;
LL+((HH-LL)*0.809),pointdot,linethick1,coloryellow;
DRAWTEXT(c>0 and ISLASTBAR=1,LL+((HH-LL)*0.809),' 0.809↑'),color009999;
DRAWNUMBER(BARSCOUNT(LL)=N-(N-1),LL+((HH-LL)*0.809),LL+((HH-LL)*0.809),2),align2,color009999;
LL+((HH-LL)*0.764),pointdot,linethick1,coloryellow;
DRAWTEXT(c>0 and ISLASTBAR=1,LL+((HH-LL)*0.764),' 0.764↑'),color009999;
DRAWNUMBER(BARSCOUNT(LL)=N-(N-1),LL+((HH-LL)*0.764),LL+((HH-LL)*0.764),2),align2,color009999;
LL+((HH-LL)*0.618),pointdot,linethick1,coloryellow;
DRAWTEXT(c>0 and ISLASTBAR=1,LL+((HH-LL)*0.618),' 0.618↑'),color009999;
DRAWNUMBER(BARSCOUNT(LL)=N-(N-1),LL+((HH-LL)*0.618),LL+((HH-LL)*0.618),2),align2,color009999;
LL+((HH-LL)*0.500),pointdot,linethick1,coloryellow;
DRAWTEXT(c>0 and ISLASTBAR=1,LL+((HH-LL)*0.500),' 0.500↑'),color009999;
DRAWNUMBER(BARSCOUNT(LL)=N-(N-1),LL+((HH-LL)*0.500),LL+((HH-LL)*0.500),2),align2,color009999;
LL+((HH-LL)*0.382),pointdot,linethick1,coloryellow;
DRAWTEXT(c>0 and ISLASTBAR=1,LL+((HH-LL)*0.382),' 0.382↑'),color009999;
DRAWNUMBER(BARSCOUNT(LL)=N-(N-1),LL+((HH-LL)*0.382),LL+((HH-LL)*0.382),2),align2,color009999;
LL+((HH-LL)*0.333),pointdot,linethick1,coloryellow;
DRAWTEXT(c>0 and ISLASTBAR=1,LL+((HH-LL)*0.333),' 0.333↑'),color009999;
DRAWNUMBER(BARSCOUNT(LL)=N-(N-1),LL+((HH-LL)*0.333),LL+((HH-LL)*0.333),2),align2,color009999;
LL+((HH-LL)*0.236),pointdot,linethick1,coloryellow;
DRAWTEXT(c>0 and ISLASTBAR=1,LL+((HH-LL)*0.236),' 0.236↑'),color009999;
DRAWNUMBER(BARSCOUNT(LL)=N-(N-1),LL+((HH-LL)*0.236),LL+((HH-LL)*0.236),2),align2,color009999;
LL+((HH-LL)*0.191),pointdot,linethick1,coloryellow;
DRAWTEXT(c>0 and ISLASTBAR=1,LL+((HH-LL)*0.191),' 0.191↑'),color009999;
DRAWNUMBER(BARSCOUNT(LL)=N-(N-1),LL+((HH-LL)*0.191),LL+((HH-LL)*0.191),2),align2,color009999;
LL,color009999;
DRAWTEXT(c>0 and ISLASTBAR=1,LL,'〖底部起点〗↑'),color009999;
DRAWNUMBER(BARSCOUNT(LL)=N-(N-1),LL,LL,2),align2,coloryellow;
fbars:=SYSPARAM(0);
f5:=barssince(c)=fbars-1;
VERTLINE(f5),pointdot,color996666,linethick1,shift5;
DRAWNUMBER(f5,SYSPARAM(4),5,0),shift5;
ff5:=barssince(c)=fbars-5;
VERTLINE(ff5),pointdot,color996666,linethick1;
DRAWNUMBER(ff5,SYSPARAM(4),5,0);
f8:=barssince(c)=fbars-1;
ff8:=barssince(c)=fbars-8;
VERTLINE(f8),pointdot,color996666,linethick1,shift8;
DRAWNUMBER(f8,SYSPARAM(4),8,0),shift8;
VERTLINE(ff8),pointdot,color996666,linethick1;
DRAWNUMBER(ff8,SYSPARAM(4),8,0);
f13:=barssince(c)=fbars-1;
ff13:=barssince(c)=fbars-13;
vertline(f13),pointdot,color996666,linethick1,shift13;
DRAWNUMBER(f13,SYSPARAM(4),13,0),shift13;
vertline(ff13),pointdot,color996666,linethick1;
DRAWNUMBER(ff13,SYSPARAM(4),13,0);
f21:=barssince(c)=fbars-1;
ff21:=barssince(c)=fbars-21;
vertline(f21),pointdot,color996666,linethick1,shift21;
DRAWNUMBER(f21,SYSPARAM(4),21,0),shift21;
vertline(ff21),pointdot,color996666,linethick1;
DRAWNUMBER(ff21,SYSPARAM(4),21,0);
f34:=barssince(c)=fbars-1;
ff34:=barssince(c)=fbars-34;
vertline( |