Giorgos E. Siligardos's article,"Building Automatic Trendlines", introduces a simple mechanical method for automatic trendline construction using monoparametric trendlines.
Building trendlines requires identifying peaks and troughs. Therefore, an indicator to identify the price swings is needed.
For the correct construction of an active trendline indicator, one can use Indicator Builder, allowing you to use the powerful capabilities of the Improvian Language.
The following is the code for the active trendline indicator:
Active Trendline Indicator
Input
thresold:"Thresold in percent",1,0,100;
End_input
Var
array:pivot[4]:=-1;
sm:=SMA(c,5);
f1:= 0; f2:=f1;
pf1:= sm\f1\;
pf2:= sm\f2\;
f3:=0;
pf3:=0;
n:=historysize;
pc:=1;
k:=0;
y:=0;
End_var
While ((100*abs(pf1-pf2)/min(pf1,pf2)
Begin
f2:=f2+1;
pf2:= sm\f2\;
End;
f3:=f2;pf3:= sm\f3\;
While (f1<=n and pc<=4) Do
Begin
While (
((100*abs(pf2-pf3)/min(pf2,pf3)
Or
(((pf1pf2) And pf2>=pf3))))
And (f3
Begin
If (((pf1pf2) and (pf2>=pf3))) then
Begin
f2:=f3; pf2:= sm\f2\;
End;
f3:=f3+1; pf3:= sm\f3\;
End;
pivot[pc]:=f2; pc:=pc+1;
f1:=f2; pf1:= sm\f1\;
f2:=f3; pf2:= sm\f2\;
End;
if (pivot[1]-pivot[3]=0 or pivot[2]-pivot[4]=0) then return inf;
if pc<=4 then return inf;
{Constructing trend}
k:= (sm\pivot[1]\-sm\pivot[3]\)/(pivot[1]-pivot[3]);
k:= (k+ (sm\pivot[2]\- sm\pivot[4]\)/(pivot[2]-pivot[4])) / 2;
y:= pivot[1]*k + c\pivot[1]\;
return y;
|
Download to import into Tradecision. 
How to use this indicator in Tradecision:
- Click Download.
- Save this indicator in a safe location on your hard drive.
- Open Tradecision and in the Tools menu click Indicator Builder.
- In the Indicator Builder dialog, click Import, locate the saved file and then click OK.
The indicator will be added to the Custom Indicators list.
|