//+------------------------------------------------------------------+
//|                                         MT4_DASHBOARD_V1.8.mq4   |
//|                                      Copyright © 2008, "OTCFX"   |
//|                                             Revision 1.8         |
//|                                        *Credits to"mladen"       |
//| #Version 1.8 gives crdit to "TRO"        for some bits&pieces.   |
//| for iCustom functions.                                          |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008 OTCFX"
//+------------------------------------------------------------------+
//|                                              TRO_Dashboard.mq4   |
//|                                        Copyright © 2008, "TRO"   |
//|                                                                  |
//+------------------------------------------------------------------+
//#property copyright "Copyright © 2007, Avery T. Horton, Jr. aka TheRumpledOne"
//#property link      "therumpledone@gmail.com"



#property indicator_separate_window  
#property indicator_buffers 0
#property indicator_minimum 0
#property indicator_maximum 1

extern string pairs        = "EURUSD;GBPUSD;AUDUSD;USDCHF;USDCAD;USDJPY;GBPJPY;EURJPY;GBPCHF;EURAUD;EURCHF;EURGBP";
string timeFrames   = "M5;M15;M30;H1;H4;D1;W1";
extern color  ColorUp      = LimeGreen;
extern color  ColorN = Gray ;
extern color  ColorDown    = Red ;
extern color  V_C = DodgerBlue;
extern color    ClrLab  = White;
extern color    DR_0  = DarkOrange;
extern int    V_Sz = 10;
extern string V_F = "Verdana";
extern string ___          = "~MA/X~";
extern int   FastMA  = 10 ;
extern int   SlowMA  = 15 ;
extern int   MAType        = 0  ;
extern int   PriceType     = 0   ;
extern string _____        = "~RSI_50~";
extern int   RSI50_Period  = 14 ;
extern int   Rsi_Price     = 0 ;
extern string ___________  = "~RSI~";
extern int   RSI_Period    = 14 ;
extern int   Rsi_Price2    = 0 ;
extern string ______       = "~MACD/X~";
extern int FastEMA = 12;
extern int SlowEMA = 26;
extern int SignalEMA = 9;
extern int Md_PRICE = 0;
extern string _______      = "~ADX/X~";
extern int ADXPeriod=14;
extern int ADXPrice=0;
extern string ____________  = "~iCustom~";
extern string Ind_Name_1    ="HMA_Russian_Color" ;
extern string i_Mode        = "#= Number of Buffers (eg:MACD=1)";
extern int    iMode  = 2;
extern double Period_ = -100;
extern double iParm4 = 3;
extern double iParm5 = 0;
extern double iParm6 = -100 ;
extern double iParm7 = -100;
extern double iParm8 = -100;
extern string Indicator_Sel    = "Indicator To Show(1 Only)";
extern bool showiCustom = false ;
extern bool showMa = false ;
extern bool showRsi_50 = false ;
extern bool showRsi = true ;
extern bool showCandle = false ;
extern bool showMacd = false ; 
extern bool showAdx = false ;
extern string ________    = "#Indicators To Calculate(+Up to 7)";
extern bool showCalculator = true ;
extern bool calciCustom = true ;
extern bool calcMa = true ;
extern bool calcRsi_50 = true ;
extern bool calcRsi = true ; 
extern bool calcMacd = true ;
extern bool calcAdx = true ;
extern bool calcCandle = true ;
string    WG_DS ="Wingdings";
int      window;  
int      totalPairs;
int      totalTimeFrames;
int      totalLabels;
int      aTimes[];
string   aPairs[];
string   sTimes[];
color    CD_B =  CadetBlue;
color    LG_R =  LimeGreen;
color    macd_color;
color    MA_color;
color    srsi_color;
color    srsi1_color;
color    cad_color;
color    adx_color;
color    iC_color;
string   srsi1_arrow;
string   adx_arrow;
string   MA_arrow;
string   macd_arrow;
string   srsi_arrow;
string   cad_arrow;
string   iC_arrow;

string   labelNames;
string   shortName;
int      corner;
int      AXINC_UP,MDINC_UP,MAINC_UP,RSPINC_UP,RSINC_UP,CDINC_UP;
int      AXINC_DN,MDINC_DN,MAINC_DN,RSPINC_DN,RSINC_DN,CDINC_DN;
int      AXINC_UC,MDINC_UC,MAINC_UC,RSPINC_UC,RSINC_UC,CDINC_UC;
int      INCIC_UP ,INCIC_UC,INCIC_DN;
int MAMode;
 
