Build 600 has this bug - page 2

 
gchrmt4:
Yes, it's too late to change it now. But thank you for finally admitting that backward compatibility is broken for some EX4 files.

Of course.

But better late than never.

How much ex4-files were broken? 0.001 percent of all

How much ex4-files will not work (imagine MT4 still old) in the Windows 8? 100 percent

 

dear brothers..

i also had samoe error with build 600 meta editor

it runs properly in build 509

the file ex4 is running properly as well in build 600

but when i compiled the code in build 600 meta editor.. the indicator became error ARRAY OUT OF RANGE

may be the meta editor 600 still have bugs with array operation

//+------------------------------------------------------------------+
//|                                                    Color RSI.mq4 |
//|                                                           mladen |                     

#property copyright "mladen"
#property link      ""

#property indicator_separate_window

#property indicator_buffers    7
#property indicator_minimum    0
#property indicator_maximum    100
#property indicator_color1     Red
#property indicator_color2     LimeGreen
#property indicator_color3     DarkSlateGray

#property indicator_width1     5
#property indicator_width2     5
#property indicator_width3     1

#property indicator_color4     LimeGreen
#property indicator_color5     FireBrick
#property indicator_color6     Green
#property indicator_color7     Red

#property indicator_width4     1
#property indicator_width5     1   
#property indicator_width6     1
#property indicator_width7     1

#property indicator_style4     STYLE_DOT  //STYLE_SOLID
#property indicator_style5     STYLE_DOT  //STYLE_DOT  
#property indicator_style6     STYLE_DOT  //STYLE_DASH
#property indicator_style7     STYLE_DOT  //STYLE_DASHDOT, STYLE_DASHDOTDOT

//---- input parameters
extern int       RSIPeriod     =  5;
extern string    note1     =  "0=close;1=open;2=hi;3=low";
extern string    note2     =  "4=median;5=typical;6=weighted";
extern int       PriceType     =   0;
extern string note3 = "Chart Time Frame";
extern string note4 = "1=M1, 5=M5, 15=M15, 30=M30";
extern string note5 = "60=H1, 240=H4, 1440=D1";
extern string note6 = "10080=W1, 43200=MN1";
extern string    timeFrame     =  "Current time frame";
extern int       overBought    =  85;
extern int       overSold      =  15;
extern bool      showArrows    = false;
extern bool      alertsOn      = false;
extern bool      alertsMessage = false;
extern bool      alertsSound   = false;
extern bool      alertsEmail   = false;
//---- buffers

double   Upper[];
double   Lower[];
double   RSIBuffer[];
double   LineA[];
double   LineB[];
double   LineC[];
double   LineD[];

int      TimeFrame;
datetime TimeArray[];
int      maxArrows;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
      IndicatorBuffers(7);

      SetIndexBuffer(0,Upper); 
      SetIndexLabel (0,NULL);
      SetIndexBuffer(1,Lower);
      SetIndexLabel (1,NULL);
      SetIndexBuffer(2,RSIBuffer);
      SetIndexLabel (2,"RSI");
               
      SetIndexStyle(0,DRAW_LINE);        //Line at level 81
      SetIndexBuffer(3,LineA);
      SetIndexStyle(1,DRAW_LINE);        //Line at level 60
      SetIndexBuffer(4,LineB);   
      SetIndexStyle(2,DRAW_LINE);        //Line at level 40
      SetIndexBuffer(5,LineC);  
      SetIndexStyle(3,DRAW_LINE);        //Line at level 19
      SetIndexBuffer(6,LineD);

      TimeFrame         = stringToTimeFrame(timeFrame);
      string shortName  = "   THV RSI_v2   (Chart "+TimeFrameToString(TimeFrame)
                        +",  RSI Period "+RSIPeriod+",  "+PriceTypeToString(PriceType);
            if (overBought < overSold) overBought = overSold;
            if (overBought < 100)      shortName  = shortName+",  "+overBought;
            if (overSold   >   0)      shortName  = shortName+",  "+overSold;
      IndicatorShortName(shortName+")  ");

   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator de-initialization function                      |
