Discussion of article "The Use of the MQL5 Standard Trade Class libraries in writing an Expert Advisor" - page 2

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
What am I doing wrong ? Why is the Bid not printed ?
Here is the log of work
2011.01.31 20:20:18 00 (EURUSD,M1) EURUSD 0
here is the code
Use \my_symbol.RefreshRates();\ instead of \my_symbol.Refresh();\. Then it works!
Thanks.
This is probably a question for the developers or the person who writes the Help.
The article says
mysymbol.Refresh()
Used to refresh all data for a symbol. When you specify a new symbol name for a class, it is called automatically.
mysymbol.RefreshRates()
Used to update quotes. When a new symbol is set, it is called automatically.
1. It turns out that not all data ?
2. What is the difference between specifying a new symbol and setting a new symbol ?
3. I don't understand the word automatically. I seem to have set a symbol with the command my_symbol.Name(_Symbol), but the update did not happen....
The article said
mysymbol.Refresh()
Used to refresh all data for a symbol. When a new symbol name is specified for a class, it is called automatically.
mysymbol.RefreshRates()
Used to refresh quotes. When a new symbol is set, it is called automatically.
1. It turns out that not all data ?
2. What is the difference between specifying a new character and setting a new character ?
3. I don't understand the word automatically. I seem to have set a symbol with the command my_symbol.Name(_Symbol), but the update didn't happen....
That rare moment when you don't have to wait for an answer from the author of the article or the author of the reference book :) It's enough to look at the source code to see that RefreshRates() completely duplicates the SymbolInfoTick() function , which "returns current prices for the specified symbol in a variable of MqlTick type". Therefore, when the authors say "about updating quotes", they are actually talking about updating values of a variable of MqlTick type.
2. There is such a line in the source code
This indicates that when calling the Name() function, only the Refresh() function is automatically activated. I have not found any information about the automatic activation of the RefreshRates() function when calling the Name() function. Therefore, it turns out that "as of today" a change of a symbol for the Name() function does not automatically activate the RefreshRates() function. We will have to update the values of the variable of MqlTick type ("refresh quotes") independently and forcibly.What am I doing wrong? Why Bid is not printed? Here is the work log 2011.01.31 20:20:18 00 (EURUSD,M1) EURUSD 0
here is the code
Here is the answer why the Bid value is printed as zero. The source code shows that the Bid() function is described by the line
Thus, the value of the Bid() function is bound to the value of one of the elements of a variable of the MqlTick type. And this variable is updated not automatically when a symbol is changed, but by an additional call of the RefreshRates() function. In your code, the Refresh() function is called - in fact, it is called twice (taking into account the body of the Name() function) - and the RefreshRates() function is not called once.
Perhaps you can improve the code by adding theRefreshRates () call in the final part ofRefresh(). then all the data will really be updated.....
I added the RefreshRates() call to the Name() function. But still - these are patches at the level of an individual user for his needs.
But if the developers put Refresh() in other places (at their discretion) it will be a normal solution for most users.
If we say that Refresh updates all data, then all data should really be updated. IMHO
But if the developers put it in Refresh() and in other places (at their discretion) it will be a normal solution for most users.
If we say that Refresh updates all data, then all data should really be updated. IMHO
There is no argument with that. But still, the normal solution for users would be a clear and understandable description of available designs and their properties. Then the user himself will figure out how to use these constructions. And since such a solution is hard to achieve due to various reasons, those who ask additional questions to themselves and others will move forward :)
I don't know, I use the standard library only for study purposes. I write all my projects on my own components.
I'll wait until constructors will be made more convenient, then I'll give up the standard library altogether....
By the way, I found out that the CHistoryOrderInfo class has a couple of lines like this one
return(FormatType(str,Type())); ... FormatType(type,Type())
But the Type() function is absent in the class.