Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 588

 

There is a problem with classes.

There are two class libraries - the standard MQL4 library and a third-party developer's one. Both of these libraries should be used, but the problem is that they contain some classes with the same name. As a result, I've got ambiguity. The compiler does not know which library I am using the class from.

How to deal with this situation? In C++ this problem can be solved with aliases, in MQL I don't know.

 
Barbarian:

There is a problem with classes.

There are two class libraries - the standard MQL4 library and a third-party developer's one. Both of these libraries should be used, but the problem is that they contain some classes with the same name. As a result, I've got ambiguity. The compiler does not know which library I am using the class from.

How to deal with this situation? In C++ this problem can be solved with aliases, in MQL I don't know.

Everyone put in their own namespace.
 
Zhunko:
Put each one in its own namespace.

How do I define a namespace in MQL4? I can't find it. So far, I'm thinking something along these lines:

#ifndef  CTable
   #include <\Integer_Test\GUI.mqh>
#endif
#ifndef  CList
   #include <Arrays\List.mqh>
#endif

but I keep getting errors with redefinition. I think I need something else.

 
Barbarian:

How do I define a namespace in MQL4? I can't find it. So far, I'm thinking something along these lines:

but I keep getting errors with redefinition. I think I need something else.

namespace A
 {
  class a{};
 }
namespace B
 {
  class a{};
 }
These are two different classes, although they are the same :-))
 
Zhunko:
These are two different classes, although they are the same :-))

This is an example for C++, there is no namespace in MQL4.
 
Barbarian:
This is an example for C++, no namespace in MQL4.

I accidentally deleted my reply :-(

I'll have to ask them to do it.

You could try putting it in a class with static members. It's almost the same thing.

Or it may be described in the following way:

class A
 {
  class a{};
 }
class B
 {
  class a{};
 }
 
Zhunko:

I accidentally deleted my reply :-(

I'll have to ask them to do it.

You could try putting it in a class with static members. It's almost the same thing.

Or the same way:

Thanks Vadim, I've already thought about such a way. It won't work for me since the standard class library must be unchanged. With third-party library is funnier :) change it did not want to change anything, but in the end, that would not mess with unnecessary times, changed the name of the class in it and everything associated with it.

I am interested in the ways to avoid this problem using MQL4 tools, without changing class libraries themselves.

 
Barbarian:

Thanks Vadim, I've already thought of a similar way. It won't work for me as the standard class library should be unchanged. I didn't want to change anything in it, but in the end, I changed the class name in the library and everything associated with it, so as not to rack my brains.

I am interested in the ways to avoid this problem using MQL4 tools, without changing class libraries themselves.

This is what it is without any changes or interventions.
 
AlexeyVik:


Look at the code of the Heiken Ashi indicator
I've already gutted it... There's a histogram there, if you can't find a way to use it with bars...
 
Frostr:
I've already gutted it... There's a histogram, so if you can't find a way to do it with bars, you'll have to use it...
Do you prefer bars to candlesticks? Interesting question, but I hate to waste my time on it. In fact, a bar is also a histogram with Open and Close labels attached to it
. If you don't care about colours of these labels, you can use this method as in H.A. Just calculate the width of bar in pixels (it's possible, I checked it but I don't remember where it is in Help) and set the bar width, while Open and Close will be the colour specified in the chart properties.
Reason: