Can anyone help me to give some simple example on how to use SymbolExist() in EA of MT5 ? Thank you
For example:
string current_symbol=Symbol(); double point=SymbolInfoDouble(current_symbol,SYMBOL_POINT); double volume_min=SymbolInfoDouble(current_symbol,SYMBOL_VOLUME_MIN);
Function SymbolExist
Example of use: You write a multi-symbol Expert Advisor (an Expert Advisor that can trade several symbols at once). In the input parameters you specify symbol names. Before starting work, the adviser should check: Have you set the correct symbols?
//+------------------------------------------------------------------+ //| SymbolExist.mq5 | //| Copyright © 2019, Vladimir Karputov | //| http://wmua.ru/slesar/ | //+------------------------------------------------------------------+ #property copyright "Copyright © 2019, Vladimir Karputov" #property link "http://wmua.ru/slesar/" #property version "1.00" //--- input parameters input string InpSymbol_0 = "EURUSD"; // Symbol #0 input string InpSymbol_1 = "EURUSF"; // Symbol #1 input string InpSymbol_2 = "USDJPY"; // Symbol #2 //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- bool is_custom=false; if(!SymbolExist(InpSymbol_0,is_custom)) { Print(__FILE__," ",__FUNCTION__,", ERROR: Symbol #0 (",InpSymbol_0,") is not exist"); return(INIT_FAILED); } if(!SymbolExist(InpSymbol_1,is_custom)) { Print(__FILE__," ",__FUNCTION__,", ERROR: Symbol #1 (",InpSymbol_1,") is not exist"); return(INIT_FAILED); } if(!SymbolExist(InpSymbol_2,is_custom)) { Print(__FILE__," ",__FUNCTION__,", ERROR: Symbol #2 (",InpSymbol_2,") is not exist"); return(INIT_FAILED); } //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+
Result:
2019.10.19 08:00:27.375 SymbolExist (EURUSD,M1) SymbolExist.mq5 OnInit, ERROR: Symbol #1 (EURUSF) is not exist
Function SymbolExist
Example of use: You write a multi-symbol Expert Advisor (an Expert Advisor that can trade several symbols at once). In the input parameters you specify symbol names. Before starting work, the adviser should check: Have you set the correct symbols?
Result:
Can you convert that the EA print if the symbol exist ? I am still confused on the bool i_custom, Thank you.
Can you convert that the EA print if the symbol exist ? I am still confused on the bool i_custom, Thank you.
The variable is_custom is not used.
And the rest: I could not understand your question.
The variable is_custom is not used.
And the rest: I could not understand your question.
ok thanks
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use