Download MetaTrader 5

Discussion of article "Price Action. Automating the Engulfing Pattern Trading Strategy"

To add comments, please log in or register
Log in to using OpenID. It is convenient!
MetaQuotes Software Corp.
MetaQuotes Software Corp. 2015.09.22 12:49 

New article Price Action. Automating the Engulfing Pattern Trading Strategy has been published:

This article describes a process of creating an Expert Advisor for MetaTrader 4 based on the Engulfing pattern, as well as the pattern recognition principle, rules of setting pending orders and stop orders. The results of testing and optimization are provided for your information.

All Forex traders come across the Price Action at some point. This is not a mere chart analysis technique but the entire system for defining the possible future price movement direction. In this article, we will analyze the Engulfing pattern and create an Expert Advisor which will follow this pattern and make relevant trading decisions based on it.

We have previously examined the automated trading with Price Action patterns, namely the Inside Bar trading, in the article Price Action. Automating the Inside Bar Trading Strategy.

Rules of the Engulfing Pattern

The Engulfing pattern is when the body and shadows of a bar completely engulf the body and shadows of the previous bar. There are two types of patterns available:

  • BUOVB — Bullish Outside Vertical Bar;
  • BEOVB — Bearish Outside Vertical Bar.

Fig. 1. Types of pattern shown on the chart

Fig. 1. Types of pattern shown on the chart

Author: Dmitry Iglakov

Roberto Jacobs
Roberto Jacobs 2015.09.23 12:53  
Very useful.. Thanks a lot.. :D
ander_assoc 2015.10.04 22:01  
spent the part of Saturday optimization and back testing on some favorite pairs and found some great results, but there is one thing there a lot of negs in a row I had one that went 70+ negs in a row and it still double the acct size in my 9 week back testing periods , can you think of a setting for I can optimize to bring the number of negs. in a row down. nice ea I would like test this a little bit more
Shintsu 2015.11.24 11:15  
i'm a newbie and i tried to compilate this EA without success, can you make a video or make it someway more easier to install please? thank you very much.
Roberto Jacobs
Roberto Jacobs 2015.11.24 12:51  
i'm a newbie and i tried to compilate this EA without success, can you make a video or make it someway more easier to install please? thank you very much.
Actually there is no problem with the files beovb_buovb_bar.mq4
Click Attached files beovb_buovb_bar.mq4 below this article. (download)
and on the computer window will pop up questions like the image below,
Select Open with MetaEditor (default)
click Ok
and after the files
beovb_buovb_bar.mq4 was opened in MetaEditor MT4

Click Compile.


Abdullah Alrai
Abdullah Alrai 2015.12.24 23:06  
Very good article thank you very much
gburg14 2016.02.14 19:39  

This article was very helpful for me as a newbie too.

I noticed you included extern int Slippage = 2. I have a few questions about that.

I tested your EA with Slippage = 2, as well as 0, and got the same result. My demo account is with New York based FXCM, which uses a 5 decimal place point. OrderSend wants an int for its Slippage parameter and your EA doesn't modify the 2 in any way.

Does OrderSend interpret the 2 to equal 2 pips (.00020) or 2 tenths of a pip (.00002)? 

Does the backtesting process in a demo account even do anything with that extern int Slippage or does it ignore it? 

My next question is: what is the practical difference between slippage and the Deviation setting in Tools|Options|Trade? The default is 10 pips.  The User Guide describes this Deviation field:

  • The symbol price can change within the ordering time. As a result, the price of the prepared order will not correspond with the market one, and position will not be opened. The "Deviation" option helps to avoid this. Maximum permissible deviation from the value given in the order can be specified in this field. If prices do not correspond, the program will modify the order by itself what allows to open a new position.

MQL4 Reference|OrderSend describes the Slippage parameter:


[in]  Maximum price slippage for buy or sell orders."

Do the extern int Slippage code and the Deviation setting do the same thing? If so, why put the Slippage code in the EA? Is there a difference between how the MetaTrader and broker handle extern int Slippage = 2 and Deviation = 2 ? If they are different numbers does one take precedence over the other? Do I need that extern int Slippage code at all? If I can/should try to regulate the acceptable amount of slippage I think I'd rather do it in extern so I more easily change it in the parameters dialog rather than going into the Options|Trade tab. But what if the Deviation setting doesn't match the Slippage parameter?

Do either or both of these influence the result differently depending on whether it is a market order or a limit order or a stop order? 

Thanks for any insight  

tmailone 2016.03.15 21:40  

Do you have an indicator of this ? engulfing indicator that marks the bar puts a line for the stop and target

or or mutli time frame indicator of engulfing bars 

Tim Leoritzson
Tim Leoritzson 2016.10.20 21:01  
Good job on this EA Dmitry..I have been testing this EA on demo account for about a month now and results are quite good..But I have suggestion if you dont mind..I think it will be a good idea to add trailing stop feature to this EA so that we can let our winners run and cut losses short.Thank you for sharing this good EA.
GBWT094114 2016.10.23 16:38  
Very nice article, But the market is much more complex then this single pattern, today we have much more complex patterns that a human can't identify, and only a system that is built upon machine learning process will identify these patterns. That is what the big guys are doing with the smart money.
Alan Saunders
Alan Saunders 2016.12.09 00:17  
Hi Dmitry,  I enjoyed your article, thank you. I have developed my own Engulfing Candle strategy which takes the concept further forward. I am now looking for someone to code this for me as an EA robot for MT4. Would you be interested in writing this for me? If so i will send you the set-up info for you to look at. Regards, Alan Saunders
To add comments, please log in or register