Errors, bugs, questions - page 2206

 
Alexander Nikolaev:
Who knows why I can't access recently created demo accounts, which were created directly in MT4 terminal, on Metaquotes Demo server? I created one a week ago. The first 2 days it works, but after some time the account disappears, as if the password becomes incorrect (although it was copied, I could not enter it incorrectly) and I have to reopen the account to test the Expert Advisor. Is it really necessary to create a new account every week?
it's been like this for a long time, if there is no activity on the account, it gets closed. create a new one and don't worry about it.
 
Denis Sartakov:

I've recently written a function like this, so try and figure it out for yourself,

If it doesn't work, I'll explain.

thanks

 

another question:

the description ofCHART_IS_MAXIMIZED andCHART_IS_MINIMIZED does not say that these properties are read-only, but ChartSetInteger(ChartID(),CHART_IS_MAXIMIZED,true); does not work, what could be the problem???

 

Why doesn't it compile?

template <typename T>
void f(T &t)
{
   t.f();
}

void OnStart()
{
   class Q
   {
   public:
      void f() {}
   }q;
   
   f(q);
}

Older versions of the compiler ate such constructs fine, took to recompile valid earlier code and error. Is it an accident or has it broken off intentionally?

 
pavlick_:

Why doesn't it compile?

Older versions of the compiler were fine with such constructs, I recompiled previously valid code and there's an error. Is it an accident or has it broken off intentionally?

but can we create classes inside functions according to the language specification?

 
Konstantin:

but can you create classes within functions according to the language specification?

What language specification? Mcl is not well documented at all, while in c++ it is normal practice, from the reference:

Local classes

A class declaration can appear in namespace scope (in which case it defines an ordinary class), inside another class definition (in which case it defines a nested class), and inside the body of a function, in which case it defines a local class. The name of such a class only exists within the function scope, and is not accessible outside.

http://en.cppreference.com/w/cpp/language/class

 

The answer is silence, as usual. Actually it's easy to work around the problem - instead of elegant placement inside the function, I put it outside with intimidating name internal__Chart_bar_shift_Comp. But the point is different - they just cut such a construct. I.e. there's no guarantee that my code will compile tomorrow. You can somehow with keys to select the dialect -std=mql18, for example. But no, don't care about backward compatibility. I find it hard to imagine that this is possible on some gcc.

I guess a simple scripting mql4 was quite sufficient for a trading platform. Or better yet, import plugins (in dynamic libraries) with scripts/experts. But no, you need your own, as they often say here, "infrastructure", where you are big and important.

 
pavlick_:

According to which language specification? Mcl is not well documented at all, but in c++ it is normal practice, from the reference book:

Local classes

A class declaration can appear in namespace scope (in which case it defines an ordinary class), inside another class definition (in which case it defines a nested class), and inside the body of a function, in which case it defines a local class. The name of such a class only exists within the function scope, and is not accessible outside.

http://en.cppreference.com/w/cpp/language/class

i met a discussion somewhere that it's not foreseen in mql5 specification, check on forum, there was also a discussion about lambas, that they are not foreseen

 
pavlick_:

The answer is silence, as usual. Actually it's easy to work around the problem - instead of elegant placement inside the function, I put it outside with intimidating name internal__Chart_bar_shift_Comp. But the point is in something else - they just cut such a construct. I.e. there's no guarantee that my code will compile tomorrow. You can somehow with keys to select the dialect -std=mql18, for example. But no, don't care about backward compatibility. I can hardly imagine that it is possible in some gcc.

Probably, a simple mql4 script was quite sufficient for a trading platform. Or better - import plugins (in dynamic libraries) with scripts/experts. But no, you need your own, as they often say here, "infrastructure", where you are big and important.

To be honest, I don't understand why they do that. It's easier to put all the auxiliary entities in a separate listing of the source code, for example util.mqh

 
Konstantin:

To be honest, I don't understand why, it's easier to put all the auxiliary entities in a separate listing of the source code, for example util.mqh

This is a predicate for binary search, which is not universal and is used only once in a function, why should I put it somewhere? For example, we have an array of structures (no comparison operator, they can't be compared clumsily using <, or the comparison condition is very tricky), and we want to find an element through binary search. In the plus library, algorithm functions take a functor (conveniently passed as a lambda), inside which we compare array elements. A very elegant solution in my opinion.

int main()
{
    typedef pair<int, double> myPair; // typedef to shorten the type name
    vector <myPair> vec(5);

    myPair low_val; // reference value (set this up as you want)
    auto it = lower_bound(vec.begin(), vec.end(), low_val, 
        [](myPair lhs, myPair rhs) -> bool { return lhs.second < rhs.second; });
}

But due to the limitations of µl, created an instance of the predicate class.

Reason: