SymbolExist

Vérifie si un symbole avec le nom spécifié existe.

bool  SymbolExist(
   const string  name,    // nom du symbole
   bool&   is_custom      // propriété de symbole personnalisé
   );

Paramètres

name

[in]  Nom du symbole.

is_custom

[out]  La valeur de la propriété de symbole personnalisé en cas d'exécution réussie. Si true, le symbole détecté est un symbole personnalisé.

Valeur de Retour

Si false, le symbole n'a pas été trouvé ni dans les symboles standards, ni dans les symboles personnalisés.

Exemple :

#define SYMBOL_NAME "GBPUSDn"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//--- déclare le symbole comme symbole personnalisé et vérifie la présence d'un symbole dont le nom est spécifié dans SYMBOL_NAME
   bool custom = false;
   bool result = SymbolExist(SYMBOL_NAMEcustom);
   
//--- déclare le texte du message 'symbol not found' par défaut
   string text = StringFormat("The symbol '%s' was not found among either the standard or custom symbols."SYMBOL_NAME);
   
//--- si un symbole est trouvé, crée le texte du message suivant la liste dans laquelle le symbole a été trouvé
   if(result)
     {
      //--- si c'est un symbole standard
      if(!custom)
         text = StringFormat("The '%s' symbol is available on the server."SYMBOL_NAME);
      //--- si c'est un symbole personnalisé
      else
         text = StringFormat("The symbol '%s' was found in the list of custom symbols."SYMBOL_NAME);
     }
     
//--- envoie le message du résultat dans le journal
   Print(text);
   /*
   result for standard 'GBPUSD' symbol:
   The 'GBPUSDsymbol is available on the server.
   
   result for custom 'GBPUSDx' symbol:
   The symbol 'GBPUSDxwas found in the list of custom symbols.
   
   result for missing 'GBPUSDn' symbol:
   The symbol 'GBPUSDnwas not found among either the standard or custom symbols.
   */
  }

Voir aussi

SymbolsTotal, SymbolSelect, Symboles personnalisés