Discussion of article "MQL5 Cookbook: Handling BookEvent" - page 2

 
denkir:
Most likely you don't need a tumbler, but a market transaction handler.
Thank you very much!
 
I have read the article you mentioned, which is certainly also useful, but in my question I meant the possibility to read the actions on orders of other market participants, not those placed by a trader from his terminal. I.e. the filter I wrote about should be applied to current market operations. Does MetaTrader provide such information? I have not seen such possibilities in the stack event handler.
Рецепты MQL5 - обработка события TradeTransaction
Рецепты MQL5 - обработка события TradeTransaction
  • 2014.09.08
  • Dennis Kirichenko
  • www.mql5.com
В статье описываются возможности языка MQL5 с точки зрения событийно-ориентированного программирования. Преимущество данного подхода состоит в том, что программа может получать информацию о поэтапном выполнении торговой операции. Приводится пример того, как с помощью обработчика события TradeTransaction можно получать и обрабатывать информацию о совершаемых торговых действиях. Думаю, что такой подход можно смело применять для целей копирования торговых сделок с терминала на терминал.
 
Rubick:
...but in my question I meant the possibility to read actions on orders of other market participants, not those placed by a trader from his terminal. I.e. the filter I wrote about should be applied to current market operations. Does MetaTrader provide such information? I have not seen such possibilities in the stack event handler.
The stack shows all current limit orders that are on the market at the moment. What do you mean by the term "current market operations"?
 
denkir:
The stack shows all current limit orders that are on the market at the moment. What do you mean by the term "current market operations"?

I apologise if I have not explained it clearly. Let me try to elaborate a bit more. Look, in ENUM_BOOK_TYPE there are only four types of orders listed in the stack. They can be divided into two categories: limited and market. Now I will tell you how I understand the trade. I will warn you that I have doubts here, so if I understand something wrong, please correct me. So here it is. There are two groups of possible variants here.

  1. When a limited order meets a market order and a deal - Tick - occurs. Or two market bids meet and there is a deal - Tick.
  2. When two limited bids meet and the last of them leads to a deal - Tick.

The task I am considering is to filter the trades into two categories, 1st - those produced by limit bids, 2nd - those produced by market bids. What this is for is for me in private please. I can say that I have seen the implementation of such a filter, and by means of 1C! I was also very surprised when I saw it. But I liked the idea. And now, as I understand it is necessary to dock the OnTick handler with the OnBookEvent handler. How to do it, I have no idea, so I ask for your help.

 
Is it possible create a book event for forex market to see the pending orders? Naturally for a single liquidity provider.
 
BlackBart:
Is it possible create a book event for forex market to see the pending orders? Naturally for a single liquidity provider.
You need a broker which provides these informations.
 

"It is obvious that out of all sell orders, order #6 had the largest volume with the price of 7700 Rub and volume of 1011 lots. Order #39 had the largest volume out of all buy orders with the price of 7653 Rub and volume of 534 lots."

It is not order #6, neither order #39. These are levels, which can be accessed by

last_bookArray[6]

or

last_bookArray[39]

MqlBookArrays are comprised of sell offers from [0] to [ArraySize(bookArray)/2-1], and buy offers from [ArraySize(bookArray)/2] to [ArraySize(bookArray)-1]. As far as I know, books have 2n levels. And, if I am not wrong, levels start with index 0 (zero), so the mathematical mode (the highest volume, the most frequent sell offer) index is 5 (volume 1011, level/price 7700), whereas the buy offer mode is 38 (volume 534, level/price of 7653).

The buy offer mode could be taken as support. And the sell offer mode could be resistance.

I wish I could know how could I increase the number of levels...

 
Hi Denis ;

I have tried to use your indicator, the BookEventProcessor2.mq5., but when trying to compile it within the mql5 meta Editor, it gives me the following error, you could be kind enough to solve those little problems to see how it works in these times. Could you also tell me if it can also include the limit orders of sale and purchase at the same time but with another color.

regards,

Michael
Files:
 
mzapata6724:
Hi Denis ;

I have tried to use your indicator, the BookEventProcessor2.mq5., but when trying to compile it within the mql5 meta Editor, it gives me the following error, you could be kind enough to solve those little problems to see how it works in these times. Could you also tell me if it can also include the limit orders of sale and purchase at the same time but with another color.

regards,

Michael

Michael, thanks for your questions. First of all, BookEventProcessor2 is not an indicator - it is an Expert Advisor. All you need is to place the source and header files into one folder. Have a look at the attached pictures below.


If you'd like to change colors quickly go to the method CBookBarsPanel::Init() :

