#define SYMBOL_NAME "GBPUSDn"
//+------------------------------------------------------------------+
//| EA交易初始化函数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 声明自定义交易品种标识,并检查是否存在其名称在SYMBOL_NAME中指定的交易品种
bool custom = false;
bool result = SymbolExist(SYMBOL_NAME, custom);
//--- 声明默认的“找不到交易品种”消息文本
string text = StringFormat("The symbol '%s' was not found among either the standard or custom symbols.", SYMBOL_NAME);
//--- 如果找到交易品种,则根据找到交易品种的列表创建消息文本
if(result)
{
//--- 如果这是一个标准交易品种
if(!custom)
text = StringFormat("The '%s' symbol is available on the server.", SYMBOL_NAME);
//--- 如果这是一个自定义交易品种
else
text = StringFormat("The symbol '%s' was found in the list of custom symbols.", SYMBOL_NAME);
}
//--- 将有关检查结果的消息发送到日志
Print(text);
/*
result for standard 'GBPUSD' symbol:
The 'GBPUSD' symbol is available on the server.
result for custom 'GBPUSDx' symbol:
The symbol 'GBPUSDx' was found in the list of custom symbols.
result for missing 'GBPUSDn' symbol:
The symbol 'GBPUSDn' was not found among either the standard or custom symbols.
*/
}
|