//+------------------------------------------------------------------+
int deinit()
{
   DeleteArrows();
   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int counted_bars=IndicatorCounted(), limit, i, y;
   if(counted_bars<0) return(-1);
   limit=Bars-counted_bars;
   ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame);     
   for(i=limit; i>=0; i--)
      {
      LineA[i]=79;
      LineB[i]=60;
      LineC[i]=40;
      LineD[i]=21;
      }
   for(i=0,y=0; i<limit; i++)
      {
      if(Time[i]<TimeArray[y])
         {
         y++; RSIBuffer[i] = iRSI(NULL,TimeFrame,RSIPeriod,PriceType,y);
         }
      }
   for(i=limit; i>=0; i--)
      {
      if (RSIBuffer[i] > overBought) { Upper[i] = RSIBuffer[i]; Upper[i+1] = RSIBuffer[i+1]; }
      else                           { Upper[i] = EMPTY_VALUE;
                                     if (Upper[i+2] == EMPTY_VALUE)
                                         Upper[i+1]  = EMPTY_VALUE; }
      if (RSIBuffer[i] < overSold)   { Lower[i] = RSIBuffer[i]; Lower[i+1] = RSIBuffer[i+1]; }
      else                           { Lower[i] = EMPTY_VALUE;
                                     if (Lower[i+2] == EMPTY_VALUE)
                                         Lower[i+1]  = EMPTY_VALUE; }  
      }
   if (showArrows)
      for (i=0; i<WindowBarsPerChart() ;i++)
         {
         if (RSIBuffer[i]>overBought && RSIBuffer[i+1]<overBought) DrawArrow(i,"up");
         if (RSIBuffer[i]<overSold   && RSIBuffer[i+1]>overSold)   DrawArrow(i,"down");
         }
   if (alertsOn)
      {
      if (RSIBuffer[0]>overBought && RSIBuffer[1]<overBought) doAlert(overBought+" line crossed up");
      if (RSIBuffer[0]<overSold   && RSIBuffer[1]>overSold)   doAlert(overBought+" line crossed down");
      }
   return(0);
}

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
void DrawArrow(int i,string type)
{
   maxArrows++;
      ObjectCreate("RSISignal"+maxArrows,OBJ_ARROW,0,Time[i],0);
      if (type=="up")
         {
            ObjectSet("RSISignal"+maxArrows,OBJPROP_PRICE1,High[i]+(8*Point));
            ObjectSet("RSISignal"+maxArrows,OBJPROP_ARROWCODE,242);
            ObjectSet("RSISignal"+maxArrows,OBJPROP_COLOR,Red);
         }
      else
         {
            ObjectSet("RSISignal"+maxArrows,OBJPROP_PRICE1,Low[i]-(6*Point));
            ObjectSet("RSISignal"+maxArrows,OBJPROP_ARROWCODE,241);
            ObjectSet("RSISignal"+maxArrows,OBJPROP_COLOR,LimeGreen);
         }
}
void DeleteArrows()
{
   while(maxArrows>0) { ObjectDelete("RSISignal"+maxArrows); maxArrows--; }
}

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
void doAlert(string doWhat)
{
   static string   previousAlert="nothing";
   static datetime previousTime;
   string message;  
      if (previousAlert != doWhat || previousTime != Time[0]) {
          previousAlert  = doWhat;
          previousTime   = Time[0];          
          message =  StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," RSI ",doWhat);
             if (alertsMessage) Alert(message);
             if (alertsSound)   PlaySound("alert2.wav");
             if (alertsEmail)   SendMail(StringConcatenate(Symbol()," RSI crossing"),message);
      }        
}

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
string PriceTypeToString(int pt)
{
   string answer;
   switch(pt)
   {
      case 0:  answer = "Close"    ; break; 
      case 1:  answer = "Open"     ; break;
      case 2:  answer = "High"     ; break;
      case 3:  answer = "Low"      ; break;
      case 4:  answer = "Median"   ; break;
      case 5:  answer = "Typical"  ; break;
      case 6:  answer = "Wighted"  ; break;
      default: answer = "Invalid price field requested";
                                    Alert(answer);
   }
   return(answer);
}
int stringToTimeFrame(string tfs)
{
   int tf=0;
       tfs = StringUpperCase(tfs);
         if (tfs=="M1" || tfs=="1")     tf=PERIOD_M1;
         if (tfs=="M5" || tfs=="5")     tf=PERIOD_M5;
         if (tfs=="M15"|| tfs=="15")    tf=PERIOD_M15;
         if (tfs=="M30"|| tfs=="30")    tf=PERIOD_M30;
         if (tfs=="H1" || tfs=="60")    tf=PERIOD_H1;
         if (tfs=="H4" || tfs=="240")   tf=PERIOD_H4;
         if (tfs=="D1" || tfs=="1440")  tf=PERIOD_D1;
         if (tfs=="W1" || tfs=="10080") tf=PERIOD_W1;
         if (tfs=="MN" || tfs=="43200") tf=PERIOD_MN1;
         if (tf<Period()) tf=Period();
  return(tf);
}
string TimeFrameToString(int tf)
{
   string tfs="Current time frame";
   switch(tf) {
      case PERIOD_M1:  tfs="M1"  ; break;
      case PERIOD_M5:  tfs="M5"  ; break;
      case PERIOD_M15: tfs="M15" ; break;
      case PERIOD_M30: tfs="M30" ; break;
      case PERIOD_H1:  tfs="H1"  ; break;
      case PERIOD_H4:  tfs="H4"  ; break;
      case PERIOD_D1:  tfs="D1"  ; break;
      case PERIOD_W1:  tfs="W1"  ; break;
      case PERIOD_MN1: tfs="MN1";
   }
   return(tfs);
}
string StringUpperCase(string str)
{
   string   s = str;
   int      lenght = StringLen(str) - 1;
   int      char;   
   while(lenght >= 0)
      {
         char = StringGetChar(s, lenght);        
         if((char > 96 && char < 123) || (char > 223 && char < 256))
                  s = StringSetChar(s, lenght, char - 32);
          else 
              if(char > -33 && char < 0)
                  s = StringSetChar(s, lenght, char + 224);                      
         lenght--;
   }
   return(s);
}

