Download MetaTrader 5

How can i solve this problem ???

To add comments, please log in or register
Having questions to the author of an article? Discuss them on the Forum!
Komoles Kumar
134
Komoles Kumar 2016.06.16 19:23 
#property indicator_chart_window

extern string    SetFile_name  = "forexall"; // File that contains symbols of user instruments
extern string    nameIndicator = "input indicator name";
extern int       ExtBuff1      = 0;
extern int       ExtBuff2      = 1;
extern string    UserText      = "Cross";
extern bool      Signal_email  = false;

string Symbols[1], text;
int expBars=0;

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
// If there is no new bar, exit
         if(!isNewBar()) return(EMPTY_VALUE);
int Total;
//---- Check for input parameter errors
         if (ControlError ()==false) return(EMPTY_VALUE);
//---- Load symbols from the file to the Symbols array
         LoadFileToSymbol();
//----

// Analyze the array of symbols (Calculations on the current and all lower time frames)
         for (int i=0; i<ArraySize(Symbols); i++)
            {  Total = 0;
               switch (Period())
                  {
                     case 43200: Total = Total +  process ( Symbols[i], 43200);
                     case 10080: Total = Total +  process ( Symbols[i], 10080);
                     case  1440: Total = Total +  process ( Symbols[i],  1440);
                     case   240: Total = Total +  process ( Symbols[i],   240);
                     case    60: Total = Total +  process ( Symbols[i],    60);
                     case    30: Total = Total +  process ( Symbols[i],    30);
                     case    15: Total = Total +  process ( Symbols[i],    15);
                     case     5: Total = Total +  process ( Symbols[i],     5);
//                     case     1: Total = Total +  process ( Symbols[i],     1);
                  }
        if (Total>1) 
               {
                  text = StringConcatenate (" Warning!!!      ", Symbols[i]," have ",UserText, " for ",Total, " TF");
                  Alert (text);
                  send_email (text);
               }
            }   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

int process (string Sym_, int TF)
   {
       text = StringConcatenate(Sym_," ",TF," indicator ",nameIndicator," Crossing line ");
double buffer1, buffer2, buffer12, buffer22;
// Analyze the first and second bars in the charts
            buffer1  = iCustom(Sym_, TF, nameIndicator, 0, ExtBuff1, 1);
            buffer12 = iCustom(Sym_, TF, nameIndicator, 0, ExtBuff1, 2);
            buffer2  = iCustom(Sym_, TF, nameIndicator, 0, ExtBuff2, 1);
            buffer22 = iCustom(Sym_, TF, nameIndicator, 0, ExtBuff2, 2);
            if(buffer12<=buffer22&&buffer1>buffer2)
               {
                  Alert (text+"UP"); // There is a crossover
                  send_email (text+"UP");
                  return (1);
               }
            if(buffer12>=buffer22&&buffer1<buffer2)
               {
                  Alert (text+"DN"); // There is a crossover
                  send_email (text+"DN");
                  return (1);
               } 
            return (0);
   
   }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
   
void LoadFileToSymbol()
   {
      {
              int file_handle = FileOpen(SetFile_name + ".set", FILE_READ);
              //---- If an error occurred
              if(file_handle < 0)
                {
                         Print("Error No.", GetLastError(), " when opening the file!!!");
                         //return(-1);
                }
              int SymbolsCount = 0;
              while(true)
                {
                         Symbols[SymbolsCount] = FileReadString(file_handle);
                         //---- If you have reached the end of the file, stop
                         if(GetLastError() == 4099) 
                             break;
                         if(FileIsEnding(file_handle)) 
                             break;
                         SymbolsCount ++;
                         ArrayResize(Symbols, SymbolsCount + 1);
                }
              FileClose(file_handle);
      }
   
   }  
//--------------------------------------------------------------+
void send_email (string texts)
   {
   if(Signal_email==true) SendMail ("Alert ",text);
   }
//--------------------------------------------------------------+
bool ControlError ()
   {
// Check whether the indicator name has been entered
         if (nameIndicator == "input indicator name")
            {
               Alert("Enter the indicator name ");
               return (false);
            }
// Check whether the file containing the symbols exists
int handle;
  handle=FileOpen(SetFile_name+ ".set",FILE_CSV|FILE_READ,';');
  if(handle<1)
    {
     Alert("The ",SetFile_name,".set file could not be found, last error ", GetLastError());
     return(false);
    }
// Check if there is any error in the assignment of input variables of the analyzed indicator buffers
   if (ExtBuff1>7||ExtBuff2>7) 
      {
         Alert("Incorrect parameters of the ExtBuff1 or ExtBuff2 buffer");
         return(false);
      }
   if (ExtBuff1==ExtBuff2) 
      {
         Alert("Error: ExtBuff1 è ExtBuff2 cannot be equal");
         return(false);
      }

return (true);   
   }
//+------------------------------------------------------------------+
//| The function will return true if the new bar appears,            |
//| otherwise false                                                  |
//+------------------------------------------------------------------+
 bool isNewBar()
 {
   bool res=false;
      if(expBars!=Bars)
         {expBars=Bars;
            res=true;
         }
  return(res);
 }
 problem in  LoadFileToSymbol() ?? 
Files:
12.JPG 53 kb
Omar Alkassar
2424
Omar Alkassar 2016.06.16 21:28  

its work perfectly

check this 

where is your forexall path ?? 

is it MQL4\Files??


where is your forexall name ?? 

is it forexall.set ?? 

Komoles Kumar
134
Komoles Kumar 2016.06.17 10:51  
Omar AlKassar:

its work perfectly

check this 

where is your forexall path ?? 

is it MQL4\Files??


where is your forexall name ?? 

is it forexall.set ?? 

yes its forexall.set ... but i got alert forexall.set not found . 
To add comments, please log in or register