Forex Blog

This blog offers fundamental analysis, technical analysis and various currency trading information.


New Expert Advisor Can Help You Trade Chart Patterns

March 7, 2013 (Last updated on July 24, 2013) by Andriy Moraru

After nearly two months of coding, testing, starting over and fixing bugs, I am finally happy to announce a release of my best EA to this date. Chart Pattern Helper is also one of the biggest programs I have ever written for MetaTrader. Unfortunately, it cannot detect chart patterns on its own. All it does is managing orders and positions based on the chart patterns drawn by a trader.

As you probably know, I trade mostly medium-/long-term Forex chart patterns (like channels and triangles). Sometimes they are created with the sloped trendlines and it can be really difficult to follow those trendlines for a breakout. There was a small discussion in our forum about this issue not so long ago and it became obvious that other traders struggle with this problem too. The only ready-made solution that I have found was LINEXCUTORS EA, which was quite different from what I needed.

The Chart Pattern Helper expert advisor precisely implements my trading style. It may seem useless to a lot of other chart pattern traders, but it is what I am using now. I have already tested it for trading these three patterns:

If you often trade channel patterns, trading with this EA can be made even easier with addition of this script.

The following screenshot shows the Chart Pattern Helper in action. It is the EUR/AUD weekly inverted H&S chart pattern trade. It has been already entered on a pull-back and now the EA is constantly adjusting its take-profit according to the current TP line position and the current spread, which is variable:
Chart Pattern Helper in live action

Coding this EA presented some challenges in both MT4 and MT5. Unfortunately, I could not benefit from the object-oriented nature of MQL5 this time because my primary goal was to create an expert advisor for MT4 as all my live trading happens only there. So I tried to keep the MT4-MT5 conversion process as simple as possible to easily transfer changes and bug-fixes from one version to another. Here is a brief list of disadvantages of both MT4 and MT5 code for Chart Pattern Helper:

  • In MT4, in most cases, it is impossible to get the value of the channel’s second line at a given time. Instead, it should be calculated using linear function formula. MT5 has no such problem as there is a native function to get channel’s second line’s value by shift.
  • There is no object renaming in MT4. You have to delete and create the object again if you want to rename one. While MT5 has a renaming function, there is another problem with objects — the object-related code is much bigger there.
  • Minimum order expiration time in MT4 is 11 minutes and it is not documented anywhere. Additionally, there may be a delay between calculation of proper expiration time and OrderSend()/OrderModify() execution, so some extra seconds should be added. Finally, if you want to change stop-loss or take-profit of the pending order with a set expiration time without changing that time, you will fail if it has less than 11 minutes left — you would have to update expiration time too. And that too is not documented in MQL Editor help files. Now you can imagine how frustrating MQL coding can sometimes be. In MT5, the minimum expiration time is 2 minutes and there is no need to update expiration time on orders if you want to modify something else.
  • MT4 cannot handle chart object change events. Unfortunately, you would need to wait for a new tick to arrive after moving your lines or channels for the changes to kick in. MT5 has nice chart event handlers for that.
  • Unfortunately, MT5 has no fast and convenient access to standard timeseries (Time, High, Low, etc.) You have to declare global variables (unless you are using classes) and update those arrays every tick. Also, I had to code a custom function to convert current timeframe to the number of seconds in a bar, whereas in MT4 each timeframe is presented by the number of minutes in a bar, which is easily converted to seconds.

Download this Forex expert advisor or read detailed information about it:

Update 2013-03-19: Due to a bug in the standard library of MetaTrader 5 Build 778, expiration will not work in MT5 version of Chart Pattern Helper. You can still use it in MT5 by disabling expiration via UseExpiration input parameter. This bug will likely be fixed in the next MetaTrader 5 update.

Update 2013-03-22: The MT5 bug has been fixed in build 787.

Update 2013-04-29: I have fixed a bug in MT4 version of this EA that would crash it many cases when horizontal channels are used for patterns. Download it again to get updated.

Update 2013-05-13: Fixed a bug in MT4 that would prevent EA from modifying TP level for open short position. Redownload to get the latest version of the expert advisor.

Update 2013-07-24: Improved stop-loss order placement. There is a new input parameter (PostEntrySLAdjustment) that will try to adjust SL level after position has been entered and breakout candle turned out to be mostly outside the pattern and thus not qualifying for being a stop-loss candle.

If you have any questions or some interesting thoughts regarding Chart Pattern Helper expert advisor, please feel free to post them using the form below.

Leave a Reply

required (will not be published)