Discussion of article "MQL5 Cookbook: Implementing Your Own Depth of Market" - page 5

 
Yes, different version. This 2015 article, contains the code from the second 2017 follow-up article https://www.mql5.com/en/articles/3336. Unfortunately, it is not compiled. For training purposes you can use the original code base from 2015, in it the price glass works without a chart. I have published the code above. As for the new version, it will take some time to fix it.
Пишем скальперский стакан цен на основе графической библиотеки CGraphic
Пишем скальперский стакан цен на основе графической библиотеки CGraphic
  • 2017.06.23
  • www.mql5.com
В статье создается базовый функционал скальперского стакана цен. Разрабатывается тиковый график на основе графической библиотеки CGraphic и интегрируется с таблицей заявок. С помощью описываемого стакана цен можно создать мощный помощник для краткосрочной торговли.
 
Vasiliy Sokolov #:
Unfortunately, it does not compile.

There are only a couple of errors in the code attached to this article.

In the MBookFon.mqh file, the method implementation is not defined correctly - void is missing:

void  CBookFon::Show(void)
{
   ObjectCreate(ChartID(), m_name, OBJ_RECTANGLE_LABEL, 0, 0, 0);
   ObjectSetInteger(ChartID(), m_name, OBJPROP_YDISTANCE, 13);
   ObjectSetInteger(ChartID(), m_name, OBJPROP_XDISTANCE, 6);
   ObjectSetInteger(ChartID(), m_name, OBJPROP_XSIZE, 116);
   ObjectSetInteger(ChartID(), m_name, OBJPROP_BORDER_TYPE, BORDER_FLAT);
   ObjectSetInteger(ChartID(), m_name, OBJPROP_BGCOLOR, clrWhite);
   int total = (int)m_book.InfoGetInteger(MBOOK_DEPTH_TOTAL);
   ObjectSetInteger(ChartID(), m_name, OBJPROP_YSIZE, total*15+16);
   CreateCeils();
   
   OnShow();
}


In the MBookCeil.mqh file, there is no check for array size and array overrun:

void CBookCeil::Refresh(void)
{
   int total = (int)m_book.InfoGetInteger(MBOOK_DEPTH_TOTAL);
   if(total == 0 || m_index < 0 || m_index > total-1)
      return;
   ENUM_BOOK_TYPE type = m_book.MarketBook[m_index].type;
   long max_volume = 0;
   if(type == BOOK_TYPE_BUY || type == BOOK_TYPE_BUY_MARKET)
   {
      ObjectSetInteger(ChartID(), m_name, OBJPROP_BGCOLOR, clrCornflowerBlue);
      max_volume = m_book.InfoGetInteger(MBOOK_MAX_BID_VOLUME);
   }
   else if(type == BOOK_TYPE_SELL || type == BOOK_TYPE_SELL_MARKET)
   {
      ObjectSetInteger(ChartID(), m_name, OBJPROP_BGCOLOR, clrPink);
      max_volume = m_book.InfoGetInteger(MBOOK_MAX_ASK_VOLUME);
   }
   else
      ObjectSetInteger(ChartID(), m_name, OBJPROP_BGCOLOR, clrWhite);
   MqlBookInfo info = m_book.MarketBook[m_index];
   if(m_ceil_type == BOOK_PRICE)
      m_text.SetText(DoubleToString(info.price, Digits()));
   else if(m_ceil_type == BOOK_VOLUME)
      m_text.SetText((string)info.volume);
   if(m_ceil_type != BOOK_VOLUME)return;
   double delta = 1.0;
   if(max_volume > 0)
      delta = (info.volume/(double)max_volume);
   if(delta > 1.0)delta = 1.0;   
   long size = (long)(delta * 50.0);
   if(size == 0)size = 1;
   ObjectSetInteger(ChartID(), m_name, OBJPROP_XSIZE, size);
   ObjectSetInteger(ChartID(), m_name, OBJPROP_YDISTANCE, m_ydist);
}

At the first run, when the price glass is not connected yet, the array size is zero and, accordingly, the critical error crashes.

 
I compiled the files, however there are still errors. Can someone share a working version please
 
startatrix #:
I have compiled the files but the errors remain. Can anyone share a working version please.
If compiled, there are no errors. If failed to compile, what are the errors?