Convertion from MQL4 to MQL5

 
Hello I downloaded an mq4 indicator and tried to convert it to mq5, how ever with each coming tick my indicator deletees everything and recalculates again please assist me 
Please Find the mql4 code below.
#property  copyright "whoever"
#property  link      "whatever"

#property  indicator_separate_window
#property  indicator_buffers 5
#property  indicator_color1  LimeGreen
#property  indicator_color2  Red
#property  indicator_color3  Gold
#property  indicator_color4  LimeGreen
#property  indicator_color5  Red
#property  indicator_width3  2
#property  indicator_width4  2
#property  indicator_width5  2
 
extern int period=35;
extern int smooth=10; 
extern bool DoAlert=true;
extern bool alertMail=false;
datetime lastAlertTime;
      string post;


double         ExtBuffer0[];
double         ExtBuffer1[];
double         ExtBuffer2[];
double         ExtBuffer3[];
double         ExtBuffer4[];
double         ExtBuffer5[];
double         ExtBufferh1[];
double         ExtBufferh2[];

#define LinesIdentifier "signalLines"
int init()
{
   IndicatorBuffers(8);
   SetIndexBuffer(0,ExtBufferh1); SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(1,ExtBufferh2); SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(2,ExtBuffer3);
   SetIndexBuffer(3,ExtBuffer4);
   SetIndexBuffer(4,ExtBuffer5);
   SetIndexBuffer(5,ExtBuffer0);
   SetIndexBuffer(6,ExtBuffer1);
   SetIndexBuffer(7,ExtBuffer2);

   SetIndexLabel(2,"ExtBuffer3");
   SetIndexLabel(3,"ExtBuffer4");
   SetIndexLabel(4,"ExtBuffer5");
   SetIndexLabel(5,"ExtBuffer0");
   SetIndexLabel(6,"ExtBuffer1");
   SetIndexLabel(7,"ExtBuffer2");
   

   lastAlertTime = Time[1];

   IndicatorShortName("Solar wind joy :)");
   return(0);
}
int deinit()
{
   int lookForLength = StringLen(LinesIdentifier);
   for (int i=ObjectsTotal(); i>=0; i--)
      {
         string name = ObjectName(i);
         if (StringSubstr(name,0,lookForLength)==LinesIdentifier) ObjectDelete(name);
      }
   return(0);
}


