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
Hi Vinin!
You checked the indicator: AltrTrend_Signal_v2_2.mq4
and found a logical error
in formula : SSP=MathCeil (Kperiod/iADX(NULL,0,PerADX,PRICE_CLOSE,MODE_MAIN,1))
you underlined 1 at the end
what do you think it should be?
pansa
Probably 0! Try it! And if in a loop, try and i or whatever counts!
Hi Vinin!
You checked the indicator: AltrTrend_Signal_v2_2.mq4
and found a logical error
in formula : SSP=MathCeil (Kperiod/iADX(NULL,0,PerADX,PRICE_CLOSE,MODE_MAIN,1))
you underlined 1 at the end
what do you think it should be?
pansa
Mustshift
The editor generates the following warnings on this standard, legal and popular construct according to C language standards: "declaration of 'a' hides global declaration at line 4" and "declaration of 'b' hides global declaration at line 4" which is also incorrect and illiterate by the core because there is neither declaration of a new variable inside a function nor any hint at any possible overlapping of variables.
As a result, even in a not very large program code we have hundreds of irrelevant warnings.
The messages are absolutely 100% correct.
You need 5-10 years of active programming with full responsibility for your code to someone to appreciate the usefulness of deep control of compilers. C/C++ languages have in no small part earned the fame of being a self-shot tool because of weak compilers that were unwilling and unable to deeply analyse quality and protect authors.
Even now in 2014 C/C++ compilers (the ones left on Windows after they were completely destroyed by Microsoft) are not in the business of protecting programmers from themselves. Yes, there is a weak(practically useless), for some money and separately run Code Analysis in Visial Studio, but we still have to use separately PVS Studio (praise God for those guys), CPP Check and Lint for deep error search.
Testing this example:
Our task is to make a quality compiler that is good at quality control and that does not allow the suicidal/insane techniques of C/C++ languages.
I also think the messages are completely useless. I'm not a professional programmer, but this kind of nonsense in µl stresses me out. I wonder if references to a and b are constant, will PVS Studio generate a warning (no way to check it myself)?
Testing of this example:
1. Could you give an example of what exactly the potential error in this simple code could be, that the compiler warns about?
Taking care of programmers is certainly a good thing, provided that it has a reasonable logical explanation and does not become too obtrusive.
2. I think the quality of the code written is not related to the quality of the compiler and its ability to analyze syntax but occurs only when the test environment is written well enough which allows you to perform deep functional analysis of the code written. But belief in a saving syntactic analysis of code without a test shell is utopia and a waste of efforts.
That's why professional programmers almost never look at the warnings for compilers, by definition, cannot provide functional analysis of code, while even a novice programmer knows the language syntax anyway.
The messages are absolutely 100% correct.
They are correct, but they are not practical. It is also very important that this compiler behaviour cannot be controlled.
You need 5-10 years of active programming with full responsibility for your code to someone to appreciate the usefulness of deep control for compilers. C/C++ languages in no small part earned the fame of being a self-shot tool because of weak compilers that were unwilling and unable to deeply analyse quality and protect authors.
I wonder why exactly these languages were taken as a basis for MQL4/MQL4++/MQL5?
After all, it's not about compilers in the first place, it's about the design of those languages.
Even now, in 2014, C/C++ compilers (the ones left on Windows after they were completely destroyed by Microsoft) are not in the business of protecting programmers from themselves. Yes, there is a weak(practically useless), for some money and separately run Code Analysis in Visial Studio, but we still have to use separately PVS Studio (praise God for those guys), CPP Check and Lint for deep error detection.
Testing of this example:
First, Microsoft is not omnipotent and ubiquitous. And second, there are other compilers left on Windows. I'll give you an example, although I compile it from under Linux, but the Windows and Linux versions of this compiler don't differ in the "deep error search" part. The source code is slightly modified:
Compilation and compiler messages:
You see, in 2014, there are compilers for Windows that have the "deep error search" service.
Note that the right to decide whether to use "deep search" or not is given to the programmer: the same code in more practical compilation without "-Wremarks" option, but with all warnings enabled with "-Wall" option compiles without any comments:
$ icpc -c -Wall 1.cpp $
Furthermore, this compiler allows one to control the "deep search" at the level of individual remarks, disabling those which the programmer considers unnecessary.
The following version of the compiler is used:
By the way, this compiler integrates with Visual Studio, at least earlier versions of it used to integrate with earlier versions of Visual Studio.
Our task is to make a quality compiler that is good at quality control and that does not allow the suicidal/insane techniques of C/C++ languages.
A quality compiler, first of all, must "work", i.e. it must correspond to the language's definition otherwise all its other features will lose their meaning:
Why is the f() method declared in the private section called perfectly from a static method as it should be, but the class constructor, also declared in the private section, is "not called" from the same static method when defining a variable?
Error messages:
This compiler bug doesn't allow, for example, to implement Myers' singleton in a human way (this example is NOT an implementation of said singleton). And this is not the last bug in terms of access to entities declared in the private section.
This is exactly a bug, and not some feature directed, for example, against suicidal/unreasonable techniques, because once you replace automatic variable definition with dynamic object creation, the constructor is suddenly called in the most wonderful way:
This code compiles already without errors. Also, you can make sure that the constructor is already being called in this case by inserting a printout of some message from the constructor code.
As long as such bugs remain, it is strange to speak of a quality compiler. When it comes to errors in the language implementation itself, C/C++ compilers, both commercial and noncommercial, are far superior to MQL4++ compilers because there is no such nonsense in them. So much better, that I would say that compared to them the MQL4++ compiler "doesn't work" at all.
The only really strong feature of the MQL4++ compiler that provides a really serious control of the code quality at this stage is warnings in case the programmer doesn't control return values of functions that can fail, for example, trading functions. But even such a strong feature of the compiler is of very limited value when the quality of its implementation is so poor.
I also think the messages are completely useless. I'm not a professional programmer, but this kind of nonsense in µl stresses me out. I wonder if references to a and b are constant, will PVS Studio generate a warning (no way to check it myself)?
Faithful they are, but not practical.
Well, if the indications of potential errors are correct, then these errors must be fixed.
A potential error is just that, a potential error is not necessarily an error at all. Therefore, the statement that "it means we have to fix these errors" is incorrect, because they may NOT be errors at all.
There are cases where an error is almost certainly present, for example, when a function call result is not checked, which may fail. A warning about such a case is both appropriate and quite useful. Warnings about cases where you cannot tell for sure if there is an error or not are usually both irrelevant and not useful. When names are withheld, you cannot say that there is almost certainly an error.
Yes, it is possible for a programmer to get all sorts of diagnostics on a "deep search" basis to determine if there are potential errors, i.e. - inadvertently made errors. But this must not be the main compiler's mode and it must be possible to disable it. In order to protect novices from potential errors of this kind, the diagnostics can be enabled by default, i.e. after the installation. However, you should still be able to turn it off.
It's obvious that facts of hiding a name in an enclosed scope which was previously declared in the outer scope are detected by the Intel compiler as mere remarks and not as warnings for the same reason: they could be NOT errors at all. And in other compilers, including non-commercial ones, such hiding facts do NOT correspond to any warning. Because all the collective experience of compiler users, i.e. programmers, tells us that this should NOT be a warning. And, of course, the user should be able to configure which warnings/remarks will be issued and which will not.
By the way, since MQL is a separate language that must not follow the C/C++ standards, wouldn't it be easier to disable hiding of names in enclosed scopes in it?
This remark is meaningless and does not give any useful information to the programmer in principle, because there is no concealment of the variable "a" initially, as stated.
Hiding occurs only when a local copy of the variable is created, which is also a legitimate action. Even if an error suddenly occurs in code because of this hiding, it can be easily found precisely because the search immediately finds the same name. If we start to change and alter the names in a function template, which is a "solution" to this rule by compiler logic, the error search situation will become much more complicated and confusion will abound in understanding the code. It seems obvious.