int      INC_UP,INC_UC ,INC_DN;
 
string    strMAType;

 bool   ShowCount    = true;

 string Pr0    = "" ;
 string Pr1    = "" ;
 string Pr2    = "" ;
 string Pr3    = "" ;
 string Pr4    = "" ;
 string Pr5    = "" ;
 string Pr6    = "" ;
 string Pr7    = "" ;
 string Pr8    = "" ;
 string Pr9    = "" ;
 string Pr10   = "" ;
 string Pr11   = "" ;
 string Pr12   = "" ;
 string Pr13   = "" ;
 string Pr14   = "" ;
 string Pr15   = "" ;
 string Pr16   = "" ;
 string Pr17   = "" ;
 string Pr18   = "" ;
 string Pr19   = "" ;
 string Pr20   = "" ;

double cVal = 0, pVal = 0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
{




switch (MAType)
   {
      case 1: strMAType="EMA"; MAMode=MODE_EMA; break;
      case 2: strMAType="SMMA"; MAMode=MODE_SMMA; break;
      case 3: strMAType="LWMA"; MAMode=MODE_LWMA; break;
      case 4: strMAType="LSMA"; break;
      default: strMAType="SMA"; MAMode=MODE_SMA; break;
   }
     
    
  
   corner     = 0;
   shortName  = MakeUniqueName("MT4_DB ","");
   labelNames = shortName;
   IndicatorShortName(shortName);

    
      pairs = StringUpperCase(StringTrimLeft(StringTrimRight(pairs)));
      if (StringSubstr(pairs,StringLen(pairs),1) != ";")
      pairs = StringConcatenate(pairs,";");
                                  

         bool isMini = IsMini();            
         int  s      = 0;
         int  i      = StringFind(pairs,";",s);
         int time;
         string current;
        
         
            while (i > 0)
            {
               current = StringSubstr(pairs,s,i-s);
               if (isMini) current = StringConcatenate(current,"m");
              time    = stringToTimeFrame(current);
               current = StringSubstr(pairs,s,i-s);
               if (isMini) current = StringConcatenate(current,"m");
               if (iClose(current,0,0) > 0) {
               ArrayResize(aPairs,ArraySize(aPairs)+1);
                aPairs[ArraySize(aPairs)-1] = current; }
                 s = i + 1;
                i = StringFind(pairs,";",s);
                                                                                   
                                     
            }
    

      timeFrames = StringUpperCase(StringTrimLeft(StringTrimRight(timeFrames)));
      if (StringSubstr(timeFrames,StringLen(timeFrames),1) != ";")
       timeFrames = StringConcatenate(timeFrames,";");

                                                  
         s = 0;
         i = StringFind(timeFrames,";",s);
         //int time;
          while (i > 0)
            {
           current = StringSubstr(timeFrames,s,i-s);
           time    = stringToTimeFrame(current);
           if (time > 0) {
           ArrayResize(sTimes,ArraySize(sTimes)+1);
           ArrayResize(aTimes,ArraySize(aTimes)+1);
           sTimes[ArraySize(sTimes)-1] = TimeFrameToString(time); 
           aTimes[ArraySize(aTimes)-1] = time; }
           s = i + 1;
           i = StringFind(timeFrames,";",s);
            }

   

      totalTimeFrames = ArraySize(aTimes);
      totalPairs      = ArraySize(aPairs);
      
      
  Pr0    = aPairs[0];
  Pr1    = aPairs[1];
  Pr2    = aPairs[2];
  Pr3    = aPairs[3];
  Pr4    = aPairs[4];
  Pr5    = aPairs[5];
  Pr6    = aPairs[6];
  Pr7    = aPairs[7];
  Pr8    = aPairs[8];
  Pr9    = aPairs[9];
  Pr10   = aPairs[10];
  Pr11   = aPairs[11];
  Pr12   = aPairs[12];
  Pr13   = aPairs[13];
  Pr14   = aPairs[14];
  Pr15   = aPairs[15];
  Pr16   = aPairs[16];
  Pr17   = aPairs[17];
  Pr18   = aPairs[18];
  Pr19   = aPairs[19];
  Pr20   = aPairs[20];
  
  
     

return(0);
}




