# Just learning to convert my MT4 indicators to MT5

1249

I am converting an MT4 indicator for Bollinger Bands to MT5.  I started by creating a new indicator in the editor and then going through the wizard to setup inputs and line params.  Now I am in the OnCalculate section and I want to make sure I get the MT4 to MT5 right.  Here is my code for MT4 start function, can you show me the changes I need to make to make it work for MT5?

```      double deviation;
double sum,oldval,newres;
//----
if(Bars<=BandsPeriod) return(0);
//---- initial zero
if(counted_bars<1)
for(i=1;i<=BandsPeriod;i++)
{
Median[Bars-i]=EMPTY_VALUE;
UpperBand[Bars-i]=EMPTY_VALUE;
LowerBand[Bars-i]=EMPTY_VALUE;
}
//----
int limit=Bars-counted_bars;
if(counted_bars>0) limit++;
for(i=0; i<limit; i++)
Median[i]=iMA(NULL,0,BandsPeriod,BandsShift,MODE_SMA,PRICE_CLOSE,i);
//----
i=Bars-BandsPeriod+1;
if(counted_bars>BandsPeriod-1) i=Bars-counted_bars-1;
while(i>=0)
{
sum=0.0;
k=i+BandsPeriod-1;
oldval=Median[i];
while(k>=i)
{
newres=Close[k]-oldval;
sum+=newres*newres;
k--;
}
deviation=BandsDeviations*MathSqrt(sum/BandsPeriod);
UpperBand[i]=oldval+deviation;
LowerBand[i]=oldval-deviation;
i--;
}```
I will see what I can learn through the tutorials and such, just wondering if you could show me how to do a conversion process.
Bollinger Bands ®