//+------------------------------------------------------------------+
//|                                                 Multi_Signal.mq4 |
//|                                                           Сергей |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Сергей"
#property link      ""
#property  indicator_separate_window
//---- input parameters
extern int       MA_Cl.period=4;
extern int       MA_Op.period=16;
extern int       HMA_Slow.period=180; 
extern int       HMA_Quick.period=15;
extern int       timeframe=PERIOD_M15;
extern int       ReminderBar=4;
extern int       X=500;
extern int       Y=15;
extern int       window=1;
extern int       font_size=10;
extern int       IndicatorNumber=1;
extern string    __________________="_____________________";
extern string    Symbol.1="EURUSD";
extern color     Color.1=C'193,225,193'; 
extern string    Symbol.2="USDJPY";
extern color     Color.2=C'193,225,193'; 
extern string    Symbol.3="USDCHF";
extern color     Color.3=C'193,225,193'; 
extern string    Symbol.4="USDCAD";
extern color     Color.4=C'193,225,193'; 
extern string    Symbol.5="AUDUSD";
extern color     Color.5=C'193,225,193'; 
extern string    Symbol.6="NZDUSD";
extern color     Color.6=C'193,225,193'; 
extern string    Symbol.7="AUDJPY";
extern color     Color.7=C'149,205,255'; 
extern string    Symbol.8="CADJPY";
extern color     Color.8=C'149,205,255'; 
extern string    Symbol.9="CHFJPY";
extern color     Color.9=C'149,205,255'; 
extern string    Symbol.10="EURJPY";
extern color     Color.10=C'149,205,255'; 
extern string    Symbol.11="GBPJPY";
extern color     Color.11=C'149,205,255'; 
extern string    Symbol.12="NZDJPY";
extern color     Color.12=C'149,205,255'; 
extern string    Symbol.13="AUDCAD";
extern color     Color.13=Orange; 
extern string    Symbol.14="AUDCHF";
extern color     Color.14=Orange; 
extern string    Symbol.15="AUDNZD";
extern color     Color.15=Orange; 
extern string    Symbol.16="CADCHF";
extern color     Color.16=SeaGreen; 
extern string    Symbol.17="EURAUD";
extern color     Color.17=Maroon; 
extern string    Symbol.18="EURCAD";
extern color     Color.18=Maroon; 
extern string    Symbol.19="EURCHF";
extern color     Color.19=Maroon; 
extern string    Symbol.20="EURGBP";
extern color     Color.20=Maroon; 
extern string    Symbol.21="EURNZD";
extern color     Color.21=Maroon; 
extern string    Symbol.22="GBPAUD";
extern color     Color.22=MediumSpringGreen; 
extern string    Symbol.23="GBPCAD";
extern color     Color.23=MediumSpringGreen; 
extern string    Symbol.24="GBPCHF";
extern color     Color.24=MediumSpringGreen; 
extern string    Symbol.25="GBPNZD";
extern color     Color.25=MediumSpringGreen; 
extern string    Symbol.26="NZDCAD";
extern color     Color.26=Violet; 
extern string    Symbol.27="NZDCHF";
extern color     Color.27=Violet; 
extern string    Symbol.28="USDDKK";
extern color     Color.28=BlueViolet; 
extern string    Symbol.29="USDNOK";
extern color     Color.29=BlueViolet; 
extern string    Symbol.30="USDSEK";
extern color     Color.30=BlueViolet; 
extern string    Symbol.31="USDSGD";
extern color     Color.31=BlueViolet; 
extern string    Symbol.32="USDZAR";
extern color     Color.32=BlueViolet; 
extern string    Symbol.33="XAUUSD";
extern color     Color.33=Aqua; 
extern string    Symbol.34="XAGUSD";
extern color     Color.34=Aqua; 
extern string    Symbol.35="AUDLFX";
extern color     Color.35=C'0,176,0'; 
extern string    Symbol.36="CADLFX";
extern color     Color.36=C'0,176,0'; 
extern string    Symbol.37="CHFLFX";
extern color     Color.37=C'0,176,0'; 
extern string    Symbol.38="EURLFX";
extern color     Color.38=C'0,176,0'; 
extern string    Symbol.39="GBPLFX";
extern color     Color.39=C'0,176,0'; 
extern string    Symbol.40="LFXJPY";
extern color     Color.40=C'0,176,0'; 
extern string    Symbol.41="NZDLFX";
extern color     Color.41=C'0,176,0';
//----
int Bar;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//----
  ObjectCreate("Пара"+IndicatorNumber,OBJ_LABEL,window,0,0,0,0,0,0);
  ObjectSet("Пара"+IndicatorNumber,OBJPROP_XDISTANCE,X+16*font_size);
  ObjectSet("Пара"+IndicatorNumber,OBJPROP_YDISTANCE,Y);
  ObjectSetText("Пара"+IndicatorNumber,"Пара",font_size-3,"Verdana",NavajoWhite);
  ObjectSet("Пара"+IndicatorNumber,OBJPROP_CORNER,1); 

  ObjectCreate("Сигнал"+IndicatorNumber,OBJ_LABEL,window,0,0,0,0,0,0);
  ObjectSet("Сигнал"+IndicatorNumber,OBJPROP_XDISTANCE,X+11.5*font_size);
  ObjectSet("Сигнал"+IndicatorNumber,OBJPROP_YDISTANCE,Y+0.1*font_size);
  ObjectSetText("Сигнал"+IndicatorNumber,"Сигнал",font_size-3,"Ариал",NavajoWhite);
  ObjectSet("Сигнал"+IndicatorNumber,OBJPROP_CORNER,1);

  ObjectCreate("Тип/Лот"+IndicatorNumber,OBJ_LABEL,window,0,0,0,0,0,0);
  ObjectSet("Тип/Лот"+IndicatorNumber,OBJPROP_XDISTANCE,X+6.5*font_size);
  ObjectSet("Тип/Лот"+IndicatorNumber,OBJPROP_YDISTANCE,Y);
  ObjectSetText("Тип/Лот"+IndicatorNumber,"Тип/Лот",font_size-3,"Verdana",NavajoWhite);
  ObjectSet("Тип/Лот"+IndicatorNumber,OBJPROP_CORNER,1);
  Y=Y+1.5*font_size;