//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   while (totalLabels>0) { ObjectDelete(StringConcatenate(labelNames,totalLabels)); totalLabels--;}
     
   return(0);
}


//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int start()
{

ObjectsDeleteAll( window, 21);
ObjectsDeleteAll( window, 22);
ObjectsDeleteAll( window, 23);
int m,n;
int i,k;

    

   window      = WindowFind(shortName);
   totalLabels = 0;
    for (i=0,m=30; i < totalPairs;      i++, m+=25){
    
   MDINC_UP=0; 
   AXINC_UP=0;
   MAINC_UP=0;
   RSINC_UP=0;
   RSPINC_UP=0;
   CDINC_UP=0;
   INC_UP = 0;   
   INC_UC = 0;
   INC_DN = 0;
   INCIC_UP = 0;
   INCIC_UC = 0;
   INCIC_DN = 0; 
   for (k=0,n=170; k < totalTimeFrames; k++, n+=46){
   showPair(aPairs[i],aTimes[k],sTimes[k],m,n);}
   if (ShowCount)  DoShowCount(m,n); }
   if(V_Sz>12) V_Sz=12;            
   if (Pr1 == "") Pr1 = Symbol();
    
  
     
   return(0);
}


//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+


void DoShowCount( int xdi, int ydi )
{
 
 double PERp,PERC,PER;
 int PCT1,PCT2,PCT3,PCT4,PCT5,PCT6,PCT7,TL1,TL2 = 0;  
 int yInc = -125;
 int C_1,C_2,C_3,C_4,C_5,C_6,C_7 = 0;
 int UI1=0;
 if (calciCustom==true){ {PCT7 = INCIC_UP ;}{C_7=7;}}
 
 if (calcMa==true){ {PCT4 = MAINC_UP ;}{C_4=7;}}

 if (calcRsi_50 == true){  {PCT2 = RSINC_UP ; } {C_2=7;}}
  
 if (calcRsi==true){ {PCT3 = RSPINC_UP  ;}{C_3=7;}}
  
 if (calcMacd==true) { {PCT1 = MDINC_UP;} {C_1=7;}}

 if (calcAdx==true){ {PCT5 = AXINC_UP ;}{C_5=7;}}
 
 if (calcCandle==true){ { PCT6 = CDINC_UP  ;}{C_6=7;}} 
 
 
  TL1 = C_1 + C_2 + C_3 + C_4 + C_5 + C_6 + C_7;     
  PER = PCT1 + PCT2 + PCT3 + PCT4 + PCT5 + PCT6 +PCT7;   
  PERC=PER*100;
  PERp=PERC/TL1;
  
  
 //////>>>>>>Calculation Selection<<<<<<<<<<<

  string MT = strMAType;
 
 
    if (showCalculator==true){     
   sOt(next(),"7",700,16,V_C     ,WG_DS,13);
   sOt(next(),"Calculator " ,     625 ,17,V_C, V_F,V_Sz);
   
    if (calcMa==true){ 
   sOt(next(),"Ma/x:" , 630,30,ClrLab, V_F,V_Sz);
   sOt(next(),FastMA + ","+ SlowMA + "," + strMAType +","+ PriceType , 668,30,DR_0, V_F,V_Sz);   
   sOt(next(),"è",615,31,LG_R     ,WG_DS,10);}
           
    if (calcRsi_50 == true){
   sOt(next(),"Rsi_50:",630,44,ClrLab, V_F ,V_Sz);
   sOt(next(),RSI50_Period + "," + Rsi_Price,680,44,DR_0, V_F ,V_Sz);  
   sOt(next(),"è",615,44,LG_R     ,WG_DS,10);}
   
   if (calcRsi==true){
   sOt(next(),"Rsi:" ,630,56,ClrLab, V_F, V_Sz);
   sOt(next(),RSI_Period + "," + Rsi_Price2 ,680,56,DR_0, V_F, V_Sz);
   sOt(next(),"è",615,57,LG_R     ,WG_DS,10);}
        
    if (calcMacd==true){     
   sOt(next(),"Macd/x:",630,69,ClrLab,V_F, V_Sz);
   sOt(next(),FastEMA + "," + SlowEMA + "," + SignalEMA + "," + Md_PRICE,680,69,DR_0,V_F, V_Sz);   
   sOt(next(),"è",615,70,LG_R     ,WG_DS,10);}
   
   if (calcAdx==true){        
   sOt(next(),"Adx/x:" ,630,82,ClrLab, V_F, V_Sz);
   sOt(next(),ADXPeriod+","+ADXPrice ,680,82,DR_0, V_F, V_Sz);   
   sOt(next(),"è",615,84,LG_R     ,WG_DS,10);}
   
    if (calcCandle==true){
   sOt(next(),"Candle:", 630,95,ClrLab, V_F, V_Sz);
   sOt(next(),"CL" + "^" + "OP", 680,95,ClrLab, V_F, V_Sz);
   sOt(next(),"è",615,98,LG_R     ,WG_DS,10);}}
   
   
   if (calciCustom==true){
   string cTitle = Ind_Name_1  ;

  if(Period_ != -100) { cTitle = cTitle + "*" + DoubleToStr(Period_,0) ; }
  if(iParm4 != -100) { cTitle = cTitle + "," + DoubleToStr(iParm4,0) ; }
  if(iParm5 != -100) { cTitle = cTitle + "," + DoubleToStr(iParm5,0) ; }
  if(iParm6 != -100) { cTitle = cTitle + "," + DoubleToStr(iParm6,0) ; }
  if(iParm7 != -100) { cTitle = cTitle + "," + DoubleToStr(iParm7,0) ; }
  if(iParm8 != -100) { cTitle = cTitle + "," + DoubleToStr(iParm8,0) ; }
  cTitle = cTitle + " |iM=" + iMode  ; 

   sOt(next(),cTitle,630,108, DR_0 ,V_F,V_Sz);
   sOt(next(),"è",615,111,LG_R     ,WG_DS,10);}
   
  
  string PER_Str =DoubleToStr(PERp,Point);
   
  color xCol = Yellow ;
 
  if( PERp > 50) { xCol = LG_R ; }
  else if( PERp < 50 ) { xCol = Crimson ; }
  
if ( showiCustom == true){ 
 {showRsi = false;}  
 {showRsi_50 = false; }
 {showMacd  = false;}
 {showCandle = false ;}
 {showAdx = false ;} 
 {showMa = false ;}}
  
if ( showMa == true){ 
 {showRsi = false;}  
 {showRsi_50 = false; }
 {showMacd  = false;}
 {showCandle = false ;}
 {showAdx = false ;}
 {showiCustom = false ;}}

if ( showRsi_50 == true){ 
 {showMa = false;}  
 {showRsi = false; }
 {showMacd  = false;}
 {showCandle = false ;}
 {showAdx = false ;}
 {showiCustom = false ;}}

if ( showRsi == true){ 
 {showMa = false;}  
 {showRsi_50 = false; }
 {showMacd  = false;}
 {showCandle = false ;}
 {showAdx = false ;}
 {showiCustom = false ;}}

if ( showCandle == true){ 
 {showRsi = false;}  
 {showRsi_50 = false; }
 {showMacd  = false;}
 {showMa = false ;}
 {showAdx = false ;}
{showiCustom = false ;}}

if ( showMacd == true){ 
 {showRsi = false;}  
 {showRsi_50 = false; }
 {showCandle  = false;}
 {showMa = false ;}
 {showAdx = false ;}
 {showiCustom = false ;}}
 
if ( showAdx == true){ 
 {showRsi = false;}  
 {showRsi_50 = false; }
 {showCandle  = false;}
 {showMa = false ;}
 {showMacd = false ;}
 {showiCustom = false ;}}



  
   sOt(next(),"MT4 DASHBOARD INDICATOR © 2008 OTCFX",64,5, Gray ,V_F,7,0);
   int a = 130;
 
   //if(show.SCORE){  
   sOt(next(),PER_Str,525,xdi + 10, xCol ,"Arial bold",10,0);//}
   sOt(next(),Pr0,a,40, V_C ,V_F,V_Sz);
   sOt(next(),Pr1,a,65, V_C ,V_F,V_Sz);
   sOt(next(),Pr2,a,90, V_C ,V_F,V_Sz);
   sOt(next(),Pr3,a,115, V_C ,V_F,V_Sz);
   sOt(next(),Pr4,a,140, V_C ,V_F,V_Sz);
   sOt(next(),Pr5,a,165, V_C ,V_F,V_Sz);
   sOt(next(),Pr6,a,190, V_C ,V_F,V_Sz);
   sOt(next(),Pr7,a,215, V_C ,V_F,V_Sz);
   sOt(next(),Pr8,a,240, V_C ,V_F,V_Sz);
   sOt(next(),Pr9,a,265, V_C ,V_F,V_Sz);
   sOt(next(),Pr10,a,290, V_C ,V_F,V_Sz);
   sOt(next(),Pr11,a,315, V_C ,V_F,V_Sz);
   sOt(next(),Pr12,a,340, V_C ,V_F,V_Sz);
   sOt(next(),Pr13,a,365, V_C ,V_F,V_Sz);
   sOt(next(),Pr14,a,390, V_C ,V_F,V_Sz);
   sOt(next(),Pr15,a,415, V_C ,V_F,V_Sz);
   sOt(next(),Pr16,a,440, V_C ,V_F,V_Sz);
   sOt(next(),Pr17,a,465, V_C ,V_F,V_Sz);
   sOt(next(),Pr18,a,490, V_C ,V_F,V_Sz);
   sOt(next(),Pr19,a,515, V_C ,V_F,V_Sz);
   
  
   
   if(showMa){
   sOt(next(),"Ma/x:" , 335,3,ClrLab, V_F,V_Sz);
   sOt(next(),FastMA + ","+ SlowMA + "," + strMAType +","+ PriceType , 375,3,DR_0, V_F,V_Sz);  
   sOt(next(),"è",318,3,LG_R     ,WG_DS,10);}
   
   if(showRsi_50){
   sOt(next(),"Rsi_50:",335,3,ClrLab, V_F ,V_Sz);
   sOt(next(),RSI50_Period + "," + Rsi_Price,385,3,DR_0, V_F ,V_Sz);
   sOt(next(),"è",318,3,LG_R     ,WG_DS,10);}
   
   if(showRsi){ 
   sOt(next(),"Rsi:" ,335,3,ClrLab, V_F, V_Sz);
   sOt(next(),RSI_Period + "," + Rsi_Price2 ,375,3,DR_0, V_F, V_Sz);   
   sOt(next(),"è",318,3,LG_R     ,WG_DS,10);}
   
   if(showMacd){ 
   sOt(next(),"Macd/x:",335,3,ClrLab,V_F, V_Sz);
   sOt(next(),FastEMA+","+SlowEMA+","+SignalEMA+","+Md_PRICE,390,3,DR_0,V_F, V_Sz);   
   sOt(next(),"è",318,3,LG_R     ,WG_DS,10);}
   
   
    if(showAdx){  
   sOt(next(),"Adx/x:" ,335,3,ClrLab, V_F, V_Sz);
   sOt(next(),ADXPeriod+","+ ADXPrice,380,3,DR_0, V_F, V_Sz);
   sOt(next(),"è",318,3,LG_R     ,WG_DS,10);}
   
     if(showCandle){ 
   sOt(next(),"Candle:", 335,3,ClrLab, V_F, V_Sz);
   sOt(next(),"CL" + "^" + "OP", 383,3,ClrLab, V_F, V_Sz);
   //sOt(next(),"^", 400,3,DR_0, V_F, V_Sz);
   sOt(next(),"è",318,3,LG_R     ,WG_DS,10);}
   
   //if(show.iCustom){ 
   string bTitle = Ind_Name_1 ;
  
   if(Period_ != -100) { bTitle = bTitle+"*" +     DoubleToStr(Period_,0) ; }
   if(iParm4 != -100) { bTitle = bTitle+ ","+    DoubleToStr(iParm4,0) ; }
   if(iParm5 != -100) { bTitle = bTitle+ "," +   DoubleToStr(iParm5,0) ; }
   if(iParm6 != -100) { bTitle =bTitle+  ","+   DoubleToStr(iParm6,0) ; }
   if(iParm7 != -100) { bTitle = bTitle+ ","+   DoubleToStr(iParm7,0) ; }
   if(iParm8 != -100) { bTitle = bTitle+ "," +  DoubleToStr(iParm8,0) ; }
   bTitle =bTitle+  " |iM=" + iMode  ; 
   if(showiCustom){ 
   sOt(next(),bTitle,335,3, DR_0 ,V_F,V_Sz);
   sOt(next(),"è",318,3,LG_R     ,WG_DS,10);}  
   
   sOt(next(),"PAIR",140,18, V_C ,V_F,V_Sz);
   sOt(next(),"M5",200,18, V_C ,V_F,V_Sz);
   sOt(next(),"M15",245,18, V_C ,V_F,V_Sz);
   sOt(next(),"M30",290,18, V_C ,V_F,V_Sz);
   sOt(next(),"H1",340,18, V_C ,V_F,V_Sz);
   sOt(next(),"H4",385,18, V_C ,V_F,V_Sz);
   sOt(next(),"D1",430,18, V_C ,V_F,V_Sz);
   sOt(next(),"W1",475,18, V_C ,V_F,V_Sz);
    
   sOt(next(),"%/",520,18, V_C ,V_F,V_Sz);
   
   sOt(next(),"7",538,18,V_C     ,WG_DS,13);  
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+


void showPair(string pair, int timeFrame,string label, int xd, int yd)
{
   double icl,icl1,ima1,ima2,srsi,srsi1,srsi2;
   double adx1,adx2,Macdmain,MacdSignal;
     
  
    adx1 = iADX(pair,timeFrame,ADXPeriod,ADXPrice,MODE_PLUSDI,0);
    adx2 = iADX(pair,timeFrame,ADXPeriod,ADXPrice,MODE_MINUSDI,0);
     
    Macdmain = iMACD(pair,timeFrame,FastEMA,SlowEMA,SignalEMA,Md_PRICE,MODE_MAIN,0);    
    MacdSignal = iMACD(pair,timeFrame,FastEMA,SlowEMA,SignalEMA,Md_PRICE,MODE_SIGNAL,0);    
    
    icl   = iClose(pair,timeFrame,0);
    icl1  = iOpen(pair,timeFrame,0);
      
    ima1  =  iMA(pair,timeFrame,FastMA,0,MAType,PriceType,0);
    ima2  = iMA(pair,timeFrame,SlowMA,0,MAType,PriceType,0);
           
    srsi  = iRSI(pair,timeFrame ,RSI50_Period,Rsi_Price,0);
    
         
    srsi1 = iRSI(pair,timeFrame ,RSI_Period,Rsi_Price2,0); 
    srsi2 = iRSI(pair,timeFrame ,RSI_Period,Rsi_Price2,1);
    
    
    
    DoWork(pair,timeFrame,1) ;   
    pVal = cVal ;      
    DoWork(pair,timeFrame,0) ;    
    
  
    if (cVal > pVal) { INCIC_UP = INCIC_UP +1 ; iC_color = ColorUp;      iC_arrow = "Ù"; } else {
    if (cVal < pVal) { INCIC_DN = INCIC_DN +1 ; iC_color = ColorDown;    iC_arrow = "Ú"; } else {
                      INCIC_UC = INCIC_UC +1 ; iC_color = ColorN;       iC_arrow = "h"; } }
        
  
    setADXAr(adx1,adx2);
    setMACDAr(Macdmain,MacdSignal);
    setRSI2Ar(srsi1,srsi2);        
    setCANAr(icl,icl1);   
    setRSIAr(srsi);   
    setMAColAr(ima1,ima2);
    
    if(showAdx){
      setLabel(" "  ,xd+10,yd+30," ",adx_color,adx_arrow);}       
    if(showMacd){ 
     setLabel(" "  ,xd+10,yd+30," ",macd_color,macd_arrow);}             
    if(showRsi){
    setLabel(" "  ,xd+10,yd+30," ",srsi1_color,srsi1_arrow);}   
    if(showRsi_50){
    setLabel(" "  ,xd+10,yd+30," ",srsi_color,srsi_arrow);}
    if(showMa){
    setLabel(" "  ,xd+10,yd+30," ",MA_color,MA_arrow);}
    if(showCandle){
    setLabel(" "  ,xd+10,yd+30," ",cad_color,cad_arrow);}    
    if(showiCustom){
     setLabel(" "  ,xd+10,yd+30," ",iC_color,iC_arrow);}
           
    
  }

//+------------------------------------------------------------------+
//| Custom functions and procedures                                  |
//+------------------------------------------------------------------+
string next() { totalLabels++; return(totalLabels); }


void       setADXAr(double adx1 ,double adx2)

{
     
      if (adx1 > adx2) { AXINC_UP = AXINC_UP + 1 ;       adx_color = ColorUp;     adx_arrow   = "Ù";} 
      if (adx1 < adx2) { AXINC_DN = AXINC_DN + 1 ;        adx_color = ColorDown;    adx_arrow   = "Ú";} 
      if (adx1==adx2) {AXINC_UC = AXINC_UC + 1 ;        adx_color = ColorN; adx_arrow = "h"; }
  }    


void       setMACDAr(double Macdmain ,double MacdSignal)

{
    
      if (Macdmain > MacdSignal) { MDINC_UP = MDINC_UP + 1 ;       macd_color = ColorUp;     macd_arrow   = "Ù";} 
      if (Macdmain < MacdSignal) { MDINC_DN = MDINC_DN + 1 ;        macd_color = ColorDown;    macd_arrow   = "Ú";} 
      if (MacdSignal==Macdmain){MDINC_UC = MDINC_UC + 1 ;        macd_color = ColorN; macd_arrow = "h"; }
  }     

void       setCANAr(double icl,double icl1)
{
  
      if (icl > icl1) { CDINC_UP = CDINC_UP + 1 ;       cad_color = ColorUp;     cad_arrow   = "5"; }
      if (icl < icl1) { CDINC_DN = CDINC_DN + 1 ;       cad_color = ColorDown;    cad_arrow   = "5"; }
      if (icl==icl1) {CDINC_UC = CDINC_UC + 1 ;       cad_color = ColorN; cad_arrow = "h"; }
      
}
void setRSIAr(double srsi)
{
  
      if (srsi > 50) { RSINC_UP = RSINC_UP + 1 ;  srsi_color = ColorUp;      srsi_arrow = "Ù"; }
      if (srsi < 50) {  RSINC_DN = RSINC_DN + 1 ; srsi_color = ColorDown;    srsi_arrow = "Ú"; }
      if (srsi==50) { RSINC_UC = RSINC_UC + 1 ;  srsi_color = ColorN; srsi_arrow = "h"; }
      
 }     
      
 void setRSI2Ar(double srsi1,  double srsi2)
{       
      
      
      if (srsi1 > srsi2) { RSPINC_UP = RSPINC_UP + 1 ;   srsi1_color = ColorUp;      srsi1_arrow = "Ù"; }
      if (srsi1 < srsi2) {  RSPINC_DN = RSPINC_DN + 1 ;  srsi1_color = ColorDown;    srsi1_arrow = "Ú"; }
      if (srsi1==srsi2) {RSPINC_UC = RSPINC_UC + 1 ;  srsi1_color = ColorN; srsi1_arrow = "h"; }
      
           
      
}
void setMAColAr(double ima1,double ima2)
{
        
      if (ima1 > ima2) { MAINC_UP = MAINC_UP + 1 ;  MA_color = ColorUp;      MA_arrow = "Ù"; }
      if (ima1 < ima2) {  MAINC_DN = MAINC_DN + 1 ;  MA_color = ColorDown;    MA_arrow = "Ú"; }
      if (ima1==ima2) { MAINC_UC = MAINC_UC + 1 ;  MA_color = ColorN; MA_arrow = "h"; }}
      
      
      
   
    
   
      
      
      
      
       

void setLabel(string text,int x,int y,string sarv, color theColor, string arrow, bool isADX=true)
{
    
                sOt(next(),arrow                  ,y,x,theColor,"Wingdings",14,0);
      
 }              
             

void sOt(string name,string text,int x,int y,color theColor, string font = "Verdana",int size=10,int angle=0)
{
   string labelName = StringConcatenate(labelNames,name);

  
      if (ObjectFind(labelName) == -1)
          {
             ObjectCreate(labelName,OBJ_LABEL,window,0,0);
             ObjectSet(labelName,OBJPROP_CORNER,corner);
             if (angle != 0)
             ObjectSet(labelName,OBJPROP_ANGLE,angle);
          }               
       ObjectSet(labelName,OBJPROP_XDISTANCE,x);
       ObjectSet(labelName,OBJPROP_YDISTANCE,y);
       ObjectSetText(labelName,text,size,font,theColor);
}


int stringToTimeFrame(string tfs)
{
   int tf=0;
       tfs = StringTrimLeft(StringTrimRight(StringUpperCase(tfs)));
         if (tfs == "M1" || tfs == "1")     tf = PERIOD_M1;
         if (tfs == "M5" || tfs == "5")     tf = PERIOD_M5;
         if (tfs == "M15"|| tfs == "15")    tf = PERIOD_M15;
         if (tfs == "M30"|| tfs == "30")    tf = PERIOD_M30;
         if (tfs == "H1" || tfs == "60")    tf = PERIOD_H1;
         if (tfs == "H4" || tfs == "240")   tf = PERIOD_H4;
         if (tfs == "D1" || tfs == "1440")  tf = PERIOD_D1;
         if (tfs == "W1" || tfs == "10080") tf = PERIOD_W1;
         if (tfs == "MN" || tfs == "43200") tf = PERIOD_MN1;
  return(tf);
}
string TimeFrameToString(int tf)
{
   string tfs;
   switch(tf) {
      case PERIOD_M1:  tfs = "M1"  ; break;
      case PERIOD_M5:  tfs = "M5"  ; break;
      case PERIOD_M15: tfs = "M15" ; break;
      case PERIOD_M30: tfs = "M30" ; break;
      case PERIOD_H1:  tfs = "H1"  ; break;
      case PERIOD_H4:  tfs = "H4"  ; break;
      case PERIOD_D1:  tfs = "D1"  ; break;
      case PERIOD_W1:  tfs = "W1"  ; break;
      case PERIOD_MN1: tfs = "MN1";
   }
   return(tfs);
}

string StringUpperCase(string str)
{
   string   s = str;
   int      lenght = StringLen(str) - 1;
   int      tchar;
   
   while(lenght >= 0)
      {
         tchar = StringGetChar(s, lenght);
                 
         if((tchar > 96 && tchar < 123) || (tchar > 223 && tchar < 256))
                  s = StringSetChar(s, lenght, tchar - 32);
          else 
              if(tchar > -33 && tchar < 0)
                  s = StringSetChar(s, lenght, tchar + 224);
         lenght--;
   }
  
   
   return(s);
}

string MakeUniqueName(string first, string rest)
{
   string result = first + (MathRand()%1001)+rest;

   while (WindowFind(result)> 0)
          result = first + (MathRand()%1001)+rest;
   return(result);
}
bool IsMini()
{
   if (StringFind(Symbol(),"m") > -1)
         return(true);
   else  return(false);    
}
void DoWork( string myPair, int myPeriod , int p )  
{
while(true)
{
if(Period_==-100 ) {
               cVal = 0;
               break ; }
                         
if(Period_!=-100 && iParm4==-100 && iParm5==-100 && iParm6==-100 && iParm7==-100) {
               cVal = iCustom(myPair,myPeriod,Ind_Name_1,Period_,iMode,p);          
               break ; }
               
if(Period_!=-100 && iParm4!=-100 && iParm5==-100 && iParm6==-100 && iParm7==-100) {
               cVal = iCustom(myPair,myPeriod,Ind_Name_1,Period_,iParm4,iMode,p);         
               break ; }
            
if(Period_!=-100 && iParm4!=-100 && iParm5!=-100 && iParm6==-100 && iParm7==-100) {
               cVal = iCustom(myPair,myPeriod,Ind_Name_1,Period_,iParm4,iParm5,iMode,p);
               break ; }                        
            
            
if(Period_!=-100 && iParm4!=-100 && iParm5!=-100 && iParm6!=-100 && iParm7==-100) {
               cVal = iCustom(myPair,myPeriod,Ind_Name_1,Period_,iParm4,iParm5,iParm6,iMode,p);
               break ; }                          
            
            
if(Period_!=-100 && iParm4!=-100 && iParm5!=-100 && iParm6!=-100 && iParm7!=-100) {
               cVal = iCustom(myPair,myPeriod,Ind_Name_1,Period_,iParm4,iParm5,iParm6,iParm7,iMode,p);
               break ; }
                       
break ;  }
                                        
}