MQL5Book/Scripts/p6/SymbolExists.mq5

22 lines
1 KiB
MQL5
Raw Permalink Normal View History

2025-05-30 16:09:41 +02:00
//+------------------------------------------------------------------+
//| SymbolExists.mq5 |
//| Copyright 2022, MetaQuotes Ltd. |
//| https://www.mql5.com |
//| Check given symbol name for existence. |
//+------------------------------------------------------------------+
#property script_show_inputs
input string SymbolToCheck = "XYZ";
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
const string _SymbolToCheck = SymbolToCheck == "" ? _Symbol : SymbolToCheck;
bool custom = false;
PrintFormat("Symbol '%s' is %s", _SymbolToCheck,
(SymbolExist(_SymbolToCheck, custom) ? (custom ? "custom" : "standard") : "missing"));
}
//+------------------------------------------------------------------+