Looking for someone to write the code into Tradovate for the Spearman Indicator. I have found this on other trading software but not here unfortunately. Please see below for script. I’m not a programmer and have no idea what this means but I like the indicator.

CALCULATION

//input = price, user defined, default is closing price

//method = moving average, user defined, default is SMA

//n = Spearman period, user defined, default is 10

//sigPeriod = signal period, user defined, default is 3

size = series.size();

r1 = new int[n+1];

r22 = new int[n+1];

r11 = new double[n+1];

r21 = new double[n+1];

temp = 0;

coefcorr = 0, sc = 0;

changed = 0, found = 0;

absum = 0, ab = 0, ab2 = 0 ;

for (int k = n; k lessThan size; k++ )

for (int i = n; i moreOrEqual 1; i–)

r1[i] = i;

r22[i] = i;

r11[i] = series.getDouble((k - n + i), key, 0);

r21[i] = series.getDouble((k - n + i), key, 0);

endFor

//sort r21 descending

changed = 1;

while (changed moreThan 0)

changed = 0;

for (int i = 1; i lessOrEqual (n-1); i++)

if (r21[i+1] lessThan r21[i])

temp = r21[i];

r21[i] = r21[i + 1];

r21[i+1] = temp;

changed = 1;

endIf

endFor

endWhile

////

for (int i = 1; i lessOrEqual n; i++)

found = 0;

while (found lessThan 1)

for (int j = 1; j lessOrEqual n; j++)

if (r21[j] == r11[i])

r22[i] = j;

found = 1;

endIf

endFor

endWhile

endFor

/////////

absum = 0;

for (int i = 1; i lessOrEqual; i++)

ab = r1[i] - r22[i];

ab2 = ab * ab;

absum = absum + ab2;

endFor

coefcorr = 1 - ((6 * absum) / (n * ((n * n) - 1)));

Plot: sc = 100 * coefcorr;

Plot: sig = ma(method, k, sigPeriod, SC);

end