Discussion of article "Library for easy and quick development of MetaTrader programs (part I). Concept, data management and first results" - page 7

 
I take this opportunity to thank you for the excellent work. I'm finally starting to understand class creation.
 

Well, I'm studying the code according to your proposal of following the steps.

At the moment I'm finalising the study of Article 1. And I stopped right after the implementation of the protected class constructor.

This piece of code I sent you has an error after compilation. It's in the section that returns the flag for closing the position by TakeProfit.

Apparently the'Status' identifier is not declared.

 

Нашел "проблему" .... Была между клавиатурой и компьютером ... МЕНЯ!

После вставки всех методов переменная была определена ...

Так как я еще не дошел до конца кода, то искал ошибку ... Но в последовательности переменная определена и все решено.

Извините за неудобства.

Спасибо

 
albertpess :

Well, I'm studying the code according to your proposal to follow the steps.

At the moment I'm finalising the study of Article 1.And I stopped right after the implementation of the protected class constructor.

This piece of code I sent you has an error after compilation. It is in the section that returns the flag for closing the position by TakeProfit.

Apparently the'Status' identifier is not declared.

So, somewhere they did something wrong. Missed something.

Just download the files attached to the article to your terminal folder and compile the EA.

And only then disassemble everything step by step as described in the article.

 
Artyom Trishkin:

So, somewhere they did something wrong. Missed something.

Just download the files attached to the article to your terminal folder and compile the EA.

And only then disassemble everything step by step as described in the article.

Thank you.

 
Very useful and well done! Thanks
 
It's pretty good.
 

Implementing the protected class constructor:

//+------------------------------------------------------------------+
//| Closed parametric constructor                                    |
//+------------------------------------------------------------------+
COrder::COrder(ENUM_ORDER_STATUS order_status,const ulong ticket)
  {
//--- Save integer properties
   m_ticket=ticket;
   m_long_prop[ORDER_PROP_STATUS]                              = order_status;
   m_long_prop[ORDER_PROP_MAGIC]                               = this.OrderMagicNumber();
   m_long_prop[ORDER_PROP_TICKET]                              = this.OrderTicket();

Hello Artyom,

can we use:

m_long_prop[ORDER_PROP_TICKET] = (long)ticket; // ticket is the parameter passed in.

 
Ming Ge # :
this . OrderTicket ();

If

 this . OrderTicket ();

returns the value of m_ticket set above, then it is possible.

But I wrote this so long ago that I can’t remember right away.

I looked. This method writes the ticket to the order property:

 //+------------------------------------------------------------------+
 //| Возвращает тикет                                                 |
 //+------------------------------------------------------------------+
 long COrder::OrderTicket( void ) const 
  {
 #ifdef __MQL4__
   return ::OrderTicket();
 #else
   long res= 0 ;
   switch ((ENUM_ORDER_STATUS) this .GetProperty(ORDER_PROP_STATUS))
     {
       case ORDER_STATUS_MARKET_POSITION   :
       case ORDER_STATUS_MARKET_ORDER      :
       case ORDER_STATUS_MARKET_PENDING    :
       case ORDER_STATUS_HISTORY_PENDING   :
       case ORDER_STATUS_HISTORY_ORDER     :
       case ORDER_STATUS_DEAL              : res=( long )m_ticket;  break ;
       default                             : res= 0 ;               break ;
     }
   return res;
 #endif
   }

Decide for yourself whether you need to replace it with a simple assignment or not.