//-------------------------End Program------------------------------------
 

here is my code in build 600

//+------------------------------------------------------------------+
//|                                                     THV3 RSI.mq4 |
//|                        Copyright 2014, MetaQuotes Software Corp. |
//|                                              https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2014, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

#property indicator_separate_window

#property indicator_buffers    7
#property indicator_minimum    0
#property indicator_maximum    100
#property indicator_color1     Red
#property indicator_color2     LimeGreen
#property indicator_color3     DarkSlateGray

#property indicator_width1     5
#property indicator_width2     5
#property indicator_width3     1

#property indicator_color4     LimeGreen
#property indicator_color5     FireBrick
#property indicator_color6     Green
#property indicator_color7     Red

#property indicator_width4     1
#property indicator_width5     1   
#property indicator_width6     1
#property indicator_width7     1

#property indicator_style4     STYLE_DOT  //STYLE_SOLID
#property indicator_style5     STYLE_DOT  //STYLE_DOT  
#property indicator_style6     STYLE_DOT  //STYLE_DASH
#property indicator_style7     STYLE_DOT  //STYLE_DASHDOT, STYLE_DASHDOTDOT

//---- input parameters
extern int       RSIPeriod     =  5;
extern string    note1     =  "0=close;1=open;2=hi;3=low";
extern string    note2     =  "4=median;5=typical;6=weighted";
extern int       PriceType     =   0;
extern string note3 = "Chart Time Frame";
extern string note4 = "1=M1, 5=M5, 15=M15, 30=M30";
extern string note5 = "60=H1, 240=H4, 1440=D1";
extern string note6 = "10080=W1, 43200=MN1";
extern string    timeFrame     =  "Current time frame";
extern int       overBought    =  85;
extern int       overSold      =  15;
extern bool      showArrows    = false;
extern bool      alertsOn      = false;
extern bool      alertsMessage = false;
extern bool      alertsSound   = false;
extern bool      alertsEmail   = false;
//---- buffers

double   Upper[];
double   Lower[];
double   RSIBuffer[];
double   LineA[];
double   LineB[];
double   LineC[];
double   LineD[];

int      TimeFrame;
datetime TimeArray[];
int      maxArrows;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
      IndicatorBuffers(7);

      SetIndexBuffer(0,Upper); 
      SetIndexLabel (0,NULL);
      SetIndexBuffer(1,Lower);
      SetIndexLabel (1,NULL);
      SetIndexBuffer(2,RSIBuffer);
      SetIndexLabel (2,"RSI");
               
      SetIndexStyle(0,DRAW_LINE);        //Line at level 81
      SetIndexBuffer(3,LineA);
      SetIndexStyle(1,DRAW_LINE);        //Line at level 60
      SetIndexBuffer(4,LineB);   
      SetIndexStyle(2,DRAW_LINE);        //Line at level 40
      SetIndexBuffer(5,LineC);  
      SetIndexStyle(3,DRAW_LINE);        //Line at level 19
      SetIndexBuffer(6,LineD);

      TimeFrame         = stringToTimeFrame(timeFrame);
      string shortName  = "   THV RSI_v2   (Chart "+TimeFrameToString(TimeFrame)
                        +",  RSI Period "+RSIPeriod+",  "+PriceTypeToString(PriceType);
            if (overBought < overSold) overBought = overSold;
            if (overBought < 100)      shortName  = shortName+",  "+overBought;
            if (overSold   >   0)      shortName  = shortName+",  "+overSold;
      IndicatorShortName(shortName+")  ");

   return(0);
}

