The Spearman Indicator For Technical Analysis
The article by Dan Valku in this issue, “The Spearman Indicator For Technical Analysis”, has demonstrated a statistical tool that helps determine trend strength and turning points, and how it can be applied to trading.
Using Tradecision’s Indicator Builder, one needs to create the SPEARMAN indicator:
SPEARMAN indicator:
input
n:"Enter Number of periods:", 10;
price:"Enter the Price:", close;
end_input
var
i:=0;
j:=0;
tmp:=0;
absum:=0;
sqrVal:=0;
dif:=0;
Array:ranks[1000]:=0;
Array:valuesTmp[1000]:=0;
end_var
if HISTORYSIZE < n then return 0;
{Fill Values}
for i:= 1 to n do
begin
valuesTmp[i]:= price\n-i\;
end;
{Sort Values Descerding}
for i:= 1 to n - 1 do
begin
for j:= 1 to n - 1 do
begin
if valuesTmp[j+1] < valuesTmp[j] then
begin
tmp:=valuesTmp[j];
valuesTmp[j]:=valuesTmp[j+1];
valuesTmp[j+1]:=tmp;
end;
end;
end;
{Sort Ranks using Values}
for i:= 1 to n do
begin
for j:= 1 to n do
begin
if valuesTmp[j] = price\n-i\ then
begin
ranks[i] := j;
j := n + 1;
end;
end;
end;
for i:= 1 to n do
begin
dif := ( n - i + 1 ) - ranks[i];
sqrVal := dif*dif;
absum := absum + sqrVal;
end;
return (1 - (6*absum)/ (n*(n*n-1)))*100;
|
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.
|