How To make this code to scan multi Pairs

 

Hi Can any one help with this code to scan multi pairs as it shown in the code.


      string pairs[]={"AUDCAD","AUDCHF","AUDNZD","AUDJPY","AUDUSD"};
      int PairsToScan = 5;


      bool isNewH1() 
      {
         static datetime BarTime;
         if (BarTime==0) 
         
         
         {
         BarTime=iTime(NULL,PERIOD_H1,0);
         }
         //----
         bool res=false;
         if (BarTime!=iTime(NULL,PERIOD_H1,0)) 
         {
         BarTime=iTime(NULL,PERIOD_H1,0);
         res=true;
         }
         return(res);
      }


//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
 
    return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{

   for(int i=0;i<PairsToScan;i++)


      double H1_Open1  = iOpen(pairs[i],PERIOD_H1,1);
      double H1_Close1 = iClose(pairs[i],PERIOD_H1,1);

      double H1_CloseRed   = H1_Close1 < H1_Open1;
      double H1_CloseGreen = H1_Close1 > H1_Open1;
      
      
      if (isNewH1() && H1_CloseRed)
          Alert("H1 Close Red    "+ pairs[i],"   ", TimeToStr(CurTime(),TIME_DATE | TIME_MINUTES),"  ");

      if (isNewH1() && H1_CloseGreen)
          Alert("H1 Close Green    "+ pairs[i],"   ", TimeToStr(CurTime(),TIME_DATE | TIME_MINUTES),"  ");









   return(0);
}
 

You can think along these lines too:

for(int i=0;i<SymbolsTotal(1);i++)
  {
   Print("SYMBOL: ",SymbolName(i,1)," Found At: ",i);
   
   // Do Something...
  }

Then you can easily add symbols if need be and it solves post and prefix problems among brokers by using SymbolName(pos) if you plan is to create a market product the use of 

      string pairs[]={"AUDCAD","AUDCHF","AUDNZD","AUDJPY","AUDUSD"};

Can become problematic so know that there are better solutions available.

Productivity - USA - Fundamental Analysis - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
Productivity - USA - Fundamental Analysis - Price Charts, Technical and Fundamental Analysis - MetaTrader 5 Help
  • www.metatrader5.com
The productivity index measures the output produced for each hour of labor worked. This indicator is useful for predicting inflation and output growth. If the cost of labor increases respective to the increase of productivity, and, moreover, if the increase in production costs is unlikely, then it will not cause inflation. It has a significant...
 
savio:

Hi Can any one help with this code to scan multi pairs as it shown in the code.

What do you mean by 'scan'? If you mean to perform a backtest in MT4 Strategy Tester,  it is not possible.

 
Jose Francisco Casado Fernandez:

What do you mean by 'scan'? If you mean to perform a backtest in MT4 Strategy Tester,  it is not possible.

scan mean search for met condition and alert

Reason: