Hello i'm relatively new to these forums although I've been using eSignal for some time.
I've written an EFS indicator for charting, and my goal was to show a correlation (number displayed between 0 and 1) between individual stocks and an index (SP500) over the first hour of the last 20 opens.
Please review my code, all comments and suggestions are welcome. TIA for the help. I'm wondering if my problems could be due to calling multiple symbols on multiple intervals for comparison? Or any other obvious errors you can spot
Thanx for your help
I've written an EFS indicator for charting, and my goal was to show a correlation (number displayed between 0 and 1) between individual stocks and an index (SP500) over the first hour of the last 20 opens.
Please review my code, all comments and suggestions are welcome. TIA for the help. I'm wondering if my problems could be due to calling multiple symbols on multiple intervals for comparison? Or any other obvious errors you can spot
PHP Code:
function computeCorrel( sSymb, nDays ) {
var x,y;
var count, spCash, spFuture, spInt, spDivRate, spDaysExp, spFV, FV, fvDiffPercent, fvMult = 0;
var nTmp, nTmp2=0;
var nTmpStr;
spInt = 0.074;
spDivRate = 2.03;
spDaysLeft = 90;
var symbDay = sSymb + ",D";
var symb5min = sSymb + ",5";
for (x=1; x=nDays; x++) {
spCash = close(-x, sym("IN A0,D"));
spFuture = close(-x, sym("ES U8,D"));
spFV = spCash*(1 + (spInt - spDivRate)*(spDaysExp/360));
fvMult = (spFuture - spCash*(spFV - spCash))/spCash;
FV = close(-x, sym(symbDay))*fvMult;
fvDiffPercent = (open(-x+1, sym(symbDay))-FV)/FV;
if (Math.abs(fvDiffPercent) > 0.005 && Math.abs(fvDiffPercent) < 0.015) {
if (fvDiffPercent < 0) {
for (y=1; y=12; y++) {
count = -78*x+y;
if (high(count, sym(symb5min)) > high(count-1, sym(symb5min)) && low(count, sym(symb5min)) > low(count-1, sym(symb5min))) {
nTmp2 += 1;
}
}
}
if (fvDiffPercent > 0) {
for (y=1; y=12; y++) {
count = -78*x+y;
if (high(count, sym(symb5min)) < high(count-1, sym(symb5min)) && low(count, sym(symb5min)) < low(count-1, sym(symb5min))) {
nTmp2 += 1;
}
}
}
if (nTmp2 > 10)
nTmp += 1;
if (nTmp == 0)
nTmpStr == "NotWithin";
}
}
nTmp /= nDays;
return( nTmp );
}
Comment