//----
CreateObject(Symbol.1,Y,Color.1);Y=Y+1.5*font_size;
CreateObject(Symbol.2,Y,Color.2);Y=Y+1.5*font_size;
CreateObject(Symbol.3,Y,Color.3);Y=Y+1.5*font_size;
CreateObject(Symbol.4,Y,Color.4);Y=Y+1.5*font_size;
CreateObject(Symbol.5,Y,Color.5);Y=Y+1.5*font_size;
CreateObject(Symbol.6,Y,Color.6);Y=Y+2*font_size;

CreateObject(Symbol.7,Y,Color.7);Y=Y+1.5*font_size;
CreateObject(Symbol.8,Y,Color.8);Y=Y+1.5*font_size;
CreateObject(Symbol.9,Y,Color.9);Y=Y+1.5*font_size;
CreateObject(Symbol.10,Y,Color.10);Y=Y+1.5*font_size;
CreateObject(Symbol.11,Y,Color.11);Y=Y+1.5*font_size;
CreateObject(Symbol.12,Y,Color.12);Y=Y+2*font_size;

CreateObject(Symbol.13,Y,Color.13);Y=Y+1.5*font_size;
CreateObject(Symbol.14,Y,Color.14);Y=Y+1.5*font_size;
CreateObject(Symbol.15,Y,Color.15);Y=Y+2*font_size;

CreateObject(Symbol.16,Y,Color.16);Y=Y+2*font_size;

CreateObject(Symbol.17,Y,Color.17);Y=Y+1.5*font_size;
CreateObject(Symbol.18,Y,Color.18);Y=Y+1.5*font_size;
CreateObject(Symbol.19,Y,Color.19);Y=Y+1.5*font_size;
CreateObject(Symbol.20,Y,Color.20);Y=Y+1.5*font_size;
CreateObject(Symbol.21,Y,Color.21);Y=Y+2*font_size;

CreateObject(Symbol.22,Y,Color.22);Y=Y+1.5*font_size;
CreateObject(Symbol.23,Y,Color.23);Y=Y+1.5*font_size;
CreateObject(Symbol.24,Y,Color.24);Y=Y+1.5*font_size;
CreateObject(Symbol.25,Y,Color.25);Y=Y+2*font_size;

