Download MetaTrader 5
To add comments, please log in or register
Interessiert am Partnerprogramm MQL5.community? Veröffentliche Links und verdiene Geld damit!
Amir Yacoby
1122
Amir Yacoby 2010.09.02 00:45 

Hi

I can't get it right when using the CIndicator and the inherited classes.

If I declare a CIndicator pointer, and then use it as an inherited CiCustom, I can't manage to make it.

CIndicator    *ind;

Ind = new CiCustom; 

and when using a method from CiCustom, NumBuffers, in order to set the number of the buffers I get error message: 'NumBuffers' - wrong parameter count.

Ind.NumBuffers(1)   ==> wrong parameter count

because probably NumBuffers of the CiCustom that sets the buffers is not recognised. What am I doing wrong? 

and also then when I try to inspect the Ind variable in order to see what type of CIndicator inherit is it (CiCustom or others)

how do I do it? Because I can't get it with:

switch (Ind.Type())

   case IND_CUSTOM:

       ....

because Type() is not declared in the CIndicator, only in it's inheritors.

The reason that I need to know at run time the type of the indicator, is that if it is custom indicator I want to be able to get the Indicator parameters thru the methods in CiCustom. 

BUG ** - the initialize method in CiCustom does not initializes m_num_params 

thank you 

Nikolaos Pantzos
10159
Nikolaos Pantzos 2010.09.02 12:37  

buitiful!!!

Amir Yacoby
1122
Amir Yacoby 2010.09.02 21:46  
 

also with casting to CiCustom I couldn't manage:

(CiCustom)Ind.NumBuffers(1)  ==> wrong parameter count

 

Any comment from the team?

 

Thanks 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Chart Constants / Types of Chart Events
  • www.mql5.com
Standard Constants, Enumerations and Structures / Chart Constants / Types of Chart Events - Documentation on MQL5
Ilyas
1182
Ilyas 2010.09.03 11:30  
It would be better, if you attach the code. It seems, that it contains an error. For more information see Virtual Functions help topic and the MQL for "Dummies": How to Design and Construct Object Classes article

Alexey Da
Moderator
6397
Alexey Da 2010.09.03 13:46  
Please use servicedesk or private messages to send code.
MQL5.community - User Memo
  • 2010.02.25
  • MetaQuotes Software Corp.
  • www.mql5.com
You have just registered and most likely you have questions such as, "How do I insert a picture to my a message?" "How do I format my MQL5 source code?" "Where are my personal messages kept?" You may have many other questions. In this article, we have prepared some hands-on tips that will help you get accustomed in MQL5.community and take full advantage of its available features.
Amir Yacoby
1122
Amir Yacoby 2010.09.03 20:54  

This is the code inside a script

CIndicator    *ind; 

ind = new CiCustom;

ind.NumBuffers(1);    // <== compiler error: wrong parameter count - I also tried ==> ((CiCustom)ind).NumBuffers(1);         // <=== invalid cust operation

if(ind.Create(NULL,PERIOD_CURRENT,IND_CUSTOM,8,parms)){
      Print("successful ind creation");
      }
   else
      Print("failed ind creation"); 

and then passing the ind pointer on to a different class and in that class:

CIndicator *ind;

switch (ind.Type()){               === > compiler error: type is not declared for CIndicator as virtual

   case IND_CUSTOM: 

         parms = ind.NumParams();      ====> always zero -> m_num_params inside CiCustom is zero, it was not initialized by the Initialize method of CiCustom 

 

the ind.Create in third line, runs the Initialize method of CiCustom in the background but the method does not initializes the m_num_params, so on the other class when I use the method ind.NumParams() and get zero, even though the ind.Create was successful and the Initialize method ran.

P.S: 

Please look inside the code of the CiCustom.mqh and you will notice that there is no initialization of m_num_params anywhere in the code. 

And so, the method NumParams() that is defined:  int               NumParams()  { return(m_num_params); }               // <============= always return zero 

Amir Yacoby
1122
Amir Yacoby 2010.09.08 18:48  

Anyone? Rosh?

/
To add comments, please log in or register