Sunday, 21 June 2015

Sử dụng autotrend trong Metastock

Dùng auto trend để vẽ đường xu hướng một cách tự động
Làm thế nào để sử dụng Autotrend trong Metastock




http://www.v2htrader.com/search/label/metastock%20code

- Vào Metastock
- Chuyển đến Tools-> Indicator Builder -> New 




 - Copy và dán mã code bên dưới vào hộp Indicator Editor và lưu với tên auto trend




pds:=
 Input("average trend length periods",2,252,21);
pr:=Input("Open=1 High=2 Low=3 Close=4 Vol=5 MP=6, P=7",1,7,4);
display:=Input("plot Trend line = 1, Trend points = 2",1,2,1);

{define events}
pr:=If(pr=1,O,If(pr=2,H,If(pr=3,L,If(pr=5,V,
If(pr=6,MP(),If(pr=7,P,C))))));
price1:=pr;
price2:=pr;
time1:=price1>Ref(HHV(price1,pds),-1);
time2:=price2=t2pds,time1,time2);
x2:=If(t1pds>=t2pds,time2,time1);
y1:=If(t1pds>=t2pds,price1,price2);
y2:=If(t1pds>=t2pds,price2,price1);

{fix coordinates}
y1:=ValueWhen(1,x1,y1);
y2:=LastValue(ValueWhen(1,x2,y2));
b1:=LastValue(BarsSince(x1));
b2:=LastValue(BarsSince(x2));
plot:=y1+BarsSince(x1)*(y2-y1)/(b1-b2);

If(display=1,plot,time1+time2)

No comments: