Self-learning the MQL5 language from scratch - page 78

 
Alexey Viktorov:

I would do this.

The thing is, it's a function from my EA, and it's multi-instrumental. That's when you add symbols and it checks for all available symbols. If it is found, it is added to the market report for further use with it. And of course the correct name of the instrument is written into the local variable.

 
Vitaly Muzichenko:

Alexey, the code is quite normal. What is not normal is entering several characters into the parameter, which is unlikely to be done by anyone.

I have about the same implementation in my work product.

This implementation successfully works in a multicurrency solution, which cannot be said about other codes, i.e. the code is universal.

There's not a hint of a multicurrency solution in the question. That's why it says the code doesn't meet the requirement.

 

And just for the record. Why check both ways

StringFind(symbol, s, 0) >= 0 || StringFind(s, symbol, 0) >= 0

Foolproof. I once had a client who complained that he entered a symbol but it didn't work. It turned out that his terminal showed a pure symbol but entered it with additives. I added the second direction of check without long thinking )))

 
Then there will be a third type, which will be outraged by the fact that he entered the name of the symbol without additives, and the graph has additives, but for some reason the Expert Advisor worked. Therefore, make an exact comparison, and if it does not match, display a message - "the graph has so-and-so symbol, and you enter so-and-so" and let the burden of responsibility fall on the user.
 
Dmitry Fedoseev:
Then we will have a third type that will complain that it entered the name of the symbol without additives, while the chart has additives, but the Expert Advisor has worked for some reason. Therefore, make an exact comparison, and if it does not match, display a message - "the graph has so-and-so symbol, and you enter so-and-so" and let the burden of responsibility lies on the user.

Not an option, of course. A person is comfortable entering pure characters. And let the code add the suffixes/prefixes itself. Purely for the sake of convenience. I'm not a fan of digging up the full name of a character myself.
You may even just copy the set file and run the program. No need to overwrite anything. There are symbols, they will be hooked automatically.

 
Konstantin Nikitin:

Not an option, of course. A person is comfortable entering pure characters. And let the code add the suffixes/prefixes itself. Purely for the sake of convenience. Not a fan of digging up the full name of a character myself.

Foolproofing is never convenient)

 
Valeriy Yastremskiy:

Foolproofing is never convenient)

It's not so much the foolproofing. It's more about the convenience of copying a set file. I already got used to it (you get used to a good thing quickly) and don't notice when I transfer settings. Quite handy.
Although the second direction and added from fools )))

 
 MrBrooklin:

Hello Alexey!

In order to improve your knowledge in MQL5 programming language, please explain why there is no difference between void &array and void& array?

Sincerely, Vladimir.

I don't know. I've found out by experience that void & array works the same way. This & means that the variable is passed by reference and nothing else. An array as an input parameter to a function is passed by reference only.
 
Alexey Viktorov:
I don't know. I've learned through experience that void & array works anyway. This & means that the variable is passed by reference and nothing else. An array as an input parameter to a function is passed by reference only.

Thank you, Alexey! I'll keep that in mind for the future.

Merry Christmas!

Sincerely, Vladimir.

 
MrBrooklin:

Thank you, Alexey! I'll keep that in mind for the future.

Merry Christmas!

Sincerely, Vladimir.

Artem Trishkin answered the same question to me, because it's a link (uppercase), so it can stand in any place. should try without spaces for the purity of the experiment.

Reason: