Files
mql5/Scripts/SymbolInfoStringChecker.mq5
T

83 lines
5.4 KiB
Plaintext
Raw Normal View History

2025-07-13 12:40:14 +02:00
//+------------------------------------------------------------------+
//| SymbolInfoStringChecker.mq5 |
//| Copyright 2025, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, MetaQuotes Ltd."
#property link "https://www.mql5.com"
#property version "1.00"
2025-07-13 14:03:44 +02:00
#include <Trade\SymbolInfo.mqh>
2025-07-13 12:40:14 +02:00
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
string symbol = _Symbol;
2025-07-13 14:03:44 +02:00
CSymbolInfo m_symbol_info;
2025-07-13 12:40:14 +02:00
2025-07-13 14:03:44 +02:00
if(!m_symbol_info.Name(symbol))
2025-07-13 12:40:14 +02:00
{
2025-07-13 14:03:44 +02:00
PrintFormat("Error: Failed to initialize CSymbolInfo for symbol '%s'. Error: %d", symbol, GetLastError());
2025-07-13 12:40:14 +02:00
return;
}
Print("--- Symbol Property Checker Started ---");
PrintFormat("Checking symbol: %s", symbol);
Print("--- String Properties (ENUM_SYMBOL_INFO_STRING) ---");
ENUM_SYMBOL_INFO_STRING string_properties[] =
{
SYMBOL_BASIS,
SYMBOL_CATEGORY,
SYMBOL_COUNTRY,
SYMBOL_SECTOR_NAME,
SYMBOL_INDUSTRY_NAME,
SYMBOL_CURRENCY_BASE,
SYMBOL_CURRENCY_PROFIT,
SYMBOL_CURRENCY_MARGIN,
SYMBOL_BANK,
SYMBOL_DESCRIPTION,
SYMBOL_EXCHANGE,
SYMBOL_FORMULA,
SYMBOL_ISIN,
SYMBOL_PAGE,
SYMBOL_PATH
};
string value;
string result_str;
for(int i = 0; i < ArraySize(string_properties); i++)
{
ResetLastError();
2025-07-13 14:03:44 +02:00
bool success = m_symbol_info.InfoString(string_properties[i], value);
2025-07-13 12:40:14 +02:00
int error = GetLastError();
if(success)
{
if(value == "")
{
result_str = StringFormat("Property: %s, Status: SUPPORTED, Value: Empty",
EnumToString(string_properties[i]));
}
else
{
result_str = StringFormat("Property: %s, Status: SUPPORTED, Value: '%s'",
EnumToString(string_properties[i]), value);
}
Print(result_str);
}
else
{
result_str = StringFormat("Property: %s, Status: QUERY FAILED (Error: %d)",
EnumToString(string_properties[i]), error);
Print(result_str);
}
}
Print("--- Check Completed ---");
}
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+