Just a simple question about vars and arrays in mt4

 

Hi all,

I'm have a custom indicator I have developed, that have 7 buffers.

The indicator runs ok, because I get painted on screen what I want, but when I want to get the buffers values using iCustom I allways get '0' as value.

So taking into account that MT4 does not have a debugger, I begin to put Print's all over the indicator code to see what's happens and I found something that let me stucked ... take a look at this piece of code:

for (j = 0; j <= CoGNumBars; j++) 
{ 
   range = 0; 
   for (w = 1; w <= CoGOrder; w++) 
      range += (buff2[w + 1]) * MathPow(j, w); 
   CoGCenter[j] = buff2[1] + range;
   if(j==0){
        double val=1.3584;
        double val2=CoGCenter[j];
        CoGCenter[j]=val;
        Print("V1: ",val);
        Print("V2: ",val2);
        Print("CoGC: ",CoGCenter[j]);
        Print("CoGC must be: ",range+buff2[1]);
        Print("Buff2 v: ",buff2[1]);
   }
}

The if(j==0) statement is only to not flood the log on the terminal, now what let me stucked ... this is the output I get on the console log:

2011.01.21 17:44:22 CoGEA EURUSD,M1: Buff2 v: 1.3597

2011.01.21 17:44:22 CoGEA EURUSD,M1: CoGC must be: 1.3597

2011.01.21 17:44:22 CoGEA EURUSD,M1: CoGC: 0

2011.01.21 17:44:22 CoGEA EURUSD,M1: V2: 0

2011.01.21 17:44:22 CoGEA EURUSD,M1: V1: 1.3584

What the hell is happening ? I don't undestand this output ...

Could someone give me a sight of light about this?


 

I see no problem, but obviously you do ...

A) The terminal lines read from bottom to top - the latest is at the top. Is that what you mean?

B) Without knowing a value for CoGOrder & values of buff2[], it's difficult to know if range and so val2 has the correct value.

 
// range += (buff2[w + 1]) * MathPow(j, w); 
   range += (buff2[w - 1]) * MathPow(j, w); 
Reason: