MarketBookAdd

Fornisce l'apertura della profondità di mercato per un simbolo selezionato, e sottoscrive per ricevere le notifiche dei cambiamenti DOM.

bool  MarketBookAdd(
   string  symbol      // simbolo
   );

Parametri

symbol

[In] Il nome di un simbolo, la cui profondità di mercato deve essere utilizzata nell' Expert Advisor o script.

Valore restituito

Il valore true se aperto con successo, altrimenti false.

Nota

Normalmente, questa funzione deve essere chiamata dalla funzione OnInit() o nel costruttore della classe. Per gestire gli avvisi in arrivo, nel programma Expert Advisor deve contenere la funzione void OnBookEvent(stringa e simbolo).

Esempio

#define   SYMBOL_NAME   "GBPUSD"
 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- aprire la profondità di mercato per il simbolo SYMBOL_NAME
   if(!MarketBookAdd(SYMBOL_NAME))
     {
      PrintFormat("MarketBookAdd(%s) failed. Error "SYMBOL_NAMEGetLastError());
      return;
     }
 
//--- inviare il messaggio di successo dell'apertura della profondità di mercato al journal
   PrintFormat("The MarketBook for the '%s' symbol was successfully opened and a subscription to change it was received"SYMBOL_NAME);
   
//--- attendere 2 secondi
   Sleep(2000);
   
//--- al completamento, annullare l'apertura della profondità di mercato
   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);
      
   /*
   risultato:
   The MarketBook for the 'GBPUSDsymbol was successfully opened and a subscription to change it was received
   MarketBook for the 'GBPUSDsymbol was successfully closed
   */
  }

Vedi anche

Struttura della Profondità di Mercato, Strutture e Classi