_TRO_Multi_Meter_MACD

_TRO_Multi_Meter_MACD

This script is a multi-timeframe visual dashboard designed for the MetaTrader platform. Its primary purpose is to provide traders with a high-level overview of the Moving Average Convergence Divergence (MACD) indicator across multiple different timeframes simultaneously, all displayed on a single chart window.

Core Functionality

Instead of requiring a trader to switch between various tabs (such as 1-minute, 5-minute, or Daily charts) to check market momentum, this script scans all those timeframes in the background. It then gathers that data and displays it as a concise, color-coded dashboard in a corner of your main chart.

How the Logic Works

  • Multi-Timeframe Analysis: The script specifically tracks seven distinct timeframes: M1 (1 minute), M5, M15, M30, H1 (1 hour), H4 (4 hours), and D1 (Daily).
  • Trend Detection: For each of these timeframes, the script calculates two specific components of the MACD indicator: the "Main" line and the "Signal" line. It compares these two values to determine the current direction of price momentum.
  • Dynamic Visual Feedback: The script translates these mathematical calculations into visual cues:
    • It determines if the current momentum is positive or negative relative to the zero line.
    • It checks whether the Main line is currently above or below the Signal line.
    • Based on these conditions, it assigns a specific color to each timeframe's status (e.g., using variations of Lime, Tomato, Green, and Red).
  • Dashboard Rendering: It automatically creates a series of text labels on your chart. These labels act as a "Multi-Meter," showing the status for every timeframe in a horizontal row. This allows you to see at a glance if the market trend is aligning across short-term and long-term periods.

User Experience Features

  • Customizable Placement: The script includes settings that allow users to adjust the position of the dashboard on the chart (specifically the corner, vertical shift, and horizontal padding) to ensure it does not overlap with price candles or other indicators.
  • Automatic Updates: The script continuously refreshes the data in real-time as new price ticks arrive, ensuring the dashboard always reflects the most current market state.
  • Clean Cleanup: When the indicator is removed from the chart, the script includes a "deinitialization" routine that automatically wipes the labels and text from your screen, leaving the chart clean.
Indicators Used
MACD Histogram
12 Views
0 Downloads
0 Favorites
_TRO_Multi_Meter_MACD
//+------------------------------------------------------------------+ 
//|  _TRO_Multi_Meter_MACD                                           | 
//|                                                                  | 
//|   Copyright © 2007, Avery T. Horton, Jr. aka TheRumpledOne       |
//|                                                                  |
//|   PO BOX 43575, TUCSON, AZ 85733                                 |
//|                                                                  |
//|   GIFT AND DONATIONS ACCEPTED                                    | 
//|                                                                  |
//|   therumpldone@gmail.com                                         |  
//+------------------------------------------------------------------+ 

#property indicator_chart_window

extern bool Show_Heading = false;
 
extern string IndName = "MACD" ; // change

extern bool Corner_of_Chart_RIGHT_TOP = true;

extern int Shift_UP_DN =15; 
extern int Adjust_Side_to_side  = 20;

extern color BarLabel_color = LightBlue;
extern color CommentLabel_color = LightBlue;

//******************* 
// change inputs for your indicator 

string    MACD_Settings         = "=== MACD Settings ===";
extern int       MACDFast              =           12;  // MACD fast EMA period
extern int       MACDSlow              =           26;  // MACD slow EMA period
extern int       MACDSignal            =            9;  // MACD signal SMA period
extern color XUP_Above_0               = Lime ; 
extern color XDN_Above_0               = Tomato ; 
extern color XUP_Below_0               = Green ; 
extern color XDN_Below_0               = Red ; 

//*******************



string Obj0001,Obj0002,Obj0003,Obj0004,Obj0005,Obj0006,Obj0007,Obj0008,Obj0009;  

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 


