MarketBookAdd

提供所选的交易品种的开盘市场深度信息,预定接收DOM转变的通知。

bool  MarketBookAdd(
   string  symbol      // 交易品种
   );

参量

symbol

[in] 交易品种的名称,市场深度用于EA交易或脚本中。

返回值

如果成功开仓,返回true,否则是false。

整数

一般来说,该函数一定从 OnInit() 函数中调用或者在分类构造函数中。为处理引用警报,在EA交易程序中必须包括 OnBookEvent函数(字符串& 交易品种)。

Example:

#define   SYMBOL_NAME   "GBPUSD"
 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- open the market depth for SYMBOL_NAME symbol
   if(!MarketBookAdd(SYMBOL_NAME))
     {
      PrintFormat("MarketBookAdd(%s) failed. Error "SYMBOL_NAMEGetLastError());
      return;
     }
 
//--- send the message about successfully opening the market depth to the journal
   PrintFormat("The MarketBook for the '%s' symbol was successfully opened and a subscription to change it was received"SYMBOL_NAME);
   
//--- wait 2 seconds
   Sleep(2000);
   
//--- upon completion, unsubscribe from the open market depth
   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 'GBPUSDsymbol was successfully opened and a subscription to change it was received
   MarketBook for the 'GBPUSDsymbol was successfully closed
   */
  }

另见

市场深度结构结构和类