CreateObject(Symbol.26,Y,Color.26);Y=Y+1.5*font_size;
CreateObject(Symbol.27,Y,Color.27);Y=Y+2*font_size;

CreateObject(Symbol.28,Y,Color.28);Y=Y+1.5*font_size;
CreateObject(Symbol.29,Y,Color.29);Y=Y+1.5*font_size;
CreateObject(Symbol.30,Y,Color.30);Y=Y+1.5*font_size;
CreateObject(Symbol.31,Y,Color.31);Y=Y+1.5*font_size;
CreateObject(Symbol.32,Y,Color.32);Y=Y+2*font_size;

CreateObject(Symbol.33,Y,Color.33);Y=Y+1.5*font_size;
CreateObject(Symbol.34,Y,Color.34);Y=Y+2*font_size;

CreateObject(Symbol.35,Y,Color.35);Y=Y+1.5*font_size;
CreateObject(Symbol.36,Y,Color.36);Y=Y+1.5*font_size;
CreateObject(Symbol.37,Y,Color.37);Y=Y+1.5*font_size;
CreateObject(Symbol.38,Y,Color.38);Y=Y+1.5*font_size;
CreateObject(Symbol.39,Y,Color.39);Y=Y+1.5*font_size;
CreateObject(Symbol.40,Y,Color.40);Y=Y+1.5*font_size;
CreateObject(Symbol.41,Y,Color.41);Y=Y+2*font_size;
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
ObjectDelete("Пара"+IndicatorNumber);
ObjectDelete("Сигнал"+IndicatorNumber);
ObjectDelete("Тип/Лот"+IndicatorNumber);
 DeleteObject(Symbol.1);
 DeleteObject(Symbol.2);
 DeleteObject(Symbol.3);
 DeleteObject(Symbol.4);
 DeleteObject(Symbol.5);
 DeleteObject(Symbol.6);
 DeleteObject(Symbol.7);
 DeleteObject(Symbol.8);
 DeleteObject(Symbol.9);
 DeleteObject(Symbol.10);
 
 DeleteObject(Symbol.11);
 DeleteObject(Symbol.12);
 DeleteObject(Symbol.13);
 DeleteObject(Symbol.14);
 DeleteObject(Symbol.15);
 DeleteObject(Symbol.16);
 DeleteObject(Symbol.17);
 DeleteObject(Symbol.18);
 DeleteObject(Symbol.19);
 DeleteObject(Symbol.20);
 
 DeleteObject(Symbol.21);
 DeleteObject(Symbol.22);
 DeleteObject(Symbol.23);
 DeleteObject(Symbol.24);
 DeleteObject(Symbol.25);
 DeleteObject(Symbol.26);
 DeleteObject(Symbol.27);
 DeleteObject(Symbol.28);
 DeleteObject(Symbol.29);
 DeleteObject(Symbol.30);
 
 DeleteObject(Symbol.31);
 DeleteObject(Symbol.32);
 DeleteObject(Symbol.33);
 DeleteObject(Symbol.34);
 DeleteObject(Symbol.35);
 DeleteObject(Symbol.36);
 DeleteObject(Symbol.37);
 DeleteObject(Symbol.38);
 DeleteObject(Symbol.39);
 DeleteObject(Symbol.40);
 
 DeleteObject(Symbol.41);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

//----
  if(Bar<iBars(Symbol(),timeframe))
    {
    Bar=iBars(Symbol(),timeframe);
    Alert("Multi_Signal новый бар!");
    }
if(Symbol.1!="")Signal(Symbol.1);
if(Symbol.2!="")Signal(Symbol.2);
if(Symbol.3!="")Signal(Symbol.3);
if(Symbol.4!="")Signal(Symbol.4);
if(Symbol.5!="")Signal(Symbol.5);
if(Symbol.6!="")Signal(Symbol.6);
if(Symbol.7!="")Signal(Symbol.7);
if(Symbol.8!="")Signal(Symbol.8);
if(Symbol.9!="")Signal(Symbol.9);
if(Symbol.10!="")Signal(Symbol.10);
    
