Several people have reported a screen update problem on some crim's platforms.
It seems to be something to do with 'unclosed' bars or missing bars in calcCorrelation()
which causes an infinite loop
example:
Code: Select all
18:48:52 Multi_10_4_EAv1.06 AUDCAD,H4: S1: AUDCAD, S2: GBPAUD, tf: 1440, periods: 50
18:48:52 Multi_10_4_EAv1.06 AUDCAD,H4: while (symbol2.close[i] < EPSILON)...
18:48:52 Multi_10_4_EAv1.06 AUDCAD,H4: GBPAUD.close[14]= iClose(GBPAUD, tf,14) : 0.00000
I have added '+1' ... (shift=1) to anything using iClose()
and I have made a work around in calcCorrelation.
I am also wondering if ForceLoadHistory might help as well?
Here is the hack to make it skip the calculation if finds empty values:
Code: Select all
double calcCorrelation(string symbol, string symbol2, int tf, int periods) {
double symbol.close[];
double symbol2.close[];
double corr.avg1 = 0.0,
corr.avg2 = 0.0,
corr.sum = 0.0,
corr.dev1 = 0.0,
corr.dev2 = 0.0,
corr.ro1 = 0.0,
corr.ro2 = 0.0,
corr = 0.0;
static bool skipcalcCorrelation = false;
string dbgstr = "";
if( skipcalcCorrelation ==true )
return (0.0);
ArrayResize(symbol.close, periods);
ArrayResize(symbol2.close, periods);
ArrayInitialize(symbol.close, 0);
ArrayInitialize(symbol2.close, 0);
int shift = 1;
for (int i = 0; i < periods; i++) {
//Print("For each period...");
while (symbol.close[i] < EPSILON) {
symbol.close[i] = iClose(symbol, tf, i + shift);
if( symbol.close[i] < EPSILON ) {
dbgstr = "S1: " + symbol + ", S2: " + symbol2 +", tf: " + tf + ", periods: " + periods;
Print( dbgstr);
Print("while (symbol.close[i] < EPSILON) ...");
Print( symbol + ".close[" + i +"] = iClose(" + symbol2 + ", tf,"+ i+") : " + DoubleToStr( iClose(symbol, tf, i + shift), 5) );
skipcalcCorrelation = true;
}
break;
}
while (symbol2.close[i] < EPSILON) {
symbol2.close[i] = iClose(symbol2, tf, i + shift);
if(symbol2.close[i] < EPSILON) {
dbgstr = "S1: " + symbol + ", S2: " + symbol2 +", tf: " + tf + ", periods: " + periods;
Print( dbgstr);
Print("while (symbol2.close[i] < EPSILON)...");
Print( symbol2 + ".close[" + i +"]= iClose(" + symbol2 + ", tf,"+ i+") : " + DoubleToStr( iClose(symbol2, tf, i + shift), 5) );
skipcalcCorrelation = true;
}
break;
}
corr.avg1 += symbol.close[i];
corr.avg2 += symbol2.close[i];
}
corr.avg1 /= periods;
corr.avg2 /= periods;
for (i = 0; i < periods; i++) {
corr.dev1 = symbol.close[i] - corr.avg1;
corr.dev2 = symbol2.close[i] - corr.avg2;
corr.sum += corr.dev1 * corr.dev2;
corr.ro1 += corr.dev1 * corr.dev1;
corr.ro2 += corr.dev2 * corr.dev2;
}
corr = MathSqrt(corr.ro1) * MathSqrt(corr.ro2);
if (corr == 0)
return(0);
return((corr.sum / corr) * 100);
}
After making this change the screen now refreshes and CPU is no longer running hot.