Download MetaTrader 5
To add comments, please log in or register
Read the Forum and improve your rating!
MetaQuotes Software Corp.
MetaQuotes Software Corp. 2016.05.31 08:38 

New article Universal Expert Advisor: Pending Orders and Hedging Support (Part 5) has been published:

This article provides further description of the CStrategy trading engine. By popular demand of users, we have added pending order support functions to the trading engine. Also, the latest version of the MetaTrader 5 now supports accounts with the hedging option. The same support has been added to CStrategy. The article provides a detailed description of algorithms for the use of pending orders, as well as of CStrategy operation principles on accounts with the hedging option enabled.

The set of CStrategy classes keeps actively improving. New algorithms are being added to the engine to make trading even more efficient and simple. Further algorithm development mainly stems from the feedback of users who read this series of articles and ask questions in the article discussion topics or by sending personal messages. One of the most frequent questions was about the use of pending orders. Well, pending orders were not discussed in the previous articles, while the CStrategy engine did not provide a convenient tool for working with pending orders. This article introduces significant additions to the CStrategy trading engines. After all these changes, CStrategy now provides new tools for working with pending orders.

We will create a strategy that will be based on entries during strong market movements in the direction of the movement, so it will be called CImpulse. At the opening of each new bar, the EA will measure a predefined distance from the current bar, expressed as a percentage. The EA will place pending BuyStop and SellStop orders at an equal distance from the current price. The distance is set as a percentage. If one of the orders trigger within one bar, it means that the price has moved quite a long distance, which indicates the market impulse. The order will be executed and will turn into an open position.

Open positions will be managed by a simple moving average. If the price returns to the Moving Average, the position will be closed. The screenshot below shows a typical entry into a long position upon triggering of a pending BuyStop order:

Fig. 1. A long position of the CImpulse strategy.

Author: Vasiliy Sokolov

To add comments, please log in or register