SymbolSelect

Consente di selezionare un simbolo nella finestra di controllo del market o rimuove un simbolo dalla finestra.

bool  SymbolSelect(
   string  name,       // nome simbolo
   bool    select      // aggiunge o rimuove
   );

Parametri

name

[in] Nome simbolo.

seleziona

[in] Switch. If the value is false, a symbol should be removed from MarketWatch, otherwise a symbol should be selected in this window. Un simbolo non può essere rimosso se il grafico simbolo è aperto, o non ci sono posizioni aperte per questo simbolo.

Valore restituito

In caso di fallimento restituisce false.

Esempio

#define SYMBOL_NAME "GBPHKD"
 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- verificare la presenza di un simbolo nelle liste, se non trovato, segnalarlo e completare il lavoro
   bool custom = false;
   if(!SymbolExist(SYMBOL_NAMEcustom))
     {
      PrintFormat("'%s' symbol not found in the lists"SYMBOL_NAME);
      return;
     }
     
//--- aggiungere un simbolo alla finestra Market Watch
   ResetLastError();
   if(!SymbolSelect(SYMBOL_NAMEtrue))
     {
      Print("SymbolSelect() failed. Error "GetLastError());
      return;
     }
//--- se un simbolo viene aggiunto con successo alla lista, ottenere il suo indice nella finestra Market Watch e inviare il risultato al journal
   int index = SymbolIndex(SYMBOL_NAME);
   PrintFormat("The '%s' symbol has been added to the MarketWatch list. Symbol index in the list: %d"SYMBOL_NAMEindex);
     
//--- ora rimuove il simbolo dalla finestra Market Watch
   ResetLastError();
   if(!SymbolSelect(SYMBOL_NAMEfalse))
     {
      Print("SymbolSelect() failed. Error "GetLastError());
      return;
     }
//--- se un simbolo viene rimosso con successo dalla lista, il suo indice nella finestra Market Watch è -1, invia il risultato della cancellazione al journal
   index = SymbolIndex(SYMBOL_NAME);
   PrintFormat("The '%s' symbol has been removed from the MarketWatch list. Symbol index in the list: %d"SYMBOL_NAMEindex);
   
  /*
  risultato:
   The 'GBPHKDsymbol has been added to the MarketWatch listSymbol index in the list12
   The 'GBPHKDsymbol has been removed from the MarketWatch listSymbol index in the list: -1
  */
  }
//+---------------------------------------------------------------------------------------------+
//| Restituisce l'indice del simbolo nella lista dei simboli Market Watch |
//+---------------------------------------------------------------------------------------------+
int SymbolIndex(const string symbol)
  {
   int total = SymbolsTotal(true);
   for(int i=0i<totali++)
     {
      string name = SymbolName(itrue);
      if(name == symbol)
         return i;
     }
   return(WRONG_VALUE);
  }