if(Symbol.11!="")Signal(Symbol.11);
if(Symbol.12!="")Signal(Symbol.12);
if(Symbol.13!="")Signal(Symbol.13);
if(Symbol.14!="")Signal(Symbol.14);
if(Symbol.15!="")Signal(Symbol.15);
if(Symbol.16!="")Signal(Symbol.16);
if(Symbol.17!="")Signal(Symbol.17);
if(Symbol.18!="")Signal(Symbol.18);
if(Symbol.19!="")Signal(Symbol.19);
if(Symbol.20!="")Signal(Symbol.20);
    
if(Symbol.21!="")Signal(Symbol.21);
if(Symbol.22!="")Signal(Symbol.22);
if(Symbol.23!="")Signal(Symbol.23);
if(Symbol.24!="")Signal(Symbol.24);
if(Symbol.25!="")Signal(Symbol.25);
if(Symbol.26!="")Signal(Symbol.26);
if(Symbol.27!="")Signal(Symbol.27);
if(Symbol.28!="")Signal(Symbol.28);
if(Symbol.29!="")Signal(Symbol.29);
if(Symbol.30!="")Signal(Symbol.30);
     
if(Symbol.31!="")Signal(Symbol.31);
if(Symbol.32!="")Signal(Symbol.32);
if(Symbol.33!="")Signal(Symbol.33);
if(Symbol.34!="")Signal(Symbol.34);
if(Symbol.35!="")Signal(Symbol.35);
if(Symbol.36!="")Signal(Symbol.36);
if(Symbol.37!="")Signal(Symbol.37);
if(Symbol.38!="")Signal(Symbol.38);
if(Symbol.39!="")Signal(Symbol.39);
if(Symbol.40!="")Signal(Symbol.40);
     
if(Symbol.41!="")Signal(Symbol.41);
 
//----
   return(0);
  }
//+------------------------------------------------------------------+
void CreateObject(string symbol,int y,color Color)
  {
  ObjectCreate(symbol+IndicatorNumber,OBJ_LABEL,window,0,0,0,0,0,0);
  ObjectSet(symbol+IndicatorNumber,OBJPROP_XDISTANCE,X+15*font_size);
  ObjectSet(symbol+IndicatorNumber,OBJPROP_YDISTANCE,y);
  ObjectSetText(symbol+IndicatorNumber,symbol,font_size,"Verdana",Color);
  ObjectSet(symbol+IndicatorNumber,OBJPROP_CORNER,1);

  ObjectCreate(symbol+"Signal"+IndicatorNumber,OBJ_LABEL,window,0,0,0,0,0,0);
  ObjectSet(symbol+"Signal"+IndicatorNumber,OBJPROP_XDISTANCE,X+12*font_size);
  ObjectSet(symbol+"Signal"+IndicatorNumber,OBJPROP_YDISTANCE,y+0.1*font_size);
  ObjectSet(symbol+"Signal"+IndicatorNumber,OBJPROP_CORNER,1);

  ObjectCreate(symbol+"lot/type"+IndicatorNumber,OBJ_LABEL,window,0,0,0,0,0,0);
  ObjectSet(symbol+"lot/type"+IndicatorNumber,OBJPROP_XDISTANCE,X+7.5*font_size);
  ObjectSet(symbol+"lot/type"+IndicatorNumber,OBJPROP_YDISTANCE,y);
  ObjectSet(symbol+"lot/type"+IndicatorNumber,OBJPROP_CORNER,1); 
  }
//+------------------------------------------------------------------+
void DeleteObject(string symbol)
  {
  ObjectDelete(symbol+IndicatorNumber);
  ObjectDelete(symbol+"Signal"+IndicatorNumber); 
  ObjectDelete(symbol+"lot/type"+IndicatorNumber);  
  }
