inputstring Symbol_Main="GBPUSDrfd"; //Валютная пара, на которую ставим советник//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
/* Определим график валютной пары, на который будем устанавливать советник*/if(Symbol_Main==_Symbol) //если график валютной пары совпадает со входным параметром
{
/* выводим окно сообщений на торговом терминале и продолжаем работу советника */MessageBox("Работа советника на данной валютной паре разрешена!");
return(INIT_SUCCEEDED); //возвращаем для функции OnInit значение означающее "удачная инициализация"
}
else//в противном случае, если график валютной пары не совпадает со входным параметром
{
/* выводим окно сообщений на торговом терминале и закрываем советник */MessageBox("Работа советника на данной валютной паре запрещена! Выходим!");
return(INIT_FAILED); //возвращаем для функции OnInit значение означающее "неудачная инициализация"
}
}
Note: In the Symbol_Main input parameter, you should specify the name of the currency pair as prescribed by your forex dealer. In my case GBPUSD symbol has the ending rfd.
Note: In the Symbol_Main input parameter, you need to specify the name of the currency pair as prescribed by your forex dealer. In my case GBPUSD symbol has the ending rfd.
And enjoy your life )))) Note that I request even not completely written symbol and case is not important.
Thanks a lot, Konstantin, for the great tip! I will certainly use it in my EA. I think this function will also be useful for beginners in learning the MQL5 programming language.
And enjoy your life )))) Note that I am even asking for a character that is not completely written and is not case sensitive.
Why should you make fun of an immature mind? Your code does not meet the requirement at all. If you enter only "eu" or "eur" in the input parameters, that part of the condition
|| StringFind(s, symbol, 0) >= 0)
will be fulfilled no matter what currency pair contains "EU" in its name and it does not matter EUR as base currency or quoted currency. And why go through SymbolName MarketWatch searching for the right symbol?
Why make such a mockery of an immature mind? Your code does not meet the requirement at all. If only "eu" or "eur" is entered in the input parameters, this part of the condition
will be fulfilled no matter what currency pair contains "EU" in its name and it does not matter EUR as base currency or quoted currency. And why should I go through the SymbolName of MarketWatch searching for the right symbol?
Hello Alexey! To be honest, I'm not good at programming, so I take a lot on faith. Does it mean that the code provided by Konstantin should be reworked?
Note: In the Symbol_Main input parameter, you should specify the name of the currency pair as prescribed by your forex dealer. In my case GBPUSD symbol has the ending rfd.
Be careful!
Sincerely Vladimir.
I would do it like this
inputstring Symbol_Main="GBPUSD"; //Валютная пара, на которую ставим советник//+------------------------------------------------------------------+//| Expert initialization function |//+------------------------------------------------------------------+intOnInit()
{
/* Определим график валютной пары, на который будем устанавливать советник*/if(StringFind(_Symbol, Symbol_Main, 0) == 0) //если график валютной пары содержит входной параметр
{
/* выводим окно сообщений на торговом терминале и продолжаем работу советника */MessageBox("Работа советника на данной валютной паре разрешена!");
return(INIT_SUCCEEDED); //возвращаем для функции OnInit значение означающее "удачная инициализация"
}
else//в противном случае, если график валютной пары не совпадает со входным параметром
{
/* выводим окно сообщений на торговом терминале и закрываем советник */MessageBox("Работа советника на данной валютной паре запрещена! Выходим!");
return(INIT_FAILED); //возвращаем для функции OnInit значение означающее "неудачная инициализация"
}
}
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
MrBrooklin: . Why dance when there is a direct request for the current chart symbol.
Hello Konstantin, I needed to compare the symbol that was specified in the input parameters with the symbol that the EA is attempting to set to.
The code you suggested does not work either.
Regards, Vladimir.
Hello Konstantin, I needed to compare the symbol that was specified in the input parameters with the symbol that the EA is attempting to set to.
The code you suggested does not work either.
Regards, Vladimir.
In your settings you have specified
_Symbol
The _Symbol variable stores the name of the current chart symbol.
So, the check for the symbol in the current chart should work fine.
In your settings you have specified
_Symbol
The _Symbol variable stores the name of the current chart symbol.
So, the symbol check by the current chart should be successful.
Thank you, Konstantin! It all worked! I made a mistake when correcting the code. I fixed it now and it worked. God grant you health and prosperity!
I wish you all a Happy New Year!
Regards, Vladimir.
The code should look like this:
Note: In the Symbol_Main input parameter, you should specify the name of the currency pair as prescribed by your forex dealer. In my case GBPUSD symbol has the ending rfd.
Be careful!
Regards, Vladimir.
The code should look like this:
Note: In the Symbol_Main input parameter, you need to specify the name of the currency pair as prescribed by your forex dealer. In my case GBPUSD symbol has the ending rfd.
Be careful!
Sincerely, Vladimir.
And enjoy your life )))) Pay attention that I am asking even not completely written symbol and case is not important.
And enjoy your life )))) Note that I request even not completely written symbol and case is not important.
Thanks a lot, Konstantin, for the great tip! I will certainly use it in my EA. I think this function will also be useful for beginners in learning the MQL5 programming language.
I am still as close as crawling to Peking!
Regards, Vladimir.
And enjoy your life )))) Note that I am even asking for a character that is not completely written and is not case sensitive.
Why should you make fun of an immature mind? Your code does not meet the requirement at all. If you enter only "eu" or "eur" in the input parameters, that part of the condition
will be fulfilled no matter what currency pair contains "EU" in its name and it does not matter EUR as base currency or quoted currency. And why go through SymbolName MarketWatch searching for the right symbol?
Why make such a mockery of an immature mind? Your code does not meet the requirement at all. If only "eu" or "eur" is entered in the input parameters, this part of the condition
will be fulfilled no matter what currency pair contains "EU" in its name and it does not matter EUR as base currency or quoted currency. And why should I go through the SymbolName of MarketWatch searching for the right symbol?
Hello Alexey! To be honest, I'm not good at programming, so I take a lot on faith. Does it mean that the code provided by Konstantin should be reworked?
Sincerely, Vladimir.
The code should look like this:
Note: In the Symbol_Main input parameter, you should specify the name of the currency pair as prescribed by your forex dealer. In my case GBPUSD symbol has the ending rfd.
Be careful!
Sincerely Vladimir.
I would do it like this