//+------------------------------------------------------------------+
//|                                    major pairs - chart opens.mq4 |
//|                                                         NickBixy |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "NickBixy"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict



//save your perfered template as 'Default' if you want that to open with chart.
string symbolPrefix="";
string symbolPostfix="";
string symbols="AUDJPY,CADJPY,CHFJPY,EURJPY,GBPJPY,NZDJPY,USDJPY,";
ENUM_TIMEFRAMES timeFrame=PERIOD_H1;



string symbolList[]; // array of symbols
string symbolListFinal[]; // array of symbols after merging post and prefix

int numSymbols;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   getSymbols();

   for(int i=0;i<numSymbols;i++)
     {
      long result=ChartOpen(symbolListFinal[i],timeFrame);

      int errorCode=GetLastError();
      if(errorCode>0)
        {
         Alert("error code: "+(string)errorCode);
         Alert("Can't find this symbol: "+symbolListFinal[i]);
         Alert("also make sure prefix and postfix are correct");
         break;
        }
     }
  }
//+------------------------------------------------------------------+
void getSymbols()
  {
   string sep=",";
   ushort u_sep;
   u_sep=StringGetCharacter(sep,0);
   StringSplit(symbols,u_sep,symbolList);

   numSymbols=ArraySize(symbolList);//get the number of how many symbols are in the symbolList array

   ArrayResize(symbolListFinal,numSymbols);//resize finals symbol list to correct size

   for(int i=0;i<numSymbols;i++)//combines postfix , symbol , prefix names together
     {
      symbolListFinal[i]=symbolPrefix+symbolList[i]+symbolPostfix;
      //printf(symbolListFinal[i]);
     }
  }
//+------------------------------------------------------------------+
