Questions from Beginners MQL4 MT4 MetaTrader 4 - page 124
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
Hello !
Can you tell me how to repaint the bars without using templates in mt4 !??
Or how to apply a colour scheme !?
I'll simplify the answer a bit to avoid confusion. The (&) sign indicates that a function argument can change its value at runtime and will return to where the function was called from with a different value. In the case in question, the SaveOrder function can change the contents of the g_arrstBuyOrderInfo and g_arrstSellOrderInfo arrays, as well as the g_nBuyOrdersCnt and g_nSellOrdersCnt variables.
Thank you. It becomes a bit clearer. It's just not clear how all this can be found out without referring to the forum. I haven't found such explanations in the tutorials.
Please give me some more advice:
1) The compiler writes - 'g_nBuyOrdersCnt' - declaration without type ; 'g_nSellOrdersCnt' - declaration without type. Am I correct in assuming that g_nBuyOrdersCnt and g_nSellOrdersCnt should be declared globally to avoid an error by the compiler?
2) Compiler:'for' - expressions are not allowed on a global scope. It is not clear here.
3) In thevoid SaveOrderInfo(OrderInfo &arrstOrderInfo[], int &nOrdersCnt) function, the compiler writes: declaration of 'arrstOrderInfo' hides global declaration. see previous declaration of 'arrstOrderInfo'. It is not very clear either.
4) 'nOrderCnt' is an undeclared identifier. Why is it not declared anywhere?
Hello !
Can you tell me how to repaint the bars without using templates in mt4 !??
Or how to apply a colour scheme !??
If programmatically, see ChartSetInteger() and ChartGetInteger() functions.
Thank you. It's starting to make a little more sense. It's just not clear how you can find out all this without referring to a forum. I couldn't find such explanations in the textbooks.
Please give me some more advice:
1) The compiler writes - 'g_nBuyOrdersCnt' - declaration without type ; 'g_nSellOrdersCnt' - declaration without type. Am I correct in assuming that g_nBuyOrdersCnt and g_nSellOrdersCnt should be declared globally to avoid an error by the compiler?
2) Compiler:'for' - expressions are not allowed on a global scope. It is not clear here.
3) In thevoid SaveOrderInfo(OrderInfo &arrstOrderInfo[], int &nOrdersCnt) function, the compiler writes: declaration of 'arrstOrderInfo' hides global declaration. see previous declaration of 'arrstOrderInfo'. It is not very clear either.
4) 'nOrderCnt' is an undeclared identifier. Why is it not declared anywhere?
Here's how it all should be in the code if you look at the code as a whole:
One last thing: I still don't understand where.n and.f come from and what they are.
The "dot" operator indicates access to a member of a structure or class. In this case, it is a structure.
Letters n and f are a way of specifying the type of data stored in a variable. After all, with a huge number of variables, it is impossible to remember the type of each one. And if in a name of a variable there will be an indication of its type, necessity of remembering disappears by itself. n is a sign of an integer number (from Numeric), f is a real number (from float - floating point number). This way of writing variable names is called Hungarian notation.
The dot operator indicates access to a member of a structure or class. In this case, a structure.
The letters n and f are a way of specifying the type of data that is stored in a variable. After all, with a huge number of variables, it is impossible to remember the type of each one. And if in a name of a variable there will be an indication of its type, necessity of remembering disappears by itself. n is a sign of an integer number (from Numeric), f is a real number (from float - floating point number). This way of notation of variable names is called Hungarian notation.
There it is!!! Turns outg_ andg_n are not just some abbreviation, but prefixes saying that they are global and global integer variables!!! Ugh... And I couldn't figure out why these dashes in variable designations... How is it possible for a beginner, who is not familiar with such subtleties, to write code using arrays, structures, etc.? I thought my simple strategy could be written in simple language, without diving into the wilds.
Could you give me a link to a detailed (extended) tutorial on mcl4 to study alongside your advice?
And could you write the above code without using Hungarian notation for comparison? Are you sure the MT4 platform understands it clearly?
And a question about the code: what is thecontinue; for?
If an order is not selected in the first iteration, then it will not be selected in subsequent iterations and the cycle will continue indefinitely? Because the number of orders does not change. Wouldn't it be more correct tobreak with an error message?Context menu graphics, properties, colours - have you tried that?
Thanks I've already found it !!!
If programmatically, see ChartSetInteger() and ChartGetInteger() functions.
Thanks for finding it already with your help!!!
There it is!!! Turns outg_ andg_n are not just some abbreviation, but prefixes that say they are global and global integer variables!!! Ugh... And I couldn't figure out why these dashes in variable designations... How is it possible for a beginner, who is not familiar with such subtleties, to write code using arrays, structures, etc.? I thought my simple strategy could be written in simple language, without diving into the wilds.
In order to do something, we have to delve into the subtleties. There is no other way.
Could you give me a link to a detailed (extended) tutorial on mcl4 to study alongside your advice?
I know only one textbook on MQL4 - that of Sergey Kovalev.
And could you write the above code without using Hungarian notation for comparison? Are you sure the MT4 platform understands it clearly?
Get used to a proper code formatting at once )) The Hungarian notation has been invented by fairly experienced programmers.
And a question about the code: what is thecontinue; for?
So, if an order is not selected in the first iteration, it will not be selected in the next ones and the loop will go on to infinity? Because the number of orders does not change. Wouldn't it be more correct tobreak with an error message?If we failed to select one order, it does not mean that we will not be able to select the next order. Therefore it is reasonable to continue the loop.
Failure to select one order does not mean that the next order cannot be selected. Therefore, it is reasonable to continue the cycle.
And there is no need to display an error message? It would probably be useful to know why an order is not found and how to avoid it?