int start()
{
   //int     period=10;
   int    limit;
   double prev,current,old;
   double Value=0,Value1=0,Value2=0,Fish=0,Fish1=0,Fish2=0;
   double price;
   double MinL=0;
   double MaxH=0;  
   
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   string sAlertMsg;
      
   //limit=Bars-1;


   for(int i=0; i<limit; i++)
    {  MaxH = High[Highest(NULL,0,MODE_HIGH,period,i)];
       MinL = Low[Lowest(NULL,0,MODE_LOW,period,i)];
      price = (High[i]+Low[i])/2;
      Value = 0.33*2*((price-MinL)/(MaxH-MinL)-0.5) + 0.67*Value1;   
      Value=MathMin(MathMax(Value,-0.999),0.999); 
      double OutofRange1 =0.5*MathLog((1+Value)/(1-Value))+0.5*Fish1;
      post+="\nArray out of range = "+ OutofRange1;
      ExtBuffer0[i]=OutofRange1;
      Value1=Value;
      Fish1=ExtBuffer0[i];
         if (ExtBuffer0[i]>0) ExtBuffer1[i]=10; else ExtBuffer1[i]=-10;
         //post += "\nBuff0["+i+"] = "+ ExtBuffer0[i]+ "\n";    
        // post += "Buff1["+i+"] = "+ ExtBuffer1[i]+ "\n";    
    }

   for(i=limit; i>=0; i--)
   {
      double sum  = 0;
      double sumw = 0;

      for(int k=0; k<smooth && (i+k)<Bars; k++)
      {
         double weight = smooth-k;
                sumw  += weight;
                sum   += weight*ExtBuffer1[i+k];  
      }             
      if (sumw!=0)
            ExtBuffer2[i] = sum/sumw;
      else  ExtBuffer2[i] = 0;
  // post += "Buff2["+i+"] = "+ ExtBuffer2[i]+ "\n";    

   }      
   for(i=0; i<=limit; i++)
   {
      sum  = 0;
      sumw = 0;

      for(k=0; k<smooth && (i-k)>=0; k++)
      {
         weight = smooth-k;
                sumw  += weight;
                sum   += weight*ExtBuffer2[i-k];
      }             
      if (sumw!=0)
            ExtBuffer3[i] = sum/sumw;
      else  ExtBuffer3[i] = 0;
         //post += "Buff3["+i+"] = "+ ExtBuffer3[i]+ "\n";    

   }      
   for(i=limit; i>=0; i--)
   {
      ExtBuffer4[i]=EMPTY_VALUE;
      ExtBuffer5[i]=EMPTY_VALUE;
      ExtBufferh1[i]=EMPTY_VALUE;
      ExtBufferh2[i]=EMPTY_VALUE;
      if (ExtBuffer3[i]>0) { ExtBuffer4[i]=ExtBuffer3[i]; ExtBufferh1[i]=ExtBuffer3[i]; }
      if (ExtBuffer3[i]<0) { ExtBuffer5[i]=ExtBuffer3[i]; ExtBufferh2[i]=ExtBuffer3[i]; }
      
      if (ExtBuffer3[i+1] < 0 && ExtBuffer3[i] > 0)
      {
         if (DoAlert && i<5 && lastAlertTime!=Time[0])
         {
            sAlertMsg="Solar Wind - "+Symbol()+" "+TF2Str(Period())+": cross UP";
            if (DoAlert)     Alert(sAlertMsg);
            lastAlertTime = Time[0];  
            if (alertMail)   SendMail(sAlertMsg, "MT4 Alert!\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS )+"\n"+sAlertMsg);   
         }
      }
      else if( ExtBuffer3[i+1] > 0 && ExtBuffer3[i] < 0)
      {
         if (i<5 && lastAlertTime!=Time[0])
         {
            sAlertMsg="Solar Wind - "+Symbol()+" "+TF2Str(Period())+": cross DOWN";
            if (DoAlert)     Alert(sAlertMsg);
            lastAlertTime = Time[0];  
            if (alertMail)   SendMail(sAlertMsg, "MT4 Alert!\n" + TimeToStr(TimeCurrent(),TIME_DATE|TIME_SECONDS )+"\n"+sAlertMsg);   
         }
                     
      }
      
      
   }
   Comment(post);
   return(0);
}
// function: TF2Str()
// Description: Convert time-frame to a string
//-----------------------------------------------------------------------------
string TF2Str(int iPeriod) {
  switch(iPeriod) {
    case PERIOD_M1: return("M1");
    case PERIOD_M5: return("M5");
    case PERIOD_M15: return("M15");
    case PERIOD_M30: return("M30");
    case PERIOD_H1: return("H1");
    case PERIOD_H4: return("H4");
    case PERIOD_D1: return("D1");
    case PERIOD_W1: return("W1");
    case PERIOD_MN1: return("MN1");
    default: return("M"+iPeriod);
  }
}
//+------------------------------------------------------------------+
I then tried to convert it to mql5, my funny code is below. 
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window
#property indicator_minimum -11
#property indicator_maximum 11
#property indicator_buffers 8
#property indicator_plots   5
//--- plot ExtBufferh1Buffer
#property indicator_label1  "ExtBufferh1Buffer"
#property indicator_type1   DRAW_HISTOGRAM
#property indicator_color1  clrLime
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot ExtBufferh2Buffer
#property indicator_label2  "ExtBufferh2Buffer"
#property indicator_type2   DRAW_HISTOGRAM
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- plot ExtBuffer3
#property indicator_label3  "ExtBuffer3"
//#property indicator_type3   DRAW_LINE
#property indicator_color3  clrGold
//#property indicator_style3  STYLE_SOLID
#property indicator_width3  2
//--- plot ExtBuffer4
#property indicator_label4  "ExtBuffer4"
#property indicator_type4   DRAW_SECTION
#property indicator_color4  clrLime
//#property indicator_style4  STYLE_SOLID
#property indicator_width4  2
//--- plot ExtBuffer5
#property indicator_label5  "ExtBuffer5"
//#property indicator_type5   DRAW_LINE
#property indicator_color5  clrRed
//#property indicator_style5  STYLE_SOLID
#property indicator_width5  2


//--- input parameters
input int      period=35;
input int      smooth=10;
input bool     DoAlert=true;
input bool     alertMail=false;
datetime lastAlertTime;

//--- indicator buffers
double         ExtBufferh1Buffer[];
double         ExtBufferh2Buffer[];

double         ExtBuffer0[];
double         ExtBuffer1[];
double         ExtBuffer2[];
double         ExtBuffer3[];
double         ExtBuffer4[];
double         ExtBuffer5[];

//--- global variable for storing calculation period 
int       IntPeriod;
string err;
#define LinesIdentifier "signalLines"
string post;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+



int OnInit()
  {
//--- indicator buffers mapping

   if(period<0)
     {
      IntPeriod=14;
      Print("Period parameter has an incorrect value. The following value is to be used for calculations ",IntPeriod);
     }
   else
      IntPeriod=period;

   SetIndexBuffer(0,ExtBufferh1Buffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtBufferh2Buffer,INDICATOR_DATA);

   SetIndexBuffer(2,ExtBuffer3,INDICATOR_CALCULATIONS);
   SetIndexBuffer(3,ExtBuffer4,INDICATOR_CALCULATIONS);
   SetIndexBuffer(4,ExtBuffer5,INDICATOR_CALCULATIONS);
   SetIndexBuffer(5,ExtBuffer0,INDICATOR_CALCULATIONS);
   SetIndexBuffer(6,ExtBuffer1,INDICATOR_CALCULATIONS);
   SetIndexBuffer(7,ExtBuffer2,INDICATOR_CALCULATIONS);

   post=" ";
   lastAlertTime=iTime(_Symbol,0,1);
//("Solar winds Joy MT5");

//---
   return(INIT_SUCCEEDED);
  }
//+==================================================================+
//|
//+==================================================================+
void OnDeinit(const int  reason)
  {
   Comment("");
   int lookForLength=StringLen(LinesIdentifier);
   for(int i=ObjectsTotal(0,-1,-1); i>=0; i--)
     {
      string name=ObjectName(0,i,-1,-1);
      if(StringSubstr(name,0,lookForLength)==LinesIdentifier) ObjectDelete(0,name);
     }
   return;
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---

   ArraySetAsSeries(ExtBufferh1Buffer,false);
   ArraySetAsSeries(ExtBufferh2Buffer,false);
   ArraySetAsSeries(ExtBuffer0,false);
   ArraySetAsSeries(ExtBuffer1,false);
   ArraySetAsSeries(ExtBuffer2,false);
   ArraySetAsSeries(ExtBuffer3,false);
   ArraySetAsSeries(ExtBuffer4,false);
   ArraySetAsSeries(ExtBuffer5,false);
   ArraySetAsSeries(high,false);
   ArraySetAsSeries(low,false);



//--- initial position for calculations 
   int limit,StartCalcPosition=(IntPeriod-1);
//---- if calculation data is insufficient 
   if(rates_total<StartCalcPosition)
      return(0);  // exit with a zero value - the indicator is not calculated

   double Value=0,Value1=0,Value2=0,Fish=0,Fish1=0,Fish2=0;
   double price;
   double MinL=0;
   double MaxH=0;
   double sum  = 0;
   double sumw = 0;
   int bars,counted_bars;

   bars=rates_total-1;
   counted_bars=prev_calculated;

   if(counted_bars<0) return(-1);
//if(counted_bars>0) counted_bars--;

/*int    counted_bars = (Bars-1)-prev_calculated;
   if(counted_bars<0)return(-1);
   int limit = Bars-counted_bars;*/
   string sAlertMsg;
//limit = Bars(NULL,0)-prev_calculated;
   limit=bars-counted_bars;
int safe = period+1;
post+="\nrates_total = "+rates_total;
post+="\nprev_counted = "+prev_calculated;
post+="\nlimit = "+limit;
   for(int i=0; i<limit-safe; i++)
     {
      int Maxindex = iHighest(NULL,0,MODE_HIGH,period,i);
      int Minindex = iLowest(NULL,0,MODE_LOW,period,i);
      MaxH = iHigh(_Symbol,0,Maxindex);
      MinL = iLow(_Symbol,0,Minindex);
      
      price=(iHigh(_Symbol,0,i)+iLow(_Symbol,0,i))/2;
      Value = 0.33*2*(((price-MinL)/(MaxH-MinL))-0.5) + 0.67*Value1;

      Value=MathMin(MathMax(Value,-0.999),0.999);
      double OutofRange1 =0.5*MathLog((1+Value)/(1-Value))+0.5*Fish1;
      post+="\nArray out of range = "+ OutofRange1;
     ArrayResize(ExtBuffer0,i+1,0);
     ArrayResize(ExtBuffer1,i+1,0);     
      ExtBuffer0[i]=OutofRange1;
      Value1=Value;
      Fish1=ExtBuffer0[i];
      if(ExtBuffer0[i]>0) ExtBuffer1[i]=10; else ExtBuffer1[i]=-10;
     }

   for(int i=limit; i>=0; i--)
     {
         sum=0; sumw=0;
      for(int k=0; k<smooth && (i+k)<bars/*Bars(NULL,0)*/; k++)
        {
         double weight = smooth-k;
         sumw  += weight;
         sum   += weight*ExtBuffer1[i+k];
        }
      if(sumw!=0)
         ExtBuffer2[i] = sum/sumw;
      else  ExtBuffer2[i] = 0;
     }

   for(int i=0; i<=limit; i++)
     {
      sum  = 0;
      sumw = 0;

      for(int k=0; k<smooth && (i-k)>=0; k++)
        {
         double weight = smooth-k;
         sumw  += weight;
         sum   += weight*ExtBuffer2[i-k];
        }
      if(sumw!=0)
         ExtBuffer3[i] = sum/sumw;
      else  ExtBuffer3[i] = 0;
     }

//---
   for(int i=limit; i>=0; i--)
     {
      ExtBuffer4[i]=EMPTY_VALUE;
      ExtBuffer5[i]=EMPTY_VALUE;
      ExtBufferh1Buffer[i]=EMPTY_VALUE;
      ExtBufferh2Buffer[i]=EMPTY_VALUE;
      if(ExtBuffer3[i]>0) { ExtBuffer4[i]=ExtBuffer3[i]; ExtBufferh1Buffer[i]=ExtBuffer3[i]; }
      if(ExtBuffer3[i]<0) { ExtBuffer5[i]=ExtBuffer3[i]; ExtBufferh2Buffer[i]=ExtBuffer3[i]; }
      //ArrayResize(ExtBuffer3,i+2,0);
      /*if(ExtBuffer3[i+1]<0 && ExtBuffer3[i]>0)
        {
         if(DoAlert && i<5 && lastAlertTime!=time[0])
           {
            sAlertMsg="Solar Wind - "+Symbol()+" "+TF2Str(Period())+": cross UP";
            if(DoAlert) Alert(sAlertMsg);
            lastAlertTime=time[0];
            if(alertMail) SendMail(sAlertMsg,"MT4 Alert!\n"+TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS)+"\n"+sAlertMsg);
           }
        }
      else if(ExtBuffer3[i+1]>0 && ExtBuffer3[i]<0)
        {
         if(i<5 && lastAlertTime!=time[0])
           {
            sAlertMsg="Solar Wind - "+Symbol()+" "+TF2Str(Period())+": cross DOWN";
            if(DoAlert) Alert(sAlertMsg);
            lastAlertTime=time[0];
            if(alertMail) SendMail(sAlertMsg,"MT4 Alert!\n"+TimeToString(TimeCurrent(),TIME_DATE|TIME_SECONDS)+"\n"+sAlertMsg);
           }

        }*/

     }
//---

Comment(post);

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//-----------------------------------------------------------------
string TF2Str(int iPeriod) 
  {
   switch(iPeriod) 
     {
      case PERIOD_M1: return("M1");
      case PERIOD_M5: return("M5");
      case PERIOD_M15: return("M15");
      case PERIOD_M30: return("M30");
      case PERIOD_H1: return("H1");
      case PERIOD_H4: return("H4");
      case PERIOD_D1: return("D1");
      case PERIOD_W1: return("W1");
      case PERIOD_MN1: return("MN1");
      default: return("M "+iPeriod);
     }
  }

//+------------------------------------------------------------------+

Please assist me where did I make a Mistake
 
Jefferson Metha:
Hello I downloaded an mq4 indicator and tried to convert it to mq5, how ever with each coming tick my indicator deletees everything and recalculates again please assist me 
Please Find the mql4 code below.
I then tried to convert it to mql5, my funny code is below. 

Please assist me where did I make a Mistake

"Solar wind" is not so practical because it is repainted.

Files:
 
Naguisa Unada:

"Solar wind" is not so practical because it is repainted.

Can't that be changed by changing limit value 
Limit = rates_total-(prev_calculated+1);
 

For "Solar wind" believers - the thread  

Forum on trading, automated trading systems and testing trading strategies

For "Solar wind" believers

Mladen Rakic, 2012.07.08 18:32

Since it seems that some new reincarnation of "Solar wind" is appearing at least on a weekly basis, and since it seems that is useless to repeat over and over that it is a wrongly coded Ehlers fisher transform and that it is one of the most famous re painters, here is this nice little thread in which whoever finds a "new" and "newly discovered" Solar wind can post it.

It will save time for believers ("it does not repaint I tried it out" even when you show them pictures of repainting, so they can find all their adoration objects in one place) scammers (poor scammers will not need to look over and over 1000s of post to find a new wonder indicator that they are going to scamm to people then) and it might even be amusing ...

These are just the first ones

Enjoy

PS: TurdorGirl Vorticity is posted as it was posted originally (it is a Solar wind indicator, believe me :):))