Errors, bugs, questions - page 815

 
tol64:

Can you tell me why an error occurs when getting an indicator handle, if the name of the indicator to be called is contained in a variable?

I mean, there is no error like this:

This is how we get error 4802 (Indicator cannot be created):

Read abouttester_indicator here.
 
marketeer:
Read aboutthe tester_indicator here.
Yes, I've read and reread everything many times already. )) But I have not managed to get what I need. And I need to set indicator's name to a variable.
 
tol64:
I've read and reread the whole thing over and over again. )) But I can't get what I need. And I need to set indicator's name to a variable.
So, have you added the property test_indicator? I guess I can't do it without it.
 
marketeer:
So, did you add property test_indicator? I don't think I could have done it without it.

I tried it. Something does not work like this. Could you show me an example (maybe I'm doing it wrong)?

P.S. It worked. It couldn't be easier. Off to rest. ))

P.S2. But I get the dependence on the fact that I have to register all indicators through the property test_indicator. That is, if the indicator name is specified by external parameter and a user has a new indicator, we have to open the code again. This is not exactly what we want.

 
tol64:

P.S2. But we still get the dependency of having to write all indicators via property test_indicator. That is, if the indicator name is specified by external parameter and a user has a new indicator, we have to open the code again. This is not exactly what we want.

It is done in five. I used it to build indices from some other randomly selected indices. Maybe the developers will tell us what they think about it.
 
marketeer:
This is how it is done in five. I used it myself to build indices from several other randomly selected indices. Maybe the developers will tell us what they think about it.

The thing is that EAs in the MT5 tester are launched outside the terminal and do not have all the library environment that was in MT4.

For example, the Expert Advisor is sent to the cloud at all and in order to pass additional links, we have to:

  1. use static indicator names in calls, that allows the compiler to automatically prescribe the expert's dependencies
  2. prescribe explicitly through property the list of required indicators to manually build the list of dependencies.

If dynamic indicator calls are used then you need to manually prescribe the list of indicators used. When running a third-party test, all dependent files are sent together with the Expert Advisor. These can be both local (they are outside the terminal anyway), and remote or cloud agents.

This is the price to pay for "press start and don't think about anything else, everything works automatically".

Способы вызова индикаторов в MQL5
Способы вызова индикаторов в MQL5
  • 2010.03.09
  • KlimMalgin
  • www.mql5.com
C появлением новой версии языка MQL, не только изменился подход к работе с индикаторами, но и появились новые способы создания индикаторов. Кроме того, появилась дополнительная гибкость при работе с индикаторными буферами - теперь вы можете самостоятельно указать нужное направление индексации и получать ровно столько значений индикатора, сколько вам требуется. В этой статье рассмотрены базовые методы вызова индикаторов и получения данных из индикаторных буферов.
 
Renat:

The whole point is that EAs in the MT5 tester run outside the terminal and do not have all the library environment that MT4 had.

This is the price to pay for "press start and don't think about anything else, everything works automatically".

This is understandable, but on the other hand users regularly have a counter question, because the usual and effective flexibility has been lost. You have in fact only implemented a static binding model. And people are asking for dynamic linking as well. The idea is that even if something is sent to the cloud, starts to be counted and suddenly accesses an external turret, you can query and retrieve it similarly to the rest of the environment, which is passed from the terminal to the agent. Well, it's just a thought out loud. I didn't ask this question ;-).
 

This question may have already been raised, but I couldn't find it in the forum.

In the following code (in the test() method), when taking a constant descriptor (reference) to an object and assigning it to a non-constant one, the compiler (MetaEditor 5.00, Build 687) does not generate an error:

class A{
   public:
      void someDo() {}
};

class B{
   public:
      void B( A* aA ) : mA( aA ) {}
      const A* getA() { return (mA); }   
   private:
      A* mA;
};

void test(){
   A a;
   B b( GetPointer( a ) );

   //Ошибки нет. И это правильно   
   const A* a1 = b.getA();
   //Ошибка есть: "...someDo' - call non-const method for constant object..". И это правильно   
   a1.someDo();
   
   //Ошибки нет. Это НЕ правильно(CONST A* B::getA())!
   A* a2 = b.getA();
   //ошибки нет. Правильно (а2 не const)
   a2.someDo();
}
 
mvk:

This question may have already been raised, but I haven't found it in the forum.

In the following code (in the test() method), when getting a constant descriptor (reference) to an object and assigning it to a non-constant one, the compiler (MetaEditor 5.00, Build 687) does not generate an error:

this would be the case without the error.

class A{
   public:
      void someDo() const {};
};
 

question for developers on the speed of object pointers


Why does the first code

class CSomeObj
{
public:
   double prm;
};

CSomeObj arr;

void OnStart()
{
        EventSetTimer(1);

        uint s0=GetTickCount();
        for (int i=0; i<100000000; i++) arr. prm=10;
        Print("1=", GetTickCount()-s0);
        
        s0=GetTickCount();
        CSomeObj *item=GetPointer(arr);
        for (int i=0; i<100000000; i++) item. prm=10;
        Print("2=", GetTickCount()-s0);
}

works twice as fast as the second?

2012.08.21 09:56:40 info (EURUSD,D1) 2=1654
2012.08.21 09:56:38 info (EURUSD,D1) 1=795

can you optimize it to increase the speed?

Reason: