#MultiIndicator

Download script
Author: Copyright � 2007, Pavel Chigirev
#MultiIndicator

This script is designed to function as a multi-timeframe dashboard for MetaTrader 4. Instead of requiring a trader to switch between different charts to see what is happening at various time intervals, it aggregates and displays several technical indicators in a single visual table on the screen.

Core Functionality

The script monitors five specific timeframes simultaneously: M15, M30, H1, H4, and Daily. For each of these timeframes, it calculates the data for five different technical analysis tools to provide a comprehensive overview of market momentum, trends, and volatility.

The Indicators Monitored

The dashboard tracks the following five indicators across all specified timeframes:

  • Parabolic SAR: Used to identify trend reversals and potential entry/exit points by looking at the "dots" relative to price action.
  • MACD (Moving Average Convergence Divergence): A momentum indicator that shows the relationship between two moving averages to identify trend strength.
  • SMA Cross: Monitors the interaction between a fast and a slow Simple Moving Average to detect when price trends are shifting direction.
  • ADX (Average Directional Index): Measures the strength of a trend regardless of its direction.
  • CCI (Commodity Channel Index): Identifies whether an asset is overbought or oversold by measuring price deviation from its average.

Data Processing Logic

For every indicator on every timeframe, the script performs a "look-back" logic:

  1. It checks the current state of the indicator.
  2. If the current state suggests a specific direction (like a Buy or Sell signal), it scans backward through previous candles to find the exact point where that condition was first met.
  3. It then reports this information as a text string (e.g., "Buy" or "Sell") along with the specific candle number where the signal originated.

Visual Presentation

The script is designed to be user-friendly and visually organized:

  • Automatic Table Construction: It creates a custom grid on your chart window, including borders and headers for each timeframe and indicator type.
  • Real-Time Updates: The text within the table updates automatically as new price data arrives.
  • Dynamic Labeling: The dashboard displays the specific parameters (settings) used for each indicator directly in the labels, ensuring the user knows exactly what calculations are being shown.

In summary, this tool acts as a "control center" that synthesizes complex technical data from multiple timeframes into one consolidated visual table, allowing for faster decision-making without cluttering the main price chart with multiple separate windows.

Price Data Components
Series array that contains close prices for each bar
Indicators Used
Parabolic Stop and Reverse systemMACD HistogramMoving average indicatorMovement directional indexCommodity channel index
15 Views
0 Downloads
0 Favorites
#MultiIndicator
//+------------------------------------------------------------------+
//|                                  Real_Time_MultiIndicator_v1.mq4 |
//|                                 Copyright © 2007, Pavel Chigirev
//| http://articles.mql4.com/384
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Pavel Chigirev"
#property link      ""
//----
#property indicator_separate_window
#property indicator_maximum 10.0
#property indicator_minimum 0.0
extern color TColor = SteelBlue;
extern color TxtColor = Red;

//----The parameters of the indicators
extern string p1 = "Parabolic SAR Parameter";
extern double SAR_Step = 0.02;
extern double SAR_Max = 0.2;
extern string p2 = "MACD Parameter";
extern int Fast_EMA = 12;
extern int Slow_EMA = 26;
extern int MACD_SMA = 9;
extern string p3 = "Moving Average Parameter";
extern int Fast_MA = 5;
extern int Slow_MA = 10;
extern string p4 = "ADX Parameter";
extern int ADX_Period = 14;
extern string p5 = "CCI Parameter";
extern int Period_CCI = 14;
//extern string p6 = "The parameters of the indicator 6";
//extern string p7 = "The parameters of the indicator 7";

//----Íàñòðîéêè èíäèêàòîðà
int t1, t2, t11, t12, t13, t14, t15, a, b;
int textT[6], textC[8], tt[10];
int per[] = {15, 30, 60, 240};    // {1=M1, 5=M5, 15=M15, 30=M30, 60=H1, 240=H4, 1440=D1, 10080=W1, 43200=MN1}
string nameS[] = {"INDICATOR", "M15", "M30", "H1", "H4"};
string name[] = {"Parabolic SAR", "MACD", "SMA Cross", "ADX", "CCI", 
                 "", ""};
