Discussion of article "Implementing a Scalping Market Depth Using the CGraphic Library" - page 4

 
"Each such class has a common parent, the CNode class, which performs only one function, i.e. stores the type of the basic primitive. 
Its only protected constructor requires type specification during element creation." 

CNode class doesn't stores the type of the basic primitive.   CEIChart does by m_obj_type member.

Thanks Vasiliy

 

In new builds of the terminal (approximately since version 2170) there appeared a problem with the sources of the article ("Writing a scalper's glass").
In particular, the main file"MarketBook.mq5" generates critical errors during compilation:

' Event' - unexpected token, probably type is missing? MBookBtn.mqh 57 12

' Event' - function already defined and has different type MBookBtn.mqh 57 12

Could you please tell me what is wrong and how to fix it?


P.S. now checked"MarketBook.mq5" from an old article from 2015. It turned out that the same kind of errors occur with that project:

'Show' - unexpected token, probably type is missing? MBookFon.mqh 47 11
'Show' - function already defined and has different type MBookFon.mqh 47 11

 
avento:

In new builds of the terminal (approximately since version 2170) there appeared a problem with the sources of the article ("Writing a scalper's glass").
In particular, the main file"MarketBook.mq5" generates critical errors during compilation:

' Event' - unexpected token, probably type is missing? MBookBtn.mqh 57 12

' Event' - function already defined and has different type MBookBtn.mqh 57 12

Could you please tell me what is wrong and how to fix it?


The language is developing and the requirements are getting stricter.

Let's look at the file "MBookBtn.mqh", the declaration of the CMBookBtn class - the function Event is declared as void

//+------------------------------------------------------------------+
//|| The class represents the button at the top of the graph, which, when clicked |
//| A panel with a tick chart and a table of orders is displayed. ||
//| Pressing the button again hides the panel. ||
//+------------------------------------------------------------------+
class CMBookBtn : public CElButton
  {
private:

   CMBookArea        m_book_area;
   bool              m_showed_book;
public:
                     CMBookBtn();
   void              SetMarketBookSymbol(string symbol);
   void              Refresh();
   void              Event(int id,long lparam,double dparam,string sparam);
   void              Clear(void);
   virtual void      OnShow(void);
  };

and now we look at the function itself in the class:

function already defined and has different type

the second error says "'Event' - function already defined and has different type MBookBtn.mqh 57 12" - that is, the function was declared with type void and here it is without specifying the type.


Cure:

//+------------------------------------------------------------------+
//|| Intercept the mouse click on our button. If the button after |
//| click in the pressed state - show the panel. If in the || state
//| pushing down - hide the panel|
//+------------------------------------------------------------------+
void  CMBookBtn::Event(int id,long lparam,double dparam,string sparam)
  {

- just add void before the function in the class body.


Now compile the ... Indicators\MarketBookArticle\MarketBook.mq5 - there are no errors and run it: the glass works.

 
Lucas:
The whole code, when I copy and paste it to compile, gives an error when compiling. Does anyone know of a solution?

Lucas, if the error is related to an unexpected token in the CMBookBtn class, the call to the CMBookBtn::Event function must be preceded by void.


That's what we had for the moment.

 
Vladimir Karputov, thank you very much for such a thorough reply!
 

Hi Vasiliy, thank you for your beautiful article. I'm new in the MQL5 world and I'm facing a challenge in order to try to run your code locally. I believe it is a very silly problem, but I'm not being able to solve it

When I try to compile your code from MarketBook.mq5 I got the error as you can see below.

Can you please help me solve this problem?

 
This is the error I'm facing. Can you help me?
Files:
Error.jpg  365 kb
 

Hello.

Can you please tell me if it is possible to fix - remember the time of the found index in the MarketBook.mqh class?

void Calculation(void)
   {
      // FOR ASK SIDE
      int begin = (int)m_book.InfoGetInteger(MBOOK_LAST_ASK_INDEX);
      int end = (int)m_book.InfoGetInteger(MBOOK_BEST_ASK_INDEX);
      //m_ask_best_index
      for(int i = begin; i <= end && begin !=-1; i++)
      {
         if(m_book.MarketBook[i].volume > m_max_ask_volume)
         {
            m_max_ask_index = i;
            m_max_ask_volume = m_book.MarketBook[i].volume;
         }
         m_sum_ask_volume += m_book.MarketBook[i].volume;
      }
      // FOR BID SIDE
      begin = (int)m_book.InfoGetInteger(MBOOK_BEST_BID_INDEX);
      end = (int)m_book.InfoGetInteger(MBOOK_LAST_BID_INDEX);
      for(int i = begin; i <= end && begin != -1; i++)
      {
         if(m_book.MarketBook[i].volume > m_max_bid_volume)
         {
            m_max_bid_index = i;
            m_max_bid_volume = m_book.MarketBook[i].volume;
         }
         m_sum_bid_volume += m_book.MarketBook[i].volume;
      }
      m_calculation = true;
   }

In this method we find the price index on which the maximum volume on the Ask and Bid sides is located.

I also want to know at what terminal time we got this index.


The structure of the stack

struct MqlBookInfo 
  { 
   ENUM_BOOK_TYPE   type;            // request type from the ENUM_BOOK_TYPE enumeration 
   double           price;           // price 
   long             volume;          // volume 
   double           volume_real;     // volume with increased accuracy 
  };


Gives us 4 parameters, but there is no time in it.


Who can guide me how to remember the time of the found index?

 
Konstantin Seredkin:

Hello.

Could you please tell me, is it possible to fix - remember the time of found index in MarketBook.mqh class ?

In this method we find the price index on which the maximum volume on the Ask and Bid side is standing.

I also want to know at what terminal time we got this index.


The structure of the glass


Gives us 4 parameters, but it doesn't have time.


Can anyone point me in the direction of how to remember the time of the found index?

inherit the structure and add an additional field to it to which you will add the tick time when filling it in

 
Konstantin Seredkin:

Hello.

Could you please tell me, is it possible to fix - remember the time of found index in MarketBook.mqh class ?

In this method we find the price index on which the maximum volume on the Ask and Bid side is standing.

I also want to know at what terminal time we got this index.

The structure of the glass

Gives us 4 parameters, but there is no time in it.

Who can point us in the direction of how to remember the time of the found index

There is no time, because the time of quote arrival in MQL5 cannot be learnt. The maximum that can be done is to remember the time at the moment of arrival of the OnBookEvent event, so remember it. Remembering the time of finding the tops of the stack is also pointless, you need the time of arrival of the price stack, not the time of finding its maximal index.