#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_NAME, GetLastError());
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 'GBPUSD' symbol was successfully opened and a subscription to change it was received
MarketBook for the 'GBPUSD' symbol was successfully closed
*/
}
|