#define SYMBOL_NAME "GBPUSD"
//+------------------------------------------------------------------+
//| EA交易初始化函数 |
//+------------------------------------------------------------------+
void OnStart()
{
//--- 打开SYMBOL_NAME交易品种的市场深度
if(!MarketBookAdd(SYMBOL_NAME))
{
PrintFormat("MarketBookAdd(%s) failed. Error ", SYMBOL_NAME, GetLastError());
return;
}
//--- 将成功打开市场深度的消息发送到日志
PrintFormat("The MarketBook for the '%s' symbol was successfully opened and a subscription to change it was received", SYMBOL_NAME);
//--- 等待2秒
Sleep(2000);
//--- 完成后,取消订阅打开的市场深度
//--- 将有关成功取消订阅市场深度或有关错误的消息发送到日志
ResetLastError();
if(MarketBookRelease(SYMBOL_NAME))
PrintFormat("MarketBook for the '%s' symbol was successfully closed", SYMBOL_NAME);
else
PrintFormat("Error %d occurred when closing MarketBook using the '%s' symbol", GetLastError(), SYMBOL_NAME);
/*
result:
The MarketBook for the 'GBPUSD' symbol was successfully opened and a subscription to change it was received
MarketBook for the 'GBPUSD' symbol was successfully closed
*/
}
|