Errors, bugs, questions - page 1172

 

There are errors in the standard library for MQL4, specifically in indicator classes.

For the CiATR class the body of the GetData method is missing.

For indicators that use parameters of the ENUM_APPLIED_VOLUME type(CiForce, CiOBV) there is an error: improper enumerator cannot be used

By the way, ENUM_APPLIED_VOLUME seems to be a standard enumeration; it is present in MQL4 documentation, but in fact it is absent ('ENUM_APPLIED_VOLUME' - undeclared identifier).

So, please check all your libraries. I have a feeling they were hastily ported from MT5 without even checking their functionality.

 

Compile error, build 966

#property library
#define  CLR     C'255,255,255'//White

class A {
        A() { clr = CLR; }
        color clr;
};
build 932 is fine
 
A100:
After direct substitution the code does not compile because of the comment
 

depends on the content of the comment

#define  CLR     C'255,255,255'//не White

it's fine

 
Well, it shouldn't compile anyway )
 

Comments are never substituted - the compiler simply ignores them, otherwise #define in most cases could not be used with comments at all //

#define  ONE 1 //один
#define  TWO 2 //два

int a = ONE + TWO;
приводит к int a = 1 + 2;
а не к int a = 1 //один + 2 //два;
In any case, replace // with /**/ in https://www.mql5.com/ru/forum/1111/page1190#comment_993854
#define  CLR     C'255,255,255'/*White*/

The result is the same - compilation error.

 
Previously on someone else's profile page it was possible to switch to the News Feed (of that user) via a link. Now I don't see such a link, but if I add /news at the end of URL, this page opens normally. Is it a bug that the link has disappeared from the UI?
 
marketeer:
Please explain the following situation. I have a multi-currency indicator, the values of which do not change depending on what chart it is attached to - it calculates the values for the specified instruments and is not related to the current window. I manually draw support and resistance lines on this indicator. Now the trick: if I drag another tool from the market overview into the window, the appearance of the indicator remains the same and lines disappear. If you open the Object List dialog box, those objects are still listed there. The endpoints values (dates and values) remain the same (i.e. they should be visible in the same places) - it's understandable, they have not been changed. However, the lines are not visible. If you then drag the former tool that was originally there onto the window, the lines become visible again. What is the problem?

Found and corrected.

Thanks for contacting me. Turns out to be a generic bug - it's always worked that way before

 

You cannot apply the abbreviated operator !() - compilation error

class A {
public:
        bool operator !() { return ( false ); }
};

bool f1( A* a ) { return ( f3( a ) ); }
bool f2( A* a ) { return ( !a ); }             //ошибка компиляции
bool f3( A* a ) { return ( a.operator!() ); }  //нормально
bool f4( A& a ) { return ( !a ); }

void OnStart()
{
        A *a = new A;
        Print( f1( a ));
        Print( f4( a ));
}

If the compiler understands (and it does) that f4( a ) means 'a' is an object and not a pointer/scriptor as a number)

it should also understand that !a' means the same thing for 'a' (object, not pointer/numeric)

in other words, if

class A {
    void f() {}

void OnStart()
{
        A a1;
        A *a2 = new A;
        a1.f();
        a2.f();
}
a1.f() and a2.f() mean the same thing, whether a1, a2 is a pointer or an object, how is operator !() any worse?
 

I should add that, for example, there is no compilation error with operator+(), nor is there one if we simply add operator+(), which is not used at all, to the first example above

class A {
public:
        bool operator !() { return ( false ); }
        bool operator +() { return ( false ); }
};
but in this case another uncertainty occurs
class A {
public:
        bool operator !() { return ( true ); }
        bool operator +() { return ( true ); }
};

int g( A& a )  { return ( 10 ); }
int g( int )   { return ( 20 ); }

void OnStart()
{
        A *a = new A;
        Print( !a );            //здесь    считает                 'a' - числом ???
        Print( a.operator!() ); //здесь не считает (что правильно) 'a' - числом
        Print( g( a ) );        //здесь не считает (что правильно) 'a' - числом, хотя есть g( int ) и нет g( A* )
}
Reason: