Description of Price Action Engulfing Candles Strategy

Forums Strategies and Expert Advisors Price Action Engulfing Candles EA Description of Price Action Engulfing Candles Strategy

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 87 total)
  • Author
    Posts
  • #4474
    DominikDominik
    Administrator

    Hello everyone! As I promised, I will try to present you my automated Price Action strategy trading on the Forex market. Please note that the strategy is under development and is not a final product. I put it here for further testing and will try to tell you what is the idea and principle of functioning. I will try to change later descriptions of parameters, but for now let them be such as they are, because all the saved settings for each currency pair also need to be changed, and I don’t have time for that now.

    I’m not a poet but a trader and a programmer, so I go straight to the point :) If there will be any inaccuracies I will explain it later. The main principle of the strategy is to discover points of retracements (I call them temporary reversals) and points of reversals (changes of the whole long-time trend). My strategy is based on pattern which was created based on the idea of engulfing pattern, but slightly modified. I will explain in a moment, because at this point, for those who don’t know what is engulfing pattern I recommend to read this: https://vantagepointtrading.com/archives/10856

    In this description and the whole strategy I count candles backwards and current candle (not closed) is always candle number 0, the previous is 1, etc. That seems to be the most logical way, especially from the point of view of the programmer. Please imagine that we add to “engulfing pattern” one more candle at the end, which will be our candle number 0 and which confirms last one from enguling pattern. So, both two last candles (current 0 and previous 1) must be in one direction and last candle (0) must exceed maximal or minimal value of wick (shadow) of previous candle (1). Of course, maximal value when new trend is UPward, minimal if is DOWNward. Another difference in this pattern (compared to engulfing pattern) is that the engulfing candle (1) don’t have to be bigger than the previous candle (2), because it is sufficient that both last candles (1 and 0) engulf candle 2. And almost last principle to this pattern, if between candle number 1 and candle number 2 there is a really small candle (also doji, pin-bar and every other used names) – we must ignore it (I mark it as “x”). It would be best to explain with an example. Let’s consider this for the case of a new uptrend (after changing from downtrend). Of course, the first candle in the pattern must be downward (candle number 2) and another – upward (candle number 1). The value of the current candle (0) must be above the highest value of the previous candle (1) and ALSO above highest value of candle 2. If it is still difficult to understand I’ll show you on the screenshots:

    As you can see value of candle 0 was above highest value of candle 1 and candle 2. It was enough to trigger the order. I marked this value with the horizontal line.

    I tested different configurations of this pattern. I have compared different schemes and relationships between the candles, between their close, open, high and low values and positions and the relationships of these positions compared to each other. As a result, I recieved the one pattern about which I write you as the most effective of all the others (with good filtering I get with this pattern, for example for EURUSD on timeframe M5, over 95% profitable trades during over 15 years).

    OK, so pattern is only one thing among many others. One of them is appropriate filtering patterns in order to avoid false patterns. I think I’ll start from demand and support zones. I don’t want to bore you with too much theory from the very beginning, so let’s say that we won’t use the term of “supply and demand zone”. We will use “room to the left” instead. A few years ago I found very interesting video in part similar to my theory and strategy. I encourage you to see it. There is also the concept of “room to the left” or “space to the left”. Here is the link: https://www.youtube.com/watch?v=t-pD3fap25c

    “Room to the left” in my strategy is counted from highest high or lowest low (whether we are after change in the trend from upward to downward or from downward to upward) of specified number of candles counted from current candle and that number is different for each currency pair. The minimum distance from the extreme (bottom of our candle “x” on screenshot) to the last such value in the past is very important and also depends on the characteristics of a given currency pair. From my research, the absolute minimum is 25 candles – if you want to open many short-term transactions with small profit (it’s also good for automated trading).

    Next parameter which filters out bad patterns in my strategy is “Highest_Candle_From_3” and it defines if the sum of the real bodies of current (0) and previous (1) candle is higher than real body of 3rd candle. This setting is required only for certain currency pairs. As well as another parameter in strategy “Third_Candle_smaller” which filters out when real body of candle number 4 is smaller than the sum of the real bodies of current (0) and previous (1) candle. Name of parameter is misleading, so I will change later name of parameter to “Fourth_Candle_smaller”, sorry for the wrong nomenclature, but as I said it’s development version. Anyway, this parameter as previous one is also required only for some currency pairs and we will talk about it later. It’s not 100% necessary, but I wanted to say about it while we are on the topic of pattern.

    I added to the system 4 another parameters with which we can set the minimal and maximal sizes of the candles with number 2 and 3. Especially minimal size is very important, because for many currency pairs if real body of candle number 2 or 3 is small – pattern just doesn’t work. For all who would like to test the strategy manually I recommend to ignore such small candles or just wait for a new opportunity with next pattern, especially when there are two consecutive small candles.

    At the end of the today’s part of description I will show you two screenshots which contain the list of all editable parameters which I will explain further in next post.

    Regards and have a nice Monday!

    P.S. For the newest version of EA search this topic from the end.

    #4513
    DominikDominik
    Administrator

    I’ll show you today one more thing. This is how looks the result of the optimized strategy. Currency pair is EURUSD, timeframe M5, period = over 5 years.

    Next part tomorrow!

    #4514
    DominikDominik
    Administrator

    Hi folks!

    I’ll start today again from theory, but soon we get to practice :) Before we go to opening, modifying and closing orders, setting TPs and SLs, I want to describe you first the rest of the parameters.

    So, to secure improper enters system, among others, uses two indicators. One of them is Average Directional Index, which provides information about strength of trend and second, Relative Strength Index – about direction of trend. In both cases, for testing purposes, we can use standard (most popular) periods, so I recommend 14 for ADX and 7 or 14 for RSI. Now, the most important issue here are levels of ADX and RSI. In both cases (ADX and RSI), we set only one level. For ADX it’s high level, above which system doesn’t open orders. And for RSI it’s low level below which system only opens BUY orders. High level for RSI is set automatically and it’s symmetrical to low level (high level=100-low level). System opens SELL orders only if value of RSI is above high level. I think it’s clear and obvious. If you don’t want to use these two indicators RSI and ADX as filters, simply set the RSI low level to 100 and ADX high level also to 100. I tested for this system also filtering low values of ADX, but it didn’t show any positive results, so I hid this option in the parameters. I tested also many other indicators and combination of indicators, but until now I haven’t found nothing interesting what is worth to use with this strategy. If you have some ideas please let me know and we will talk about it.

    Next filters (at the end on parameter list) refer to the trading hours for each day and trading days. I used this filter, because depending on the currency pair, we can multiply profits by turning off opening orders by system on Mondays and Fridays (or just Mondays or Fridays). Interesting, isn’t it? This is due to the different behavior of the market for a given currency pairs just after the weekend (the market needs to stabilize) and before the weekend (market calms down, many large orders are closed etc). If we want to trade also on Mondays and/or Fridays it would be that we lose more than we gain, because of the “fake” market behavior, false retracements, reversals, breakouts, etc. And similar situation may happen, for example, after the close of New York, and before London opening. Each period of time for each trading session is unique. As a curiosity, I suggest you to search and read about trading strategy called London Open Breakout. I also have one strategy and theory about it, but there’s no time for that now and in this topic.

    Ok, let’s go further. I’ve decided some time ago to change algorithm of opening orders in system. Previously system opened only market orders, which was executed immediately. I’ve changed that to pending orders, which gave surprisingly good results. Now, when every other conditions are met, system places BUY STOP or SELL STOP order specified value of points (point = pip/10) above highest high or below lowest low of specified number of candles back. There are two parameters which define that. First is “Candles_To_Take_To_Stop”, which defines from how many candles take highest high (for BUY STOPs) or lowest low (for SELL STOPs). Second parameter is “Stops_Distance_from_Extreme”, which defines how many points higher than highest high (BUY STOPs) or how many points lower than lowest low (SELL STOPs) will be placed pending order. Both of these parameters are very closely dependent on the characteristic and behavior of the specified currency pair. If we want to make it work perfectly, it must be very well optimized. And before I’ll show you example on screenshot I want to write about one more parameter, which is “Buy_Sell_Stop_Expiration”. Just like the previous two parameters, this also must be optimized individually for a given currency pair and it defines after how many seconds the order expires. Please remember that if we’re using system on M5 timeframe each one candle = 300 seconds. And 12 candles = 1 hour = 3600 seconds. Let’s see example.

    As you can see on screenshot, pending order BUY STOP was placed when the value of candle 0 has reached and exceeded highest value from candle number 1 and 2 (and about this I’ve already written in a previous post). BUY STOP was placed according to our parameters that we have set, so specified value above highest high taken from specified amount of candles. I will explain it in more detail: order has changed from pending BUY STOP to market BUY order in that place where you see red arrow. The green candle below red arrow triggered BUY STOP order, because its value was higher than “Stops_Distance_from_Extreme” (150 points) from highest value of “Candles_To_Take_To_Stop” (3 candles). Of course, expiration time wasn’t exceeded and pending order was still awaiting until the time when finally has been triggered… and in this simple way we have opened BUY order :) What could happen next I will write in next part of description.

    Take care and have a nice Wednesday!

    #4515
    Avatarvelasju79
    Spectator

    Dominic, you have very deep knowledge of candle techniques. I am highly impressed about your system, its fully customizable and very flexible to the way almost every single parameter can be set :D . Your EA is already way above most other robots available on the market and i would be very happy to some help in testing the EA. Great stuff, really. TP should always be 2-3x greater than SL over the long run. Could you upload a detailed statement from a backtest? Thanks a lot, Andreas (skype.buba)

    #4516
    DominikDominik
    Administrator

    Hi my friend. Thanks. I will only write description to the end and then I will upload all files: expert advisor, all the optimized settings that I have for each currency pair (based on different backtests) and so on. I will explain also how to efficiently test the system and which parameter change in which way to have intended effect. I will try to make last part of description today and to describe last assumptions of the system :)

    #4517
    DominikDominik
    Administrator

    Hi everyone!

    Today I’ll show you another parameters of system, which define where to put Take Profit, Stop Loss and how to protect from unwanted trades. The principle of functioning is based on Supply and Demand Zones (or Support and Resistance Levels). No matter what is the terminology, because it works the same – we just see on chart tops and bottoms and these are our potential levels for putting TPs and SLs.

    System has two parameters which decide where to put TP. First (“Candles_To_Take_To_TP”) defines how many candles we want to take from the past to find extreme and second (“TP_Distance_from_Extreme”) defines distance in points from highest high or lowest low to put TP. If value of distance is positive then TP is over highest high for BUY orders and below lowest low for SELL orders. If value of distance is negative, TP is below highest high for BUY orders and above lowest low for SELL orders. Let’s see on screenshot:

    For Stop Loss is very similar. “Candles_To_Take_To_SL” defines how many candles from past we want to check to find extreme value of highest high for SELL order or lowest low for BUY order. And “SL_Distance_from_Extreme” defines distance to put SL from highest high or lowest low value. For BUY orders, SL is below lowest low value if this parameter is positive, if negative – SL is above lowest low. For SELL orders, SL is above highest high for positive values and below for negative values of this parameter. Let’s see on example:

    I will explain one more parameter being in topic of SL – “Max_SL”. This parameter defines maximal distance in points between BUY or SELL STOP and SL to open the order. We don’t want to risk much more than we can earn (Risk to Reward ratio), so we don’t want to open orders when price is far away from SL. This parameter can be changed in future to work on the basis of proportions instead of constant value.

    In order to protect against opening unwanted orders by the system I’ve coded another three parameters. “Candles_To_Take_To_Extreme” defines, as always, how many candles we take from the past to find extreme value (HH for BUY, LL for SELL) and “Min_Stop_Distance_To_Extreme” defines minimal distance between BUY STOP and highest high or SELL STOP and lowest low. In simple words, if distance between BUY or SELL STOP and long-term top or bottom on chart is too small, we don’t want to risk opening order for a small profit, also with low probability. Last parameter from these three, “Min_Stop_Distance_To_TP”, works similar, but instead distance between STOP and long-term HH or LL value it calculates distance between STOP and Take Profit. And again, it protects system from opening orders which are too close to Take Profit, which in most cases is on last top or bottom (so it’s support or resistance level), and because price is almost there we don’t want to risk and wait if price can push through it or just bounce from that level and go in an undesired direction. I think it’s clear and understable enough and I don’t need to show it on screenshot.

    Tomorrow, I will try to make next part. Regards!

    #4518
    DominikDominik
    Administrator

    Today next part of description, this time, among others, about protecting profits. If the price moved in the expected direction and opened order became profitable we want to secure current profit (at least for transaction costs). System has got 2 algorithms for this purpose and both work in the same way – by moving Stop Loss.

    First algorithm “BE” (Break Even) uses two parameters. “BE_Min_Distance_from_Price_To_Modify_Order”, which defines minimal distance in points between current price and price of opened order to put new Stop Loss, and second “BE_Distance_from_Open_Order_Price”, which defines distance in points from current price to put new Stop Loss. Example, if we have BUY order and current price is above open price for that order more than minimum distance set in first parameter, system puts new Stop Loss amount of points from second parameter below current price. I think it’s simple. This works like a regulated Break Even, but we can use it also as a tool to achieve profits quickly on short-term transactions. “BE” works only once on specified transaction, it puts new Stop Loss only once and in a further steps the transaction is managed by second algorithm “SL_Follow”.

    Second algorithm “SL_Follow” works as Trailing Stop Loss and it starts to work just after first new Stop Loss is put by “BE” algorithm. “SL_Follow” has 2 parameters, which are similar to “BE”. Parameter “SL_Follow_Min_Distance_from_SL” defines how far from current Stop Loss price must be to put new Stop Loss. Second parameter “SL_Follow_Points_from_Price” defines how many points from current price will be put new Stop Loss. Of course, “SL_Follow” moves Stop Loss only in direction of profits and doesn’t move back.

    At the end, I quickly explain first parameters on the list of parameters. “Lots_To_Margin_Percent” defines size of transaction in proportion to available margin on account. For “Lots_To_Margin_Percent” equal to 10, system opens orders in size of 0.01 lot for each 100 your base currency (€, $, £ etc.). For example, if you have 1000$ available on your account and this parameter is set to 10, your order will be opened in size of 0.10 lot. Second parameter on the list, “Max_Spread_To_Trade” defines maximal spread at which system can open orders. Third parameter, “Slippage”, I hope, that is well known and I don’t have to explain. Fourth parameter “Trading” must be set to “True” if we want to allow the system to trade automatically. Another parameters on the list determine if we want to recieve alerts, e-mails and notifications from the system.

    Next part of description with files etc. soon ;)

    Have a great Saturday!

    #4519
    AvatarTobias6444
    Spectator

    @Dominik wrote:

    Hello everyone! As I promised, I will try to present you my automated Price Action strategy trading on the Forex market. Please note that the strategy is under development and is not a final product. I put it here for further testing and will try to tell you what is the idea and principle of functioning. I will try to change later descriptions of parameters, but for now let them be such as they are, because all the saved settings for each currency pair also need to be changed, and I don’t have time for that now. (…)

    Good ! For me, your strategy should be called “2 Candles Engulfing”.

    #4520
    DominikDominik
    Administrator

    @sangnakhon wrote:

    Good ! For me, your strategy should be called “2 Candles Engulfing”.

    Thanks. Yeah, it’s also good name :) I will try to upload today file with strategy with small description and then I will start placing optimization results with settings files for specified currency pairs.

    #4521
    DominikDominik
    Administrator

    As I promised, file with full version of Expert Advisor is in attachement. This copy of product will work till the end of August and after that time I will put another copy.

    I show you now how to use it. First, you must download .ex4 file and save in directory where your terminal is keeping Expert Advisors. If you don’t know where is that directory – you can find it in a few simple steps. Open MT4 terminal and choose “File” -> “Open Data Folder”. Now go to “MQL4” -> “Experts” and put downloaded file there. You can now refresh list in “Navigator” window (Ctrl+N) and you will see “Price Action EA” in “Experts Advisors”. If you want to test strategy you must open “Strategy Tester” (Ctrl+R) and then set all the parameters. Here you have some instructions how to do it:
    http://www.investopedia.com/university/forex-software-metatrader-4-advanced-guide/strategy-testing-and-optimization.asp
    and also:
    http://www.easyexpertforex.com/backtesting-optimization.html

    If you want to trade you can just simple attach “Price Action EA” to the chart of currency pair that you want to trade. You must remember that strategy will work only when you let it trade. In order to do it you must select “Allow automated trading” in “Options” window – Ctrl+O and “Expert Advisors” tab (or “Tools” -> “Options” -> “Expert Advisors”):

    Second place where you must turn on automated trading is option “Allow live trading” in parameters of Expert Advisor. You can make it while attaching Expert Advisor to the chart or after that just by pressing F7.

    Third place is icon with text “AutoTrading” in main window of MetaTrader 4 (Ctrl+E):

    Fourth place is on parameters list (“Inputs”) of Expert Advisor. You must set “Trading” to “true”:

    If you have turned on auto-trading in all places you should see smiley face in the upper right corner of your chart window.

    If anything about functioning of Meta Trader 4 is unclear please, before asking, just google it. Google knows everything ;)

    All the settings for each currency pair will be in different topics on this forum: https://theinvestbay.com/viewforum.php?f=3

    #4522
    DominikDominik
    Administrator

    Hi! I’ll show you how result of optimization looks like when we switch on/off Mondays and Fridays.

    That example below is for EURUSD pair on M5 timeframe.

    Second result on the list (pass number 1) is the best… why? Mondays and Fridays are excluded from trading plan, so number of total trades is the lowest (so the commission for a broker also), profit factor is over 2 times higher than in first result on the list (when system trades also on Fridays, pass number 3). Drawdown is acceptable in this case, because on this example used lot size was higher than standard. Test was made on period: 2000-2016.

    #4523
    DominikDominik
    Administrator

    If you already know theory you can take a look here for continuation of work on the system, on example of customization parameters for first currency pair, which is EURUSD on M5 timeframe:

    https://theinvestbay.com/viewtopic.php?f=3&t=3&p=37#p37

    All ideas are welcome!

    #4524
    DominikDominik
    Administrator

    New version of Expert Advisor released!

    I added parameter “MagicNumber” to the code (https://www.mql5.com/en/articles/1359).
    I also optimized the code a little bit. And I’m working further on improving EA.

    Regards!

    #4525
    DominikDominik
    Administrator

    Hi!

    I’ve just released new version of EA. All parameters on the list have been ordered and categorized in order to simplify optimizing and testing process. List has become much clearer and optimizing – much faster. Below are screenshots with new list:

    As you can see there are several new parameters implemented which I’ll explain:

    1) One_Candle_Engulfing – set to “True” triggers buy/sell stop orders only when body of 1st candle completely engulfs body of 2nd candle.
    2) Highest_Candle_from_6 – same as Highest_Candle_from_3, but compares the size of sum of 0+1st candle to sizes of 2nd, 3rd, 4th, 5th and 6th candle (in simple words, 0+1 must be bigger than 2, 3, 4, 5 and 6).
    3) Min_Size_of_0 and Max_Size_of_0 – the minimum and maximum size of current (not closed) candle.
    4) Min_Size_of_1st and Max_Size_of_1st – the minimum and maximum size of previous candle (it’s first candle in new direction).
    5) ADX_Low_Level – minimum level at which orders are triggered.

    Lets say that previous versions were beta versions and this one deserves to be called: version 1.0! :)

    From now current version will be always available to download at the bottom of first post in this topic (and also in the post with description of new version).

    Regards and have a nice Tuesday!

    P.S. In the next post I will explain how to test Expert Advisor, with which combinations of parameters etc.

    #4526
    Avatarxdrbgr
    Spectator

    Well, we have tested only the penultimate version …. Getting back testit new! We are waiting for clarification on the test blocks.

Viewing 15 posts - 1 through 15 (of 87 total)
  • The topic ‘Description of Price Action Engulfing Candles Strategy’ is closed to new replies.