Nubie need help please...

 
ai learn to code mql5 and trying to create indicator. i know there is tons indi on this web that i can use. But i just want to learn how to code it. Here i try to draw histogram and line based on average of 3 high - low value of 3 candles. But i got this weird look on my script. Could some body please explain to me why i got this..? And if possible please fix my code.. Thanks alot.. Sorry for my bad spell..
Files:
 
//int i;
//if(prev_calculated==0) i=0;
//else i=prev_calculated-1;
   
//for (i = 0; i < prev_calculated;i++)

int i, limit;
if(prev_calculated==0) limit=0;
else limit=prev_calculated-1;
   
for (i = limit; i < rates_total;i++)
 
Naguisa Unada:

It's more than just that. OP's issue is that he is working with the buffers as if they are MT4. MT5 is reversed so the entire logic needs to be reversed. 

{
   int limit = rates_total - 1;
   if(prev_calculated == 0)
      limit = 3;
   for(int i=limit; i<rates_total; ++i)
   {      
       double ihl = high[i] - low[i];
       double jhl = high[i-1] - low[i-1];
       double khl = high[i-2] - low[i-2];
       double x = (ihl + jhl + khl) / 3.0;
       BlockBuffer[i] = x;
       PowerBuffer[i] = x;
   }
   return(rates_total);
}
 
nicholi shen:

It's more than just that. OP's issue is that he is working with the buffers as if they are MT4. MT5 is reversed so the entire logic needs to be reversed. 

Surely you are right.
However, this method does not cause problems when communication is interrupted? It always calculates only the last buffer.

int limit = rates_total - 1;
 
Naguisa Unada:

Surely you are right.
However, this method does not cause problems when communication is interrupted? It always calculates only the last buffer.

The last buffer is always the most recent bar in MT5. Indexes run opposite of MT4. 

 
 nicholi shen:

The last buffer is always the most recent bar in MT5. Indexes run opposite of MT4. 

Yes, I know it.

But your program is the same as following because in your program (limit = rates_total - 1).

for (int i=ratos_total - 1; i < ratos_total; i++)

It always calculates only last index except for the first calculation.

I think that (limit = prev_calculated - 1) is the best.

 
nicholi shen:

It's more than just that. OP's issue is that he is working with the buffers as if they are MT4. MT5 is reversed so the entire logic needs to be reversed. 

Thanks very much...
it work now....

and you GOD DAMN RIGHT,, i got the error bcz i followed the mql4 tuts...
thanks agai for your help...
 
Cipud:
Thanks very much...
it work now....

and you GOD DAMN RIGHT,, i got the error bcz i followed the mql4 tuts...
thanks agai for your help...
Naguisa Unada:

thanks alot for your kindness...

you all are my angel...

 

KDE is love, KDE is life.

You can make all things dark in winecfg and MetaEditor Tools/Properties/Colors.

Let the darkness flow through you.

 
kypa:

KDE is love, KDE is life.

You can make all things dark in winecfg and MetaEditor Tools/Properties/Colors.

Let the darkness flow through you.

What's that off-topic useless comment ?
Reason: