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-/
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:
Head-and-Shoulderson Weekly EUR/AUD Chart
- Ascending Channel on Daily USD/CAD Chart
- Descending Channel on 4-Hour EUR/JPY Chart
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
Coding this EA presented some challenges in both MT4 and MT5. Unfortunately, I could not benefit from the
- 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-relatedcode 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-lossor take-profitof 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
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.