Discussion of article "MQL5 Cookbook: ОСО Orders"

 

New article MQL5 Cookbook: ОСО Orders has been published:

Any trader's trading activity involves various mechanisms and interrelationships including relations among orders. This article suggests a solution of OCO orders processing. Standard library classes are extensively involved, as well as new data types are created herein.

This article focuses on dealing with such type of order pair as OCO. This mechanism is implemented in some trading terminals competing with MetaTrader 5. I pursue two aims through the example of creation of an EA with a panel for OCO orders processing. On the one hand, I wish to describe features of the Standard Library, on the other hand I would like to extend a trader's tool set.


1. Essence of OCO Orders

OCO orders (one-cancels-the-other order) represent a pair of two pending orders.

They are connected by mutual cancellation function: if the first one triggers, the second one stays untouched, and vice versa.

Fig. 1 Pair of OCO orders

Fig. 1 Pair of OCO orders

Fig.1 shows a simple order interdependence scheme. It reflects an essential definition: a pair exists for so long as both orders exist. In terms of logic any [one] order of the pair is an essential but not sufficient condition for the pair existence.

Some sources say that the pair must have one limit order and one stop order, moreover orders must have one direction (either buy or sell). To my mind such restriction cannot aid in creation of flexible trading strategies. I suggest that various OCO orders shall be analyzed in the pair, and most importantly we shall try to program this pair.

Author: Dennis Kirichenko

 

Thank you for this interesting article.

  • There is a translation issue in point 1.

They are connected by mutual cancellation function: if the first one triggers, the second one stays untouched, and vice versa.

The second should be removed if the first is triggered, not "untouched".

  • The way to process the deletion of the second order with OnTrade/OnTradeTransaction is not reliable enough. It can happens that the need event is not received at all, or received and not processed :

Besides, transactions can be lost during delivery from the server to the terminal.

and

Transactions queue length comprises 1024 elements. If OnTradeTransaction handles a new transaction for too long, the old ones in the queue may be superseded by the newer ones.

So it's better to add a protection proceedings to avoid big surprise if your second pending order is not removed.

 

angevoyageur, thank you for your comments!  You're talking business as always :-)

As for the translation - yes, there's a blunder.

As for the deletion of the untriggered order in the body of the Trade event-handler - yes, the additional checking should be exploited, e.g. in the body of the NewTick event-handler.


 

I know this is an old thread but I really want to use this. I downloaded the zip file but I have no idea how to make this work., Some assistance on compiling this would be great.


Thank You

 

Your article is intéressant.  Thanks to people like you beginners can progress and maybe someday start trading . Thanks

 

I just downloaded all the zip files but i need help with the instraction on  how to make them work or install

 
vijanda:

I just downloaded all the zip files but i need help with the instraction on  how to make them work or install

You have to create a folder where all the relevant files will reside. After creation just copy the files into the folder.  For example:


oco_files


After compilation you will find the expert file in the MT5 Navigator.


oco_files_mt5


Much time has elapsed since the article publication. But the code runs fine. Build 1981.

 
I followed all the instructions but the OCO Folder is not showing on my MT5 Navigator I even tried refreshing it
Reason: