# How To make this code to scan multi Pairs

82

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

```
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);
}
```
Moderator
8168

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
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...
5159

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.

82