//+------------------------------------------------------------------+
//| Initialization                                                   |
//+------------------------------------------------------------------+
int init()
  {
   string sn = "Real_Time_MultiIndicator_v1";
   IndicatorShortName(sn);
   SetIndexLabel(0, sn);
   name[0] = name[0] + "(" + DoubleToStr(SAR_Step, 2) + ", " + 
             DoubleToStr(SAR_Max, 2) + ")";
   name[1] = name[1] + "(" + DoubleToStr(Fast_EMA, 0) + ", " + 
             DoubleToStr(Slow_EMA, 0) + ", " + 
             DoubleToStr(MACD_SMA, 0) + ")";
   name[2] = name[2] + "(" + DoubleToStr(Fast_MA, 0) + ", " + 
             DoubleToStr(Slow_MA,0)+")";
   name[3] = name[3] + "(" + DoubleToStr(ADX_Period, 0) + ")";
   name[4] = name[4] + "(" + DoubleToStr(Period_CCI, 0) + ")";
//   name[5] = name[5] + "(" + DoubleToStr(1-é ïàðàìåòð èíäèêàòîðà 2, 0) + 
//             ", " + DoubleToStr(2-é ïàðàìåòð èíäèêàòîðà 2, 0) + ")";
//   name[6] = name[6] + "(" + DoubleToStr(1-é ïàðàìåòð èíäèêàòîðà 3, 0) + 
//             ", " + DoubleToStr(2-é ïàðàìåòð èíäèêàòîðà 3, 0) + ")";
   return(0);
  }
//+------------------------------------------------------------------+
//| Check errors                                                  |
//+------------------------------------------------------------------+
int Error(int p, int a)
  {
    double s = iClose(NULL, p, a);
    if(s == 0) 
        return(1);
  }
//+------------------------------------------------------------------+
//| Parabolic SAR                                                    |
//+------------------------------------------------------------------+
string SAR(int p)
  {
   int ii = 1;
   if(iSAR(NULL, p, SAR_Step, SAR_Max, 0) > iClose(NULL, p, ii)) 
     {
       while(iSAR(NULL, p, SAR_Step, SAR_Max, ii) > iClose(NULL, p, ii))
           ii++;
       if(Error(p, ii + 1) == 1) 
           return("Waiting data");
       return("Sell(" + DoubleToStr(ii, 0) + ")");
     }
   else 
     {
       while(iSAR(NULL, p, SAR_Step, SAR_Max, ii) < iClose(NULL, p, ii))
           ii++;
       if(Error(p, ii + 1) == 1) 
           return("Waiting data");
       return("Buy(" + DoubleToStr(ii, 0) + ")");
     } 
  }
//+------------------------------------------------------------------+
//| MACD                                                             |
//+------------------------------------------------------------------+
string MACD(int p)
  {
   int ii = 1;
   if(iMACD(NULL, p, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_MEDIAN, 0, 0) < 
      iMACD(NULL, p, Fast_EMA, Slow_EMA, MACD_SMA, PRICE_MEDIAN, 1, 0))
     {
       while(iMACD(NULL, p, Fast_EMA, Slow_EMA, MACD_SMA, 
             PRICE_MEDIAN, 0, ii) < 
             iMACD(NULL, p, Fast_EMA, Slow_EMA, MACD_SMA, 
             PRICE_MEDIAN, 1, ii))
           ii++;
       if(Error(p, ii + 1) == 1) 
           return("Waiting data");
       return("Sell(" + DoubleToStr(ii, 0) + ")");
     }
   else 
     {
       while(iMACD(NULL, p, Fast_EMA, Slow_EMA, MACD_SMA, 
             PRICE_MEDIAN, 0, ii) > 
             iMACD(NULL, p, Fast_EMA, Slow_EMA, MACD_SMA, 
             PRICE_MEDIAN, 1, ii))
           ii++;
       if(Error(p, ii + 1) == 1) 
           return("Waiting data");
       return("Buy(" + DoubleToStr(ii, 0) + ")");
     }
  }