//+------------------------------------------------------------------+
//| Custom indicator de-initialization function                      |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
   DeleteArrows();
   
}

//+------------------------------------------------------------------+
//| 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[])
{
   int counted_bars=IndicatorCounted(), limit, i, y;
   if(counted_bars<0) return(-1);
   limit=Bars-counted_bars;
   ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame);     
   for(i=limit; i>=0; i--)
      {
      LineA[i]=79;
      LineB[i]=60;
      LineC[i]=40;
      LineD[i]=21;
      }
   for(i=0,y=0; i<limit; i++)
      {
      if(Time[i]<TimeArray[y])
         {
         y++; RSIBuffer[i] = iRSI(NULL,TimeFrame,RSIPeriod,PriceType,y);
         }
      }
   for(i=limit; i>=0; i--)
      {
      if (RSIBuffer[i] > overBought) { Upper[i] = RSIBuffer[i]; Upper[i+1] = RSIBuffer[i+1]; }
      else                           { Upper[i] = EMPTY_VALUE;
                                     if (Upper[i+2] == EMPTY_VALUE)
                                         Upper[i+1]  = EMPTY_VALUE; }
      if (RSIBuffer[i] < overSold)   { Lower[i] = RSIBuffer[i]; Lower[i+1] = RSIBuffer[i+1]; }
      else                           { Lower[i] = EMPTY_VALUE;
                                     if (Lower[i+2] == EMPTY_VALUE)
                                         Lower[i+1]  = EMPTY_VALUE; }  
      }
   if (showArrows)
      for (i=0; i<WindowBarsPerChart() ;i++)
         {
         if (RSIBuffer[i]>overBought && RSIBuffer[i+1]<overBought) DrawArrow(i,"up");
         if (RSIBuffer[i]<overSold   && RSIBuffer[i+1]>overSold)   DrawArrow(i,"down");
         }
   if (alertsOn)
      {
      if (RSIBuffer[0]>overBought && RSIBuffer[1]<overBought) doAlert(overBought+" line crossed up");
      if (RSIBuffer[0]<overSold   && RSIBuffer[1]>overSold)   doAlert(overBought+" line crossed down");
      }
   return(0);
}

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
void DrawArrow(int i,string type)
{
   maxArrows++;
      ObjectCreate("RSISignal"+maxArrows,OBJ_ARROW,0,Time[i],0);
      if (type=="up")
         {
            ObjectSet("RSISignal"+maxArrows,OBJPROP_PRICE1,High[i]+(8*Point));
            ObjectSet("RSISignal"+maxArrows,OBJPROP_ARROWCODE,242);
            ObjectSet("RSISignal"+maxArrows,OBJPROP_COLOR,Red);
         }
      else
         {
            ObjectSet("RSISignal"+maxArrows,OBJPROP_PRICE1,Low[i]-(6*Point));
            ObjectSet("RSISignal"+maxArrows,OBJPROP_ARROWCODE,241);
            ObjectSet("RSISignal"+maxArrows,OBJPROP_COLOR,LimeGreen);
         }
}
void DeleteArrows()
{
   while(maxArrows>0) { ObjectDelete("RSISignal"+maxArrows); maxArrows--; }
}

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
void doAlert(string doWhat)
{
   static string   previousAlert="nothing";
   static datetime previousTime;
   string message;  
      if (previousAlert != doWhat || previousTime != Time[0]) {
          previousAlert  = doWhat;
          previousTime   = Time[0];          
          message =  StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," RSI ",doWhat);
             if (alertsMessage) Alert(message);
             if (alertsSound)   PlaySound("alert2.wav");
             if (alertsEmail)   SendMail(StringConcatenate(Symbol()," RSI crossing"),message);
      }        
}

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
string PriceTypeToString(int pt)
{
   string answer;
   switch(pt)
   {
      case 0:  answer = "Close"    ; break; 
      case 1:  answer = "Open"     ; break;
      case 2:  answer = "High"     ; break;
      case 3:  answer = "Low"      ; break;
      case 4:  answer = "Median"   ; break;
      case 5:  answer = "Typical"  ; break;
      case 6:  answer = "Wighted"  ; break;
      default: answer = "Invalid price field requested";
                                    Alert(answer);
   }
   return(answer);
}
int stringToTimeFrame(string tfs)
{
   int tf=0;
       tfs = StringUpperCase(tfs);
         if (tfs=="M1" || tfs=="1")     tf=PERIOD_M1;
         if (tfs=="M5" || tfs=="5")     tf=PERIOD_M5;
         if (tfs=="M15"|| tfs=="15")    tf=PERIOD_M15;
         if (tfs=="M30"|| tfs=="30")    tf=PERIOD_M30;
         if (tfs=="H1" || tfs=="60")    tf=PERIOD_H1;
         if (tfs=="H4" || tfs=="240")   tf=PERIOD_H4;
         if (tfs=="D1" || tfs=="1440")  tf=PERIOD_D1;
         if (tfs=="W1" || tfs=="10080") tf=PERIOD_W1;
         if (tfs=="MN" || tfs=="43200") tf=PERIOD_MN1;
         if (tf<Period()) tf=Period();
  return(tf);
}
string TimeFrameToString(int tf)
{
   string tfs="Current time frame";
   switch(tf) {
      case PERIOD_M1:  tfs="M1"  ; break;
      case PERIOD_M5:  tfs="M5"  ; break;
      case PERIOD_M15: tfs="M15" ; break;
      case PERIOD_M30: tfs="M30" ; break;
      case PERIOD_H1:  tfs="H1"  ; break;
      case PERIOD_H4:  tfs="H4"  ; break;
      case PERIOD_D1:  tfs="D1"  ; break;
      case PERIOD_W1:  tfs="W1"  ; break;
      case PERIOD_MN1: tfs="MN1";
   }
   return(tfs);
}
string StringUpperCase(string str)
{
   string   s = str;
   int      lenght = StringLen(str) - 1;
   int      CHAR;   
   while(lenght >= 0)
      {
         CHAR = StringGetChar(s, lenght);        
         if((CHAR > 96 && CHAR < 123) || (CHAR > 223 && CHAR < 256))
                  s = StringSetChar(s, lenght, CHAR - 32);
          else 
              if(CHAR > -33 && CHAR < 0)
                  s = StringSetChar(s, lenght, CHAR + 224);                      
         lenght--;
   }
   return(s);
}

