Get_Current_Symbol

Download script
Author: Copyright 2021, MetaQuotes Ltd.

This script is designed to automatically identify and display the specific financial instrument (such as a currency pair, commodity, or stock) that you are currently viewing on your trading platform.

How it Works

The primary purpose of this tool is to provide real-time awareness of the active market context. In a professional trading environment where multiple charts or symbols may be open simultaneously, it is essential to verify exactly which asset the system is interacting with at any given moment.

Core Functionality

  • Active Monitoring: The script operates on a "tick-by-tick" basis. This means every time the market price updates (a "tick"), the script triggers its internal logic to check the current environment.
  • Dynamic Identification: Instead of being hardcoded to look for one specific asset, it dynamically retrieves the name of whatever symbol is currently active on the chart where the script is placed.
  • Logging and Reporting: Once the script identifies the symbol, it automatically records that information into the platform's diagnostic log. This allows traders to keep a running record or verify that their automated processes are executing on the correct asset without manual intervention.

Summary for the User

Think of this script as an automated "Identity Check." It ensures that the system is constantly aware of its surroundings by broadcasting the name of the current trading pair to your logs every time the market moves, providing a clear audit trail of which asset is being monitored.

13 Views
0 Downloads
0 Favorites
Get_Current_Symbol
//+------------------------------------------------------------------+
//|                                           Get_Current_Symbol.mq5 |
//|                                  Copyright 2021, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"

#include <CurSymbol.mqh>

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   Print(Get_CurSymb());
  }
//+------------------------------------------------------------------+

Comments