指标编辑入门9--SUPERTREN优化版
看了一下,上个版本想得太复杂了
这个版本结构更简单,更符合原指标的意思
{通达信版}
{SUPERTREN优化}
N:=10;M:=2.5;
TR1:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
UP:=(H+L)/2+MA(TR1,N)*M;
DN:=(H+L)/2-MA(TR1,N)*M;
L1:=REF(UP,BARSLAST(UP<=REF(UP,1)));
L2:=LLV(UP,N*1.5);
LL:=IF(L2!=REF(L2,1) AND L1<REF(L1,1),L1,IF(L1=L2,L1,L2));
S1:=BARSLAST(CROSS(0.5,UP=LL))+1;
S2:=CROSS(COUNT((CROSS(C,LL) OR CROSS(C,REF(LL,2))) AND UP>LL,S1),0.5);
A6:=BARSLAST(S2);
B6:=BARSLAST(CROSS(HHV(DN,A6+1),C));
BY:=CROSS(B6,A6);
SL:=CROSS(A6,B6);
DRAWKLINE(HIGH,OPEN,LOW,CLOSE);
SUPERTREN:IF(B6>A6,HHV(DN,BARSLAST(BY)+1),LLV(UP,BARSLAST(SL)+1)),COLORGREEN,LINETHICK2;
IF(B6>A6,SUPERTREN,DRAWNULL),COLOR0000C8,LINETHICK2;
DRAWICON(CROSS(B6,A6),SUPERTREN*0.99,1);
DRAWICON(CROSS(A6,B6),SUPERTREN*1.015,2);
买进:CROSS(B6,A6)*100,NODRAW,COLORRED;
卖出:CROSS(A6,B6)*100,NODRAW;
201374652680877.png
//////////////////////////////////////////////
{飞狐版}
n:=10;m:=2.5;
tr1:=max(max((high-low),abs(ref(close,1)-high)),abs(ref(close,1)-low));
up:=(h+l)/2+ma(tr1,n)*m;
dn:=(h+l)/2-ma(tr1,n)*m;
l1:=ref(up,barslast(up<=ref(up,1)));
l2:=llv(up,n*1.5);
ll:=if(l2<>ref(l2,1) and l1<ref(l1,1),l1,if(l1=l2,l1,l2));
s1:=barslast(cross(0.5,up=ll))+1;
s2:=cross(count((cross(c,ll) or cross(c,ref(ll,2))) and up>ll,s1),0.5);
a6:=barslast(s2);
b6:=barslast(cross(hhv(dn,a6+1),c));
by:=cross(b6,a6);
sl:=cross(a6,b6);
kline(o,h,l,c,0);
supertren:if(b6>a6,hhv(dn,barslast(by)+1),llv(up,barslast(sl)+1)),colorwhite;
partline(b6>a6,supertren),Color0000C8,linethick2;
partline(b6<a6,supertren),Color00C800,linethick2;
drawicon(cross(b6,a6),supertren*0.99,8),align1;
drawicon(cross(a6,b6),supertren*1.015,9),align1;
买进:cross(b6,a6)*100,linethick0;
卖出:cross(a6,b6)*100,linethick0;
2013746515056433.png
/////////////////////////////////////////////////
{大智慧版-基本函数}
n:=10;m:=2.5;
tr1:=max(max((high-low),abs(ref(close,1)-high)),abs(ref(close,1)-low));
up:=(h+l)/2+ma(tr1,n)*m;
dn:=(h+l)/2-ma(tr1,n)*m;
l1:=ref(up,barslast(up<=ref(up,1)));
l2:=llv(up,n*1.5);
ll:=if(l2<>ref(l2,1) and l1<ref(l1,1),l1,if(l1=l2,l1,l2));
s1:=barslast(cross(0.5,up=ll))+1;
s2:=cross(count((cross(c,ll) or cross(c,ref(ll,2))) and up>ll,s1),0.5);
a6:=barslast(s2);
b6:=barslast(cross(hhv(dn,a6+1),c));
by:=cross(b6,a6);
sl:=cross(a6,b6);
supertren:if(b6>a6,hhv(dn,barslast(by)+1),llv(up,barslast(sl)+1)),colorwhite,layer0;
partline(supertren,b6>a6,rgb(200,0,0),b6<a6,rgb(0,200,0)),linethick2,layer0;
drawicon(cross(b6,a6),supertren*0.99,7),align1,layer0;
drawicon(cross(a6,b6),supertren*1.015,8),align1,layer0;
{stickline(c>=o,c,o,7,1),color5454ff;
stickline(c>=o,h,max(c,o),0,0),color5454ff;
stickline(c>=o,l,min(c,o),0,0),color5454ff;
stickline(c<=o,c,o,7,0),colorffff54;
stickline(c<=o,h,max(c,o),0,0),colorffff54;
stickline(c<=o,l,min(c,o),0,0),colorffff54;}
买进:cross(b6,a6)*100,linethick0;
卖出:cross(a6,b6)*100,linethick0;
2013746514079234.png
|