Download MetaTrader 5

indicator line 's difference because of a very little different code

To add comments, please log in or register
Do you know that MQL5 is an object-oriented language?
Fa Cao
1141
Fa Cao 2013.11.25 09:21 

Below code comes from an indicator's code, and I think the red codes and blue codes are the same, but in the fact very different.

 i=Bars-MAPeriod-1;

   if(counted_bars>=MAPeriod) i=Bars-counted_bars-1;

   while(i>=0)

    {
   ind_buffer[i]=iMA(NULL,0,MAPeriod,0,MODE_SMA,PRICE_CLOSE,i);

    BiasBuffer[i]=(Close[i]-ind_buffer[i])/Close[i];

      
    /* 
    int x=iMA(NULL,0,MAPeriod,0,MODE_SMA,PRICE_CLOSE,i);

    BiasBuffer[i]=(Close[i]-x)/Close[i];
    */

      i--;

     }

the red code gets the line as 'A' and blue code gets the line as 'B':

A:

B:

in addition, i find add label by two methods as below:

"IndicatorShortName("BIAS("+MAPeriod+")"); SetIndexLabel(0,"BIAS"); "

"IndicatorShortName("BIAS("+MAPeriod+")"); " always works, but "SetIndexLabel(0,"BIAS"); " not. I don;t know why, because i think they should all work well.

Keith Watford
Moderator
9614
Keith Watford 2013.11.25 09:30  
Do you realise the difference between an integer and a double?
Fa Cao
1141
Fa Cao 2013.11.25 12:32  
GumRai:
Do you realise the difference between an integer and a double?

Haha, thanks
To add comments, please log in or register