-- [分享]日内趋势线的划法
//交易控制变量
variable:a1=0;
variable:a2=0;
variable:c1=0;
n1:=0.8;
n2:=2;
//*******************************
r1:=barslast(date<>ref(date,1)),linethick0;
r2:=ref(o,r1);
partline(r1>0,r2);
//*******************************
if barpos=1 then a2:=c;
if r1=0 and c>=o then
begin
a1:=barpos;
a2:=l-n2;
c1:=1;
end
if r1=0 and c<o then
begin
a1:=barpos;
a2:=h+n2;
c1:=-1;
end
r10:if(c1>0,a2+n1*(barpos-a1),a2-n1*(barpos-a1));
//----------------------------
if c1>0 and c<r10 then
begin
a1:=barpos;
a2:=h+n2;
c1:=-1;
end
if c1<0 and c>r10 then
begin
a1:=barpos;
a2:=l-n2;
c1:=1;
end
这个小程序是用来在日内划趋势线的;
1.如果把r10改为r10:if(c1>0,a2+n1*(barpos-a1)*(barpos-a1),a2-n1*(barpos-a1)*(barpos-a1));就变成抛物线了,注意n1的调整;
2.可根据k线的变化把n1做成动态的(对直线而言n1就是斜率);
3.可根据趋势线r10,画出通道线;
4.可根据趋势线可以做出很多的交易策略,大家各显神通吧,如果效果好把测试报告贴出来欣赏一下。
[此贴子已经被作者于2013-2-24 16:16:11编辑过]