//+------------------------------------------------------------------+
//| Crossing MA                                                      |
//+------------------------------------------------------------------+
string CMA(int p)
  {
   int ii = 1;
   if(iMA(NULL, p, Fast_MA, 0, MODE_SMA, PRICE_MEDIAN, 0) < 
      iMA(NULL, p, Slow_MA, 0, MODE_SMA, PRICE_MEDIAN, 0))
     {
       while(iMA(NULL, p, Fast_MA, 0, MODE_SMA, PRICE_MEDIAN, ii) < 
             iMA(NULL, p, Slow_MA, 0, MODE_SMA, PRICE_MEDIAN, ii))
           ii++;
       if(Error(p, ii + 1) == 1) 
           return("Waiting data");
       return("Sell(" + DoubleToStr(ii, 0) + ")");
     }
   else
     {
       while(iMA(NULL, p, Fast_MA, 0, MODE_SMA, PRICE_MEDIAN, ii) > 
             iMA(NULL, p, Slow_MA, 0, MODE_SMA, PRICE_MEDIAN, ii))
           ii++;
       if(Error(p, ii + 1) == 1) 
           return("Waiting data");
       return("Buy(" + DoubleToStr(ii, 0) + ")");
     }
  }
//+------------------------------------------------------------------+
//| ADX                                                              |
//+------------------------------------------------------------------+
string ADX(int p)
  {
   int ii = 1;
   if(iADX(NULL, p, ADX_Period, PRICE_MEDIAN, 1, 0) < 
      iADX(NULL, p, ADX_Period, PRICE_MEDIAN, 2, 0))
     {
       while(iADX(NULL, p, ADX_Period, PRICE_MEDIAN, 1, ii) < 
             iADX(NULL, p, ADX_Period, PRICE_MEDIAN, 2, ii))
           ii++;
       if(Error(p, ii + 1) == 1) 
           return("Waiting data");
       return("Sell(" + DoubleToStr(ii, 0) + ")");
     }
   else
     {
       while(iADX(NULL, p, ADX_Period, PRICE_MEDIAN, 1, ii) > 
             iADX(NULL, p, ADX_Period, PRICE_MEDIAN, 2, ii))
           ii++;
       if(Error(p, ii + 1) == 1) 
           return("Waiting data");
       return("Buy(" + DoubleToStr(ii, 0) + ")");
     }
  }
//+------------------------------------------------------------------+
//| CCI                                                       |
//+------------------------------------------------------------------+
string CCI(int p)
  {
    int ii = 1;
    if(iCCI(NULL, p, Period_CCI, PRICE_MEDIAN, 0) < 0)
     {
       while(iCCI(NULL, p, Period_CCI, PRICE_MEDIAN, ii) < 0)       
ii++;
      if(Error(p, ii + 1) == 1) 
          return("Waiting data");
      return("Sell(" + DoubleToStr(ii, 0) + ")");
    }
  else
    {
      while(iCCI(NULL, p, Period_CCI, PRICE_MEDIAN, ii) > 0)
          ii++;
      if(Error(p, ii + 1) == 1) 
          return("Waiting data");
      return("Buy(" + DoubleToStr(ii, 0) + ")");
    }
  }
/*//+------------------------------------------------------------------+
//| Ôóíêöèÿ 2                                                        |
//+------------------------------------------------------------------+
string Ôóíêöèÿ(int p)
  {
   int ii = 1;
   if(Óñëîâèå äëÿ èíäèêàòîðà - true - sell, false - buy)
     {
       while(Óñëîâèå äëÿ sell)
           ii++;
       if(Error(p, ii + 1) == 1) 
           return("Waiting data");
       return("Sell(" + DoubleToStr(ii, 0) + ")");
     }
   else
     {
       while(Óñëîâèå äëÿ buy)
           ii++;
       if(Error(p, ii + 1) == 1) 
           return("Waiting dataY");
       return("Buy(" + DoubleToStr(ii, 0) + ")");
     }
  }*/