//+------------------------------------------------------------------+
//| Initialization                                                   |
//+------------------------------------------------------------------+
bool CBookBarsPanel::Init(const uint _width,const uint _height)
  {
//--- panel size
   this.m_width=_width;
   this.m_height=_height;

//--- allocate memory
   if(this.m_obj_arr.Reserve(this.m_arr_size))
     {
      //--- the memory management flag 
      this.m_obj_arr.FreeMode(true);
      //--- panel label
      CChartObjectRectLabel *ptr_rect_label=new CChartObjectRectLabel;
      if(CheckPointer(ptr_rect_label)==POINTER_DYNAMIC)
         if(ptr_rect_label.Create(0,"Panel",0,15,15,this.m_width,this.m_height))
            if(ptr_rect_label.BorderType(BORDER_RAISED))
               if(this.m_obj_arr.Add(ptr_rect_label))
                 {
                  //--- bar label 
                  uint curr_x=this.m_width/5;
                  uint curr_y=35;
                  uint mid_idx=this.m_arr_size/2-1;
                  for(uint idx=0;idx<this.m_arr_size;idx++)
                    {
                     color rec_color=(idx<(mid_idx+1))?clrRed:clrGreen;
                     //---
                     CBookRecord *ptr_record=new CBookRecord;
                     if(CheckPointer(ptr_record)==POINTER_DYNAMIC)
                        if(ptr_record.Create(IntegerToString(idx+1),rec_color,curr_x+15,
                           curr_y,curr_x*3,10))
                           if(this.m_obj_arr.Add(ptr_record))
                              curr_y+=(idx==mid_idx)?24:13;
                    }
                 }
     }

//---
   return this.m_obj_arr.Total()==(this.m_arr_size+1);
  }

Or you may slightly change the method parameters like this:

//+------------------------------------------------------------------+
//| Initialization                                                   |
//+------------------------------------------------------------------+
bool CBookBarsPanel::Init(const uint _width,const uint _height, const color _buy_clr, const color _sell_clr)
  {
//--- panel size
   this.m_width=_width;
   this.m_height=_height;

//--- allocate memory
   if(this.m_obj_arr.Reserve(this.m_arr_size))
     {
      //--- the memory management flag 
      this.m_obj_arr.FreeMode(true);
      //--- panel label
      CChartObjectRectLabel *ptr_rect_label=new CChartObjectRectLabel;
      if(CheckPointer(ptr_rect_label)==POINTER_DYNAMIC)
         if(ptr_rect_label.Create(0,"Panel",0,15,15,this.m_width,this.m_height))
            if(ptr_rect_label.BorderType(BORDER_RAISED))
               if(this.m_obj_arr.Add(ptr_rect_label))
                 {
                  //--- bar label 
                  uint curr_x=this.m_width/5;
                  uint curr_y=35;
                  uint mid_idx=this.m_arr_size/2-1;
                  for(uint idx=0;idx<this.m_arr_size;idx++)
                    {
                     color rec_color=(idx<(mid_idx+1))?_sell_clr:_buy_clr;
                     //---
                     CBookRecord *ptr_record=new CBookRecord;
                     if(CheckPointer(ptr_record)==POINTER_DYNAMIC)
                        if(ptr_record.Create(IntegerToString(idx+1),rec_color,curr_x+15,
                           curr_y,curr_x*3,10))
                           if(this.m_obj_arr.Add(ptr_record))
                              curr_y+=(idx==mid_idx)?24:13;
                    }
                 }
     }

//---
   return this.m_obj_arr.Total()==(this.m_arr_size+1);
  }
 

Hi Dennis


Thanks for soon reply, the expert advisor now is working pretty good.  But I was trying to talk about this reference:

When sending a trade request using the OrderSend() function, some operations require the indication of the order type. The order type is specified in the type field of the special structure MqlTradeRequest, and can accept values of the ENUM_ORDER_TYPE enumeration.

ENUM_ORDER_TYPE

Identifier

Description

ORDER_TYPE_BUY

Market Buy order

ORDER_TYPE_SELL

Market Sell order

ORDER_TYPE_BUY_LIMIT

Buy Limit pending order

ORDER_TYPE_SELL_LIMIT

Sell Limit pending order

ORDER_TYPE_BUY_STOP

Buy Stop pending order

ORDER_TYPE_SELL_STOP

Sell Stop pending order

ORDER_TYPE_BUY_STOP_LIMIT

Upon reaching the order price, a pending Buy Limit order is placed at the StopLimit price

ORDER_TYPE_SELL_STOP_LIMIT

Upon reaching the order price, a pending Sell Limit order is placed at the StopLimit price

ORDER_TYPE_CLOSE_BY

Order to close a position by an opposite one


I can see into the terminal of Mql5, that the exper advisor show ORDER_TYPE_BUY AND  ORDER_TYPE_BUY, but my question is you can show the transaccion in the bookevent about and change those color, because I know how to see the buy order, but wher is the big boss putting there money , with Iceberg and hug pending order at certain price level.


is that possible ???


best regards Michael. 

RDER_TYPE_SELL_LIMIT

Sell Limit pending order

ORDER_TYPE_BUY_STOP

Buy Stop pending order

Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
Documentation on MQL5: Constants, Enumerations and Structures / Data Structures / Trade Request Structure
  • www.mql5.com
Trade Request Structure - Data Structures - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5