//-------------------------End Program------------------------------------
 
   limit=Bars-counted_bars;
   ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame);     
   for(i=limit; i>=0; i--)
      {
      LineA[i]=79;
When counted_bars == 0 limit = Bars. But LineA[Bars] does not exist.
 
WHRoeder:
When counted_bars == 0 limit = Bars. But LineA[Bars] does not exist.


Thank you very much WHRoeder.. you are the best

i made some modif.. and succesfull

 int counted_bars=IndicatorCounted(), limit, i, y;
   if(counted_bars<0) return(-1);
   limit=Bars-counted_bars;
   ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame);     

   int  LIMIT=limit-1; if (LIMIT<0)LIMIT=0;       // add this
   for(i=LIMIT; i>=0; i--)
      {
      LineA[i]=79;
      LineB[i]=60;
      LineC[i]=40;
      LineD[i]=21;
      }
   for(i=0,y=0; i<limit; i++)
      {
      if(Time[i]<TimeArray[y])
         {
         y++; RSIBuffer[i] = iRSI(NULL,TimeFrame,RSIPeriod,PriceType,y);
         }
      }
      
   for(i=LIMIT; i>=0; i--)
      {
      if (RSIBuffer[i] > overBought) { Upper[i] = RSIBuffer[i]; 
                                       if (i+2 <= Bars)         // add this
                                       Upper[i+1] = RSIBuffer[i+1]; }
      else                           { Upper[i] = EMPTY_VALUE;
                                    if (i+3 <= Bars)            // add this
                                    if (Upper[i+2] == EMPTY_VALUE)
                                         Upper[i+1]  = EMPTY_VALUE; }
      if (RSIBuffer[i] < overSold)   { Lower[i] = RSIBuffer[i]; 
                                       if (i+2 <= Bars)           // add this
                                       Lower[i+1] = RSIBuffer[i+1]; }
      else                           { Lower[i] = EMPTY_VALUE;
                                     if (i+3 <= Bars)             // add this
                                     if (Lower[i+2] == EMPTY_VALUE)
                                         Lower[i+1]  = EMPTY_VALUE; }  
      }
Reason: