Errors, bugs, questions - page 1768

 
fxsaber:
This is only possible in a dumb compiler. You know it yourself.
C++ compiler won't think it through for you.
#include <iostream>
using namespace std;
struct S
{
    S operator +(const S&) {cout << "operator +\n"; return S{};}
};
S operator ""_s(const char*, size_t) {cout << "literal operator\n"; return S{};}
int main()
{
    cout << "___literal concatenation example___\n";
    S s = "sd"_s "sf"_s;
    cout << "___operator+ example___\n";
    S s2 = "sd"_s + "sf"_s;
}
The output:
___literal concatenation example___
literal operator
___operator+ example___
literal operator
literal operator

operator +

As you can see, operator+ has not been replaced by concatenation in the second case (created for literal with subsequent run-time addition). The compiler simply cannot cut it out because the programmer has too many possibilities, which greatly limits the scope of optimization. This is not MKL, of course, it may be different, but the very statement: "a normal compiler will do everything for me" is wrong.
 
pavlick_:
This is not MQL, of course, it may be different, but the statement "a normal compiler will do everything for me" is erroneous.
Well, since there are no such operators in MQL, then it's logical not to have any features associated with them. I'm not going to argue about the compilers, because I'm not a programmer at all. I only know a little bit of MQL.
 

Tired of wasting time and money: the optimiser hangs on the last pass. Agents do nothing, everything is at Authorized stage. There is silence in the log. It makes no sense to enable/disable agents, everything starts from scratch after optimization is restarted.

Who has faced this problem? How to fight it?

Files:
opt1.png  44 kb
opt2.png  96 kb
opt3.png  88 kb
 

Magic line

Sequence of operations in MetaEditor\1495 at a screen resolution of 1024x768 :

  • Open the attached file
  • Move the horizontal scroll slider all the way to the right (as in the picture)
  • In the 3rd line click on /*12345*/
Further settings: Service/Settings/General/Tabulation 4 characters
Files:
Test.mq5  2 kb
 

When attempting to convert a string into a number using StringToInteger(), if the string does not contain a number, it returns 0 without an error (GetLastError() = 0). If the input parameters contain a string and the user specified the values incorrectly - the function will return an incorrect value and no error. This is bad.

Further, if the string contains an incorrect number representation, for instance, 5o (instead of 50), the function will return the value 5 without generating an error. Not only that it is not 0, but the function breaks the string as 5, which is again incorrect.

Please, dear developers, improve the function adding error codes or if it cannot parse the string, return LONG_MAX value + error so that we may determine what is wrong. You cannot do it now.

Checking script code:

#property version   "1.00"
#property script_show_inputs
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
input string value="05";
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
   const long iValue=StringToInteger(value);
   Print("iValue = ",iValue,", lastError = ",GetLastError());
  }
//+------------------------------------------------------------------+
 

Implement your own version of the function - it should take no more than 10 minutes.

We will not change the behaviour of the system functions.

 
Renat Fatkhullin:

Implement your own version of the function - it should take no more than 10 minutes.

We will not change the behaviour of the system functions.

So you don't think it is necessary to refine functions, especially functions that can obviously lie?

Even if we just added error codes, it would be Ok, but now you are suggesting that we reinvent the wheel. Not a complicated one, of course, but a bicycle.

 
Alexey Kozitsyn:

So you don't think it's necessary to refine functions, especially functions that can obviously lie?

Even if you just added error codes, it would be good, but now you are proposing to reinvent the wheel. Not a complicated one, of course, but a bicycle.

No need to refine, they are full analogues of wtoi/atoi. The question is closed.
 

Compilation error

#include <Math\Stat\Math.mqh>
struct S {};
 
Hello, could you please tell me if it is possible to set a "period separator" in Metatrader? I just want to be able to see where the 15, 30 and hour candles end on m5, so I don't always have to look at the time, how can I do that?
Reason: