Real_Time_MultiIndicator_v1

Download script
Author: Copyright � 2007, Pavel Chigirev
Real_Time_MultiIndicator_v1

This script is designed to function as a real-time multi-indicator dashboard on the MetaTrader 4 platform. Instead of requiring you to look at four different separate windows or charts, it consolidates the data from multiple technical analysis tools into a single, organized visual table.

Core Functionality

The tool scans the market using four primary technical indicators to determine potential "Buy" or "Sell" signals. These indicators include:

  • Parabolic SAR: Used to identify trend reversals.
  • MACD (Moving Average Convergence Divergence): Used to measure momentum and trend strength.
  • Crossing Moving Averages (MA): Used to detect when fast-moving price averages cross over slow-moving ones.
  • ADX (Average Directional Index): Used to determine the strength of a current trend.

How the Logic Works

The script operates by processing data across different timeframes simultaneously. Here is the step-by-step logic:

  1. Multi-Timeframe Analysis: The system automatically checks market conditions for four specific time intervals (M15, M30, H1, and H4).
  2. Signal Scanning: For every timeframe, the script looks back through historical price bars to find the most recent point where a "crossover" or "reversal" occurred.
    • If it detects a bullish condition (e.g., a fast average crossing above a slow one), it identifies this as a Buy signal and notes how many bars ago it happened.
    • If it detects a bearish condition, it identifies this as a Sell signal.
  3. Dynamic Data Retrieval: If the market data is currently loading or unavailable for a specific timeframe, the script is programmed to display "Waiting data" rather than providing incorrect information.

Visual Presentation

Rather than simply listing numbers, the script creates a dynamic visual dashboard:

  • The Grid Layout: It draws a structured table on your chart using rectangles and text objects. This allows you to see a snapshot of all timeframes in one glance.
  • Real-Time Updates: The script constantly refreshes the "Buy" and "Sell" labels. As new candles form, the dashboard updates the signal status and the specific bar count where the trend changed.
  • Configuration: Users can customize the sensitivity of each indicator (such as the speed of Moving Averages or the period of the ADX) through the input settings to tailor the dashboard to their specific trading style.

In short, this tool acts as a "Command Center," summarizing complex technical data from multiple timeframes into a readable table of Buy and Sell signals, helping traders make faster, more informed decisions without switching between different charts.

Price Data Components
Series array that contains close prices for each bar
Indicators Used
Parabolic Stop and Reverse systemMACD HistogramMoving average indicatorMovement directional index
7 Views
0 Downloads
0 Favorites
Real_Time_MultiIndicator_v1
//+------------------------------------------------------------------+
//|                                  Real_Time_MultiIndicator_v1.mq4 |
//|                                 Copyright © 2007, Pavel Chigirev |
//+------------------------------------------------------------------+
#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;
//----Ïàðàìåòðû èñïîëüçóåìûõ èíäèêàòîðîâ
extern string p1 = "Ïàðàìåòðû SAR";
extern double SAR_Step = 0.01;
extern double SAR_Max = 0.1;
extern string p2 = "Ïàðàìåòðû MACD";
extern int Fast_EMA = 12;
extern int Slow_EMA = 26;
extern int MACD_SMA = 9;
extern string p3 = "Ïàðàìåòðû Moving Average";
extern int Fast_MA = 5;
extern int Slow_MA = 10;
extern string p4 = "Ïàðàìåòðû ADX";
extern int ADX_Period = 14;
//extern string p5 = "Ïàðàìåòðû íäèêàòîðà 1";
//extern string p6 = "Ïàðàìåòðû èíäèêàòîðà 2";
//extern string p7 = "Ïàðàìåòðû èíäèêàòîðà 3";
//----Íàñòðîéêè èíäèêàòîðà
int t1, t2, t11, t12, t13, t14, t15, a, b;
int textT[6], textC[8], tt[10];
int per[] = {15, 30, 60, 240};
string nameS[] = {"INDICATOR", "M15", "M30", "H1", "H4"};
string name[] = {"Parabolic SAR", "MACD", "Ñrossing MA", "ADX", "", 
                 "", ""};
//+------------------------------------------------------------------+
//| 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(1-é ïàðàìåòð èíäèêàòîðà 1, 0) + 
//             ", " + DoubleToStr(2-é ïàðàìåòð èíäèêàòîðà 1, 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) + ")");
     }
  }
/*//+------------------------------------------------------------------+
//| Ôóíêöèÿ 1                                                        |
//+------------------------------------------------------------------+
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) + ")");
     }
  }*/
/*//+------------------------------------------------------------------+
//| Ôóíêöèÿ 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], 13, 
                     "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]), 13, 
                     "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]), 13, 
                     "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]), 13, 
                     "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]), 13, 
	                    "Tahoma", TxtColor);
	    }
/*// Ïÿòàÿ ñòðîêà   
   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), Ôóíêöèÿ(per[i-1]), 13, 
	                    "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], 13, "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