//+------------------------------------------------------------------+
int Signal(string symbol)
  {
//----проверка на торговлю по инструменту
  if(MarketInfo(symbol,MODE_TRADEALLOWED)==false)
    {
    Alert("Смотрю на ",symbol," а его нету в MarketInfo");return(0);
    }
//----
  int i=0;
  while(i<ReminderBar)
    {
    ObjectSetText(symbol+"Signal"+IndicatorNumber,"",font_size+1,"Ариал",CLR_NONE);
    double MA_Cl.0=iMA(symbol,timeframe,MA_Cl.period,0,MODE_SMMA,PRICE_CLOSE,i); 
    double MA_Cl.1=iMA(symbol,timeframe,MA_Cl.period,0,MODE_SMMA,PRICE_CLOSE,i+1);
    double MA_Cl.2=iMA(symbol,timeframe,MA_Cl.period,0,MODE_SMMA,PRICE_CLOSE,i+2);

    double MA_Op.0=iMA(symbol,timeframe,MA_Op.period,0,MODE_SMMA,PRICE_OPEN,i);
    double MA_Op.1=iMA(symbol,timeframe,MA_Op.period,0,MODE_SMMA,PRICE_OPEN,i+1);
    double MA_Op.2=iMA(symbol,timeframe,MA_Op.period,0,MODE_SMMA,PRICE_OPEN,i+2);
    
    double HMA.Slow=iCustom(symbol,timeframe,"Index_HMA",HMA_Slow.period,0,i);
    double ASK=MarketInfo(symbol,MODE_ASK);
    double BID=MarketInfo(symbol,MODE_BID);
    
    double HMA.Quick.1=iCustom(symbol,timeframe,"Index_HMA",HMA_Quick.period,0,i);    
    double HMA.Quick.2=iCustom(symbol,timeframe,"Index_HMA",HMA_Quick.period,0,i+1);
   
    double H_A.Purple=iCustom(symbol,timeframe,"Index_HeikenAshi",HMA_Quick.period,2,i);   
    double H_A.Green=iCustom(symbol,timeframe,"Index_HeikenAshi",HMA_Quick.period,3,i);
    
    //проверка на ноль данных
    if(MA_Cl.0==0.0 || MA_Cl.1==0.0 || MA_Cl.2==0.0 || MA_Op.0==0.0 || MA_Op.1==0.0 || MA_Op.2==0.0 || HMA.Slow==0.0 || 
       ASK==0.0 || BID==0.0 || HMA.Quick.1==0.0 || HMA.Quick.2==0.0 || H_A.Purple==0.0 || H_A.Green==0.0)
       {
       Alert("По инструменту ",symbol," есть в данных ноль!!!");
       }
    
    if(BID>HMA.Slow)
      {
      if(MA_Cl.2<MA_Op.2 && MA_Cl.1>MA_Op.1 && MA_Cl.0>MA_Op.0 && H_A.Green>H_A.Purple && HMA.Quick.1>HMA.Quick.2)
        {
        ObjectSetText(symbol+"Signal"+IndicatorNumber,"/\ ",font_size+1,"Ариал",Lime);
        i=ReminderBar;
        }      
      }
    else if(ASK<HMA.Slow)
      {
      if(MA_Cl.2>MA_Op.2 && MA_Cl.1<MA_Op.1 && MA_Cl.0<MA_Op.0 && H_A.Purple>H_A.Green && HMA.Quick.1<HMA.Quick.2)
        {
        ObjectSetText(symbol+"Signal"+IndicatorNumber,"\/ ",font_size+1,"Ариал",OrangeRed);
        i=ReminderBar;
        }
      }   
    i++;
    }
//----  
  double lots=0,profit=0;int type;
  for(int pos=OrdersTotal()-1;pos>=0;pos--)
    {
    if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES)==true)
      {
      if(OrderSymbol()==symbol)
        {
        lots+=OrderLots();
        type=OrderType();            
        }
      }
    else Print("Ошибка ",GetLastError());
    }
  if(lots>0)
    {
  //----  
    if(type==OP_BUY){ObjectSetText(symbol+"lot/type"+IndicatorNumber,DoubleToStr(lots,2),font_size,"Verdana",Lime);}
    else if(type==OP_SELL){ObjectSetText(symbol+"lot/type"+IndicatorNumber,DoubleToStr(lots,2),font_size,"Verdana",OrangeRed);}
  //----
    }
  else 
    {
    ObjectSetText(symbol+"lot/type"+IndicatorNumber,"",font_size,"Verdana",CLR_NONE);
    ObjectSetText(symbol+"Profit"+IndicatorNumber,"",font_size,"Verdana",CLR_NONE);
    }
//----
  }
//+------------------------------------------------------------------+