//+------------------------------------------------------------------+
//|                                     MultiPair-MTF-ind-sample.mq4 |
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_separate_window

int TFs[10]={ 0, 1, 5, 15, 30, 60, 240, 1440, 10080, 43200 };
string TFns[10]={ "", "M1", "M5", "M15", "M30", "H1", "H4", "D1", "W1", "MN" };

string tpairs[40] = {"",
   "EURUSD", "GBPUSD", "USDJPY", "USDCHF", "USDCAD", "AUDUSD", "NZDUSD", "GBPCHF", "GBPJPY", "EURAUD",
   "EURCHF", "EURJPY", "EURGBP", "EURCAD", "CHFJPY", "AUDNZD", "AUDJPY", "CADJPY", "EURNZD", "GBPNZD",
   "CADCHF", "AUDCAD", "GBPAUD", "GBPCAD", "AUDCHF", "NZDCAD", "NZDCHF", "NZDJPY",
   "EURSEK", "EURNOK", "USDSEK", "USDNOK", "GOLD",   "SILVER"
};

int n_pairs=35;
datetime currentbar[10];
string txt, col, ap;
string short_name="MultiPair-MTF-ind-sample";
bool header=false;
//---- buffers

// indicators parameters

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   ArrayInitialize(currentbar,0);
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int x, np;
   if (!header)
   {
      header=true;
      for (x=1;x<10;x++)
      {
         // column header
         wr("CH1"+DoubleToStr(x,0), TFns[x], White, 30+(x*70), 15);  
         for (np=1;np<n_pairs;np++)
         {
            // line header
            wr("LH1"+DoubleToStr(np,0), tpairs[np], White, 1, 15+(np*15));  
         }
      }
   }

   for (x=1;x<10;x++)
   {
      if (iTime(Symbol(),TFs[x],0)!=currentbar[x])
      {
         currentbar[x]=iTime(Symbol(),TFs[x],0);

         for (np=1;np<n_pairs;np++)
         {
            ap=tpairs[np];

            //-----------------------------
            string txt=DoubleToStr(iClose(ap, TFs[x],1), MarketInfo(ap, MODE_DIGITS));
            color col=Lime;
            if (iClose(ap, TFs[x],1)<iOpen(ap, TFs[x],1)) { col=Red; }
            //-----------------------------
            // 1st section: price values
            wr("tr"+DoubleToStr(x,0)+"-"+DoubleToStr(np,0), txt, col, 30+(x*70), 15+(np*15));

            // 2nd section: small boxes
            wr("tb"+DoubleToStr(x,0)+"-"+DoubleToStr(np,0), CharToStr(110), col, 800+(x*10), 15+(np*15), "Wingdings");
         }
       }
   }

   return(0);
}

void wr(string objn, string text, color col, int xc, int yc, string ft="Verdana")
{
   ObjectCreate(objn, OBJ_LABEL, WindowFind(short_name), 0, 0);
   ObjectSetText(objn, text ,7, ft, col);
   ObjectSet(objn, OBJPROP_CORNER, 0);
   ObjectSet(objn, OBJPROP_XDISTANCE, xc);
   ObjectSet(objn, OBJPROP_YDISTANCE, yc);
}