//----
   return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {    
   //***********************************************************************************************************************

string LabelTime="";

if (LabelTime=="") {LabelTime=TimeToStr(TimeLocal(),TIME_SECONDS); }

   int    counted_bars=IndicatorCounted();
   
if ( Show_Heading) {         
    if (Corner_of_Chart_RIGHT_TOP == true)
    {  
    
   Obj0001 = "Numbers" + LabelTime ; 
           ObjectCreate(Obj0001, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0001, "    M1   M5  M15  M30   H1    H4   D1", 7, "Tahoma Narrow", BarLabel_color);
   ObjectSet(Obj0001, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0001, OBJPROP_XDISTANCE, 17+Adjust_Side_to_side);
   ObjectSet(Obj0001, OBJPROP_YDISTANCE, 28+Shift_UP_DN); 
   }
    if (Corner_of_Chart_RIGHT_TOP == false)
   { 
           ObjectCreate(Obj0001, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0001, "   M1     M5   M15   M30   H1    H4    D1", 7, "Tahoma Narrow", BarLabel_color);
   ObjectSet(Obj0001, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0001, OBJPROP_XDISTANCE, 17+Adjust_Side_to_side);
   ObjectSet(Obj0001, OBJPROP_YDISTANCE, 24+Shift_UP_DN); 
    } 
} // Show_Heading

 //*******************   change for  your indicator ********************
   //MACD Signals

   

    
    string M1_MACD= "",M5_MACD= "", M15_MACD= "", M30_MACD= "", H1_MACD= "", H4_MACD= "", D1_MACD= "",PRC1;
    color  color_MACDm1,color_MACDm5,color_MACDm15,color_MACDm30,color_MACDH1,color_MACDH4,color_MACDD1;     
         
   
   double MACD_m_1=iMACD(NULL,PERIOD_M1,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_MAIN,0);
   double MACD_s_1=iMACD(NULL,PERIOD_M1,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_SIGNAL,0);
   
   if( MACD_m_1 > 0 ) {   
      if ((MACD_m_1 > MACD_s_1)) { M1_MACD= "-";color_MACDm1 = XUP_Above_0 ; }
      if ((MACD_m_1 < MACD_s_1)) { M1_MACD= "-";color_MACDm1 = XDN_Above_0 ; } }
   else {
      if ((MACD_m_1 > MACD_s_1)) { M1_MACD= "-";color_MACDm1 = XUP_Below_0 ; }
      if ((MACD_m_1 < MACD_s_1)) { M1_MACD= "-";color_MACDm1 = XDN_Below_0 ; } }   
 
   double MACD_m_5=iMACD(NULL,PERIOD_M5,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_MAIN,0);
   double MACD_s_5=iMACD(NULL,PERIOD_M5,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_SIGNAL,0);
   
   if( MACD_m_5 > 0 ) {   
      if ((MACD_m_5 > MACD_s_5)) { M5_MACD= "-";color_MACDm5 = XUP_Above_0  ;}
      if ((MACD_m_5 < MACD_s_5)) { M5_MACD= "-";color_MACDm5 = XDN_Above_0 ; } }
   else {
      if ((MACD_m_5 > MACD_s_5)) { M5_MACD= "-";color_MACDm5 = XUP_Below_0 ; }
      if ((MACD_m_5 < MACD_s_5)) { M5_MACD= "-";color_MACDm5 = XDN_Below_0 ; } }   
    
   double MACD_m_15=iMACD(NULL,PERIOD_M15,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_MAIN,0);
   double MACD_s_15=iMACD(NULL,PERIOD_M15,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_SIGNAL,0);
   
   if( MACD_m_15 > 0 ) {   
      if ((MACD_m_15 > MACD_s_15)) { M15_MACD= "-";color_MACDm15 = XUP_Above_0 ; }
      if ((MACD_m_15 < MACD_s_15)) { M15_MACD= "-";color_MACDm15 = XDN_Above_0 ; } }
   else {
      if ((MACD_m_15 > MACD_s_15)) { M15_MACD= "-";color_MACDm15 = XUP_Below_0 ; }
      if ((MACD_m_15 < MACD_s_15)) { M15_MACD= "-";color_MACDm15 = XDN_Below_0 ; } }   
 
   double MACD_m_30=iMACD(NULL,PERIOD_M30,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_MAIN,0);
   double MACD_s_30=iMACD(NULL,PERIOD_M30,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_SIGNAL,0);
   
   if( MACD_m_30 > 0 ) {   
      if ((MACD_m_30 > MACD_s_30)) { M30_MACD= "-";color_MACDm30 = XUP_Above_0 ; }
      if ((MACD_m_30 < MACD_s_30)) { M30_MACD= "-";color_MACDm30 = XDN_Above_0 ; } }
   else {
      if ((MACD_m_30 > MACD_s_30)) { M30_MACD= "-";color_MACDm30 = XUP_Below_0 ; }
      if ((MACD_m_30 < MACD_s_30)) { M30_MACD= "-";color_MACDm30 = XDN_Below_0 ; } }   
 
 
   double MACD_m_H1=iMACD(NULL,PERIOD_H1,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_MAIN,0);
   double MACD_s_H1=iMACD(NULL,PERIOD_H1,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_SIGNAL,0);
   
   if( MACD_m_H1 > 0 ) {   
      if ((MACD_m_H1 > MACD_s_H1)) { H1_MACD= "-";color_MACDH1 = XUP_Above_0 ; }
      if ((MACD_m_H1 < MACD_s_H1)) { H1_MACD= "-";color_MACDH1 = XDN_Above_0 ; } }
   else {
      if ((MACD_m_H1 > MACD_s_H1)) { H1_MACD= "-";color_MACDH1 = XUP_Below_0 ;  }
      if ((MACD_m_H1 < MACD_s_H1)) { H1_MACD= "-";color_MACDH1 = XDN_Below_0 ; } }   
      
   double MACD_m_H4=iMACD(NULL,PERIOD_H4,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_MAIN,0);
   double MACD_s_H4=iMACD(NULL,PERIOD_H4,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_SIGNAL,0);
   
   if( MACD_m_H4 > 0 ) {   
      if ((MACD_m_H4 > MACD_s_H4)) { H4_MACD= "-";color_MACDH4 = XUP_Above_0 ; }
      if ((MACD_m_H4 < MACD_s_H4)) { H4_MACD= "-";color_MACDH4 = XDN_Above_0 ; } }
   else {
      if ((MACD_m_H4 > MACD_s_H4)) { H4_MACD= "-";color_MACDH4 = XUP_Below_0 ; }
      if ((MACD_m_H4 < MACD_s_H4)) { H4_MACD= "-";color_MACDH4 = XDN_Below_0 ; } }   
       
   double MACD_m_D1=iMACD(NULL,PERIOD_D1,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_MAIN,0);
   double MACD_s_D1=iMACD(NULL,PERIOD_D1,MACDFast,MACDSlow,MACDSignal,PRICE_CLOSE,MODE_SIGNAL,0);
   
   if( MACD_m_D1 > 0 ) {   
      if ((MACD_m_D1 > MACD_s_D1)) { D1_MACD= "-";color_MACDD1 = XUP_Above_0 ; }
      if ((MACD_m_D1 < MACD_s_D1)) { D1_MACD= "-";color_MACDD1 = XDN_Above_0 ; } }
   else {
      if ((MACD_m_D1 > MACD_s_D1)) { D1_MACD= "-";color_MACDD1 = XUP_Below_0 ; }
      if ((MACD_m_D1 < MACD_s_D1)) { D1_MACD= "-";color_MACDD1 = XDN_Below_0 ; } }   
 

      

    

   Obj0002 = "SignalMACDM1t" + LabelTime ; 
           
           ObjectCreate(Obj0002, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0002,IndName, 7, "Tahoma Narrow",  BarLabel_color);  
   ObjectSet(Obj0002, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0002, OBJPROP_XDISTANCE, 155+Adjust_Side_to_side);
   ObjectSet(Obj0002, OBJPROP_YDISTANCE, 50+Shift_UP_DN);  

   Obj0003 = "SignalMACDM1" + LabelTime ;        
           ObjectCreate(Obj0003, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0003, M1_MACD, 40, "Tahoma Narrow",  color_MACDm1);
   ObjectSet(Obj0003, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0003, OBJPROP_XDISTANCE, 130+Adjust_Side_to_side);
   ObjectSet(Obj0003, OBJPROP_YDISTANCE, 20+Shift_UP_DN); 

   Obj0004 = "SignalMACDM5" + LabelTime ;          
           ObjectCreate(Obj0004, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0004, M5_MACD, 40, "Tahoma Narrow",  color_MACDm5);
   ObjectSet(Obj0004, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0004, OBJPROP_XDISTANCE, 110+Adjust_Side_to_side);
   ObjectSet(Obj0004, OBJPROP_YDISTANCE, 20+Shift_UP_DN); 
      
   Obj0005 = "SignalMACDM15" + LabelTime ; 
   ObjectCreate(Obj0005, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0005, M15_MACD, 40, "Tahoma Narrow",  color_MACDm15);
   ObjectSet(Obj0005, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0005, OBJPROP_XDISTANCE, 90+Adjust_Side_to_side);
   ObjectSet(Obj0005, OBJPROP_YDISTANCE, 20+Shift_UP_DN); 
      
   Obj0006 = "SignalMACDM30" + LabelTime ; 
   ObjectCreate(Obj0006, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0006, M30_MACD, 40, "Tahoma Narrow",  color_MACDm30);
   ObjectSet(Obj0006, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0006, OBJPROP_XDISTANCE, 70+Adjust_Side_to_side);
   ObjectSet(Obj0006, OBJPROP_YDISTANCE, 20+Shift_UP_DN); 

   Obj0007 = "SignalMACDM60" + LabelTime ;      
           ObjectCreate(Obj0007, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0007, H1_MACD, 40, "Tahoma Narrow",  color_MACDH1);
   ObjectSet(Obj0007, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0007, OBJPROP_XDISTANCE, 50+Adjust_Side_to_side);
   ObjectSet(Obj0007, OBJPROP_YDISTANCE, 20+Shift_UP_DN); 

   Obj0008 = "SignalMACDM240" + LabelTime ;          
           ObjectCreate(Obj0008, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0008, H4_MACD, 40, "Tahoma Narrow",  color_MACDH4);
   ObjectSet(Obj0008, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0008, OBJPROP_XDISTANCE, 30+Adjust_Side_to_side);
   ObjectSet(Obj0008, OBJPROP_YDISTANCE, 20+Shift_UP_DN);

   Obj0009 = "SignalMACDM1440" + LabelTime ;    
           ObjectCreate(Obj0009, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(Obj0009, D1_MACD, 40, "Tahoma Narrow",  color_MACDD1);
   ObjectSet(Obj0009, OBJPROP_CORNER, Corner_of_Chart_RIGHT_TOP);
   ObjectSet(Obj0009, OBJPROP_XDISTANCE, 10+Adjust_Side_to_side);
   ObjectSet(Obj0009, OBJPROP_YDISTANCE, 20+Shift_UP_DN);
  
 //----
   return(0);
  }
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
ObjectsDeleteAll(0,OBJ_HLINE);
ObjectsDeleteAll(0,OBJ_TEXT);
ObjectsDeleteAll(0,OBJ_LABEL);
deleteObject(); 

//----
   return(0);
  }
  
void deleteObject()
  { 
ObjectDelete(Obj0001);  
ObjectDelete(Obj0002); 
ObjectDelete(Obj0003); 
ObjectDelete(Obj0004); 
ObjectDelete(Obj0005); 
ObjectDelete(Obj0006); 
ObjectDelete(Obj0007); 
ObjectDelete(Obj0008); 
ObjectDelete(Obj0009); 
 
  }

Comments