Download MetaTrader 5

Discussion of article "A Virtual Order Manager to track orders within the position-centric MT5 environment"

To add comments, please log in or register
MetaQuotes Software Corp.
Moderator
182441
MetaQuotes Software Corp. 2010.05.13 10:00 

New article A Virtual Order Manager to track orders within the position-centric MT5 environment is published:

This class library can be added to an MT5 Expert Advisor to enable it to be written with an order-centric approach broadly similar to MT4, in comparison to the position-based approach of MT5. It does this by keeping track of virtual orders at the MT5 terminal, while maintaining a protective broker stop for each position for disaster protection.

Figure 7. Two EAs with opposing virtual orders and no position is open at the broker

Author: Paul

investeo
4100
investeo 2010.05.13 13:22  
I have been waiting for that article, thanks.
Eric
153
Eric 2010.05.13 20:21  

Really nice article

Bravo 

Wackena
648
Wackena 2010.05.14 18:37  

There seems to be a flaw with VOM.

I loaded the FraMA Cross EA VOM.mq5 EA to EURUSD H1 chart and manually opened a Sell order.  With the open sell order, there is no Comment() on chart. Pic attached.

/+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
// Need to include this line in all EAs using CVirtualOrderManager  
   VOM.OnTick();
   Comment(VOM.m_OpenOrders.SummaryList());


I also tested this Comment() in EA with 1 open sell order and Comment line on chart was "Open Orders = 0".

/+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
// Need to include this line in all EAs using CVirtualOrderManager  
   VOM.OnTick();
   Comment("Open Orders = ",VOM.OpenOrders());




Files:
Paul
784
Paul 2010.05.15 03:44  
wackena:

There seems to be a flaw with VOM.

I loaded the FraMA Cross EA VOM.mq5 EA to EURUSD H1 chart and manually opened a Sell order.  With the open sell order, there is no Comment() on chart. Pic attached.


I also tested this Comment() in EA with 1 open sell order and Comment line on chart was "Open Orders = 0".




 

That's correct, wackena.  What you have done is to go direct to the server to with a conventional order, so there is no virtual order open.  You would need to use the VirtualOrderManagerTester to issue a manual virtual order.

 I should have made it clear in the article that if a VOM EA is introduced on a particular symbol, then all other EAs trading that symbol must also be VOM-enabled.  This is because of the Disaster Protection SL code in the VOM.

 Paul 

 

Wackena
648
Wackena 2010.05.15 16:35  
phampton:

 

That's correct, wackena.  What you have done is to go direct to the server to with a conventional order, so there is no virtual order open.  You would need to use the VirtualOrderManagerTester to issue a manual virtual order.

 I should have made it clear in the article that if a VOM EA is introduced on a particular symbol, then all other EAs trading that symbol must also be VOM-enabled.  This is because of the Disaster Protection SL code in the VOM.

 Paul 

 

Thanks Paul.

Can the VirtualOrderManager.mqh be used in the MT-5  Strategy Tester? If yes, how should the EA be setup with VOM?

Paul
784
Paul 2010.05.15 18:20  
wackena:

Thanks Paul.

Can the VirtualOrderManager.mqh be used in the MT-5  Strategy Tester? If yes, how should the EA be setup with VOM?

Yes, my very limited testing in the ST indicates that it works with no alteration, although slowly because each tick must be processed.
Wackena
648
Wackena 2010.05.16 20:59  

Been working with VOM on Martingale type EA. With multiple Sell trades open, same type and currency pair, this CloseAllOrders function appears to only close last trade, leaving previous trades still open.

VOM.CloseAllOrders(_Symbol,VIRTUAL_ORDER_TYPE_SELL);

With multiple, same type and currency pair, virtual orders (vo) open, should this function code initiate closing of one vo order or should function close all open vo orders.

VOM.OrdersTotal() does track number of open vo orders quite well.


Paul
784
Paul 2010.05.17 13:24  
wackena:

Been working with VOM on Martingale type EA. With multiple Sell trades open, same type and currency pair, this CloseAllOrders function appears to only close last trade, leaving previous trades still open.

With multiple, same type and currency pair, virtual orders (vo) open, should this function code initiate closing of one vo order or should function close all open vo orders.

VOM.OrdersTotal() does track number of open vo orders quite well.

Hi wackena,

I've just added a Close all button to VirtualOrderManagerTester, see attached.  It works OK, although I admit it's a clunky way to close all virtual orders - a better way would be to sum them up and issue a single server order, and I'll look at doing that in the next release.

Feel free to send me a copy of a LOG_VERBOSE EA log so I can see better what's happening.

 Paul 

 

Wackena
648
Wackena 2010.05.17 16:07  
phampton:

Hi wackena,

I've just added a Close all button to VirtualOrderManagerTester, see attached.  It works OK, although I admit it's a clunky way to close all virtual orders - a better way would be to sum them up and issue a single server order, and I'll look at doing that in the next release.

Feel free to send me a copy of a LOG_VERBOSE EA log so I can see better what's happening.

 Paul 

 

Attached is the log file.
Files:
Paul
784
Paul 2010.05.17 17:26  
wackena:
Attached is the log file.

 

Thanks - from what I can tell in the log, the only calls to OrderClose occur when a virtual takeprofit has been hit, ie whatever code you have to explicitly close orders (like a CloseAllOrders) isn't being reached or is being reached when there are no orders left to close.

123
To add comments, please log in or register