/*//+------------------------------------------------------------------+
//| Ôóíêöèÿ 3                                                        |
//+------------------------------------------------------------------+
string Ôóíêöèÿ(int p)
  {
   int ii = 1;
   if(Óñëîâèå äëÿ èíäèêàòîðà - true - sell, false - buy)
     {
       while(Óñëîâèå äëÿ sell)
           ii++;
       if(Error(p, ii + 1) == 1) 
           return("Waiting data");
       return("Sell(" + DoubleToStr(ii, 0) + ")");
     }
   else
     {
       while(Óñëîâèå äëÿ buy)
           ii++;
       if(Error(p, ii + 1) == 1) 
           return("Waiting data");
       return("Buy(" + DoubleToStr(ii, 0) + ")");
     }
  }*/
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
// Âû÷èñëåíèå êîîðäèíàò äëÿ ïîñòðîåíèÿ òàáëèöû è íàïèñàíèÿ òåêñòà
   a = WindowBarsPerChart(); 
   b = a - (0.3*a);
   t1 = Time[b];
   t2 = Time[0];
   for(int i = 1; i <= 5; i++)
     {
       if(i == 1)
         {
           b = a - (0.41*a);
           textT[i] = Time[b];
         }
       else
         {
           b = a - ((0.34 + (i*0.12))*a);
           textT[i] = Time[b];
         }
     }
   for(i = 0; i <= 7; i++)
       textC[i] = 9.5 - i;
   for(i = 1; i <= 4; i++)
     {
       if(i == 1)
         {
           b = a - (0.52*a);
           tt[i] = Time[b];
         }
       else
         {
           b = a - ((0.52 + (0.12*(i - 1)))*a);
           tt[i] = Time[b];
         }
    }
//------------ÇÀÏÎËÍÅÍÈÅ ÒÀÁËÈÖÛ
// Ïåðâûé ñòîëáåö
   for(i = 1; i <= 7; i++)
     {
       ObjectDelete("1" + DoubleToStr(i, 0));
       ObjectCreate("1" + DoubleToStr(i, 0), OBJ_TEXT, 
                    WindowFind("Real_Time_MultiIndicator_v1"), 
                    textT[1], textC[i]);
       ObjectSetText("1" + DoubleToStr(i, 0), name[i-1], 8, 
                     "Tahoma", TxtColor);
     }
//------------ÇÀÏÎËÍÅÍÈÅ ÑÒÐÎÊ Ñ ÑÈÃÍÀËÀÌÈ ÈÍÄÈÊÀÒÎÐÀ
// Ïåðâàÿ ñòðîêà   
   for(i = 1; i <= 4; i++)
     {
       ObjectDelete("2" + DoubleToStr(i, 0));
       ObjectCreate("2" + DoubleToStr(i, 0), OBJ_TEXT, 
                    WindowFind("Real_Time_MultiIndicator_v1"), 
                    textT[i+1], textC[1]);
       ObjectSetText("2" + DoubleToStr(i, 0), SAR(per[i-1]), 8, 
                     "Tahoma", TxtColor);
     }
// Âòîðàÿ ñòðîêà   
   for(i = 1; i <= 4; i++)
     {
       ObjectDelete("3" + DoubleToStr(i, 0));
       ObjectCreate("3" + DoubleToStr(i, 0), OBJ_TEXT, 
                    WindowFind("Real_Time_MultiIndicator_v1"), 
                    textT[i+1], textC[2]);
       ObjectSetText("3" + DoubleToStr(i, 0), MACD(per[i-1]), 8, 
                     "Tahoma", TxtColor);
     }
// Òðåòüÿ ñòðîêà   
   for(i = 1; i <= 4; i++)
     {
       ObjectDelete("4" + DoubleToStr(i, 0));
       ObjectCreate("4" + DoubleToStr(i, 0), OBJ_TEXT, 
                    WindowFind("Real_Time_MultiIndicator_v1"), 
                    textT[i+1], textC[3]);
       ObjectSetText("4" + DoubleToStr(i, 0), CMA(per[i-1]), 8, 
                     "Tahoma", TxtColor);
     }
// ×åòâåðòàÿ ñòðîêà   
   for (i=1;i<=4;i++)
     {
       ObjectDelete("5" + DoubleToStr(i, 0));
	      ObjectCreate("5" + DoubleToStr(i, 0), OBJ_TEXT, 
	                   WindowFind("Real_Time_MultiIndicator_v1"), 
	                   textT[i+1], textC[4]);
	      ObjectSetText("5" + DoubleToStr(i, 0), ADX(per[i-1]), 8, 
	                    "Tahoma", TxtColor);
	    }
