0_-_Chart_Symbol

Download script
0_-_Chart_Symbol

This script is a visual enhancement tool designed for the MetaTrader 4 platform. Its primary purpose is to provide traders with a clear, instant reference of which currency pair or asset they are currently viewing, along with the specific timeframe of the chart.

Core Functionality

The logic of the script follows a simple three-step process to improve your dashboard visibility:

1. Identifying the Timeframe The tool automatically detects the "timeframe" you have selected on your chart (for example, whether you are looking at 5-minute, hourly, or daily candles). It translates these internal system values into human-readable labels like "M1", "H1", "D1", etc.

2. Dynamic Label Creation Once the script knows which asset and timeframe you are using, it generates a text label on your screen. This label combines two pieces of information:

  • The name of the current symbol (e.g., EURUSD).
  • The identified timeframe code.

3. Customizable Visual Display The script gives you full control over how this information appears on your workspace. You can adjust the following settings without needing to understand the underlying code:

  • Color: Change the text color to suit your theme (default is Magenta).
  • Size & Style: Adjust the font size and choose whether the text should be bold or regular.
  • Positioning: Move the label to different corners of your screen and set the specific distance from the edges so it doesn't obstruct your price candles or other indicators.

Summary for the User

Essentially, this is a "Status Label" tool. Instead of having to look at the top header of the platform to confirm which chart you are on, this script places that information directly onto your chart area in a clean, customizable format that stays visible as you navigate between different trading pairs and timeframes.

4 Views
0 Downloads
0 Favorites
0_-_Chart_Symbol
//+------------------------------------------------------------------+
//|  0 - Chart Symbol.mq4 | File45 (Phylo)
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property indicator_chart_window

extern color Font_Color = Magenta;
extern int Font_Size_ = 12;
extern bool Font_Bold = true;
extern int Label_Corner = 1;
extern int Left_Right = 20;
extern int Up_Down = 75;

string TM, TZF;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   switch(Period())
   {    
      case 1:     TM = "M1";  break;
      case 2:     TM = "M2";  break;
      case 3:     TM = "M3";  break;
      case 4:     TM = "M4";  break;
      case 5:     TM = "M5";  break;
      case 6:     TM = "M6";  break;
      case 7:     TM = "M7";  break;
      case 8:     TM = "M8";  break;
      case 9:     TM = "M9";  break;
      case 10:    TM = "M10"; break;
      case 11:    TM = "M11"; break;
      case 12:    TM = "M12"; break;
      case 13:    TM = "M13"; break;
      case 14:    TM = "M14"; break;
      case 15:    TM = "M15"; break;
      case 20:    TM = "M20"; break;
      case 25:    TM = "M25"; break;
      case 30:    TM = "M30"; break;
      case 40:    TM = "M40"; break;
      case 45:    TM = "M45"; break;
      case 50:    TM = "M50"; break;
      case 60:    TM = "H1";  break;
      case 120:   TM = "H2";  break;
      case 180:   TM = "H3";  break;
      case 240:   TM = "H4";  break;
      case 300:   TM = "H5";  break;
      case 360:   TM = "H6";  break;
      case 420:   TM = "H7";  break;
      case 480:   TM = "H8";  break;
      case 540:   TM = "H9";  break;
      case 600:   TM = "H10"; break;
      case 660:   TM = "H11"; break;
      case 720:   TM = "H12"; break;
      case 1440:  TM = "D1";  break;
      case 10080: TM = "W1";  break;
      case 43200: TM = "M4";  break;
   }     
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{
   ObjectDelete("SYB");
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   if(Font_Bold == true)
   {
      TZF = "Arial Bold";
   }
   else
   {
      TZF = "Arail";
   }      
   
   ObjectCreate("SYB",OBJ_LABEL,0,0,0);
   ObjectSetText("SYB",Symbol()+ " " + TM,Font_Size_,TZF,Font_Color);
   ObjectSet("SYB",OBJPROP_CORNER, Label_Corner);
   ObjectSet("SYB",OBJPROP_XDISTANCE, Left_Right);
   ObjectSet("SYB",OBJPROP_YDISTANCE, Up_Down);
   
   return(0);
}

Comments