//----------Fifth line   
 for (i=1;i<=4;i++)
   {
     ObjectDelete("6" + DoubleToStr(i, 0));
     ObjectCreate("6" + DoubleToStr(i, 0), OBJ_TEXT,
                  WindowFind("Real_Time_MultiIndicator_v1"),
                  textT[i+1], textC[5]);
     ObjectSetText("6" + DoubleToStr(i, 0), CCI(per[i-1]), 8, 
                   "Tahoma", TxtColor);
   }
/*// Øåñòàÿ ñòðîêà   
   for(i = 1; i <= 4; i++)
     {
       ObjectDelete("7" + DoubleToStr(i, 0));
	      ObjectCreate("7" + DoubleToStr(i, 0), OBJ_TEXT, 
	                   WindowFind("Real_Time_MultiIndicator_v1"), 
	                   textT[i+1], textC[6]);
	      ObjectSetText("7" + DoubleToStr(i, 0), Ôóíêöèÿ(per[i-1]), 13, 
	                    "Tahoma", TxtColor);
	    }*/
/*// Ñåäüìàÿ ñòðîêà   
  for (i=1;i<=4;i++)
    {
      ObjectDelete("8" + DoubleToStr(i, 0));
	     ObjectCreate("8" + DoubleToStr(i, 0), OBJ_TEXT,
	                  WindowFind("Real_Time_MultiIndicator_v1"), 
	                  textT[i+1], textC[7]);
	     ObjectSetText("8" + DoubleToStr(i, 0), Ôóíêöèÿ(per[i-1]), 13, 
	                   "Tahoma", TxtColor);
	   }*/
//------------ÑÎÇÄÀÍÈÅ ÒÀÁËÈÖÛ
// Çàãîëîâêè ñòîëáöîâ
   for(i = 1; i <= 5; i++)
     {   	  
	      ObjectDelete(DoubleToStr(i, 0));
	      ObjectCreate(DoubleToStr(i, 0), OBJ_TEXT, 
	                   WindowFind("Real_Time_MultiIndicator_v1"), 
	                   textT[i], textC[0]);
	      ObjectSetText(DoubleToStr(i, 0), nameS[i-1], 8, "Tahoma", 
	                    TxtColor);
	    }
// Ãîðèçîíòàëüíàÿ ðàçìåòêà òàáëèöû
   for(i = 1; i <= 7; i++)	
	    {
       ObjectDelete("Tb" + DoubleToStr(i, 0));
       ObjectCreate("Tb" + DoubleToStr(i, 0), OBJ_RECTANGLE, 
                    WindowFind("Real_Time_MultiIndicator_v1"), t1, 
                    i, t2, 9.0);
       ObjectSet("Tb" + DoubleToStr(i, 0), OBJPROP_COLOR, TColor);
       ObjectSet("Tb" + DoubleToStr(i, 0), OBJPROP_BACK, false);
     }
// Ñòðîêà çàãîëîâêîâ
   ObjectDelete("Tbl8");
   ObjectCreate("Tbl8", OBJ_RECTANGLE, 
                WindowFind("Real_Time_MultiIndicator_v1"), 
                t1, 8.0, t2, 9.0);
   ObjectSet("Tbl8", OBJPROP_COLOR, TColor);
   ObjectSet("Tbl8", OBJPROP_BACK, true);
// Âåðòèêàëüíàÿ ðàçìåòêà òàáëèöû  
   for(i = 1; i <= 4; i++)
     {
       ObjectDelete("Tb2" + DoubleToStr(i, 0));
       ObjectCreate("Tb2" + DoubleToStr(i, 0), OBJ_RECTANGLE, 
                    WindowFind("Real_Time_MultiIndicator_v1"), t1, 
                    1.0, tt[i], 9.0);
       ObjectSet("Tb2" + DoubleToStr(i, 0), OBJPROP_COLOR, TColor);
       ObjectSet("Tb2" + DoubleToStr(i, 0), OBJPROP_BACK, false);
     }
//----                    
   return(0);
  }
//+------------------------------------------------------------------+

Comments