Advertisements:

Chart Pattern Helper

Introduction

Chart Pattern Helper EA is not an automated trading robot. It has no trading strategy implemented inside. The only purpose of this expert advisor is to execute trades via pending orders based on some chart objects: trend lines, horizontal lines or equidistant channels. In addition to straightforward execution of breakout trades, it is also able to execute a pull-back trade with this EA if you have missed the breakout point for some reason.

The main advantage of Chart Pattern Helper is its ability to set and adjust pending orders according to a range of graphical objects placed on the Forex chart, including objects with slope. This allows easy trade execution for such popular patterns as triangles (ascending, descending and symmetrical), channels, flags, pennants, rectangles, head-and-shoulders, double tops/bottoms, etc.

Breakout of a level is defined as a simple touch. Chart Pattern Helper will not wait for a price to close above/below the given line. It will place pending orders that get executed whenever the price first touches the set levels.

There is a range of input parameters to regulate the work of this expert advisor, but it can start functioning immediately after you attach it to the chart and add the properly named chart objects. The chart objects may be moved freely then. The expert advisor will continue detecting their position and will adjust orders' parameters accordingly. By default, the EA outputs its current status to the chart comment.

Since all the chart objects are drawn at Bid price, the EA adjusts the entry, stop-loss and take-profit levels by adding the current spread value in cases when Ask price is to be used. This behavior can be disabled via the input parameters, decreasing the number of modification orders sent to trading server.

Chart Pattern Helper is capable of calculating the position size based on a set of input parameters, stop-loss level and account balance/equity — much like the Position Size Calculator for MetaTrader. You may turn this feature off and give a fixed position size to the EA.

Operation Process

This expert advisor goes through the following steps after initialization:

  1. Detect the objects according to names given via input parameters.
  2. Entry level for Buy order is placed at Entry object + spread (Ask).
  3. Entry level for Sell order is placed at Entry object (Bid).
  4. Stop-loss level for Buy order is placed at the Low of the latest bar with the majority of its length below Border object.
  5. Stop-loss level for Sell order is placed at the High of the latest bar with the majority of its length above Border object; the spread is then added to that High.
  6. Take-profit level for Buy order is placed at TP object (Bid).
  7. Take-profit level for Sell order is placed at TP object + spread (Ask).
  8. Calculated values are on a constant display via chart comment unless Silent input parameter is set to true.
  9. Pending orders are positioned according to these calculated values. If either Buy or Sell Entry object is absent, only one order is placed. Orders expire automatically when the current chart bar ends. In MT4, the minimum expiration time is 11 minutes; in MT5, it is 2 minutes.
  10. If the current price is below the Buy entry and above the Sell entry, pending stop orders are used. If the current price is either below the Sell entry or above the Buy entry, only one pending limit order is used.
  11. Track current object values and adjust entry, SL and TP levels accordingly.
  12. If position size calculation is used, order's volume is updated when needed. In this case, the order with old volume is deleted and the order with new volume is created. Warning: Be advised that this may cause significant flow of pending orders, which may be against your broker's terms of service. To prevent such behavior, you need to set UpdatePendingVolume input parameter to false.
  13. Expired orders are recreated with new volume (if needed) and updated entry/SL/TP levels.
  14. If one stop order is triggered, the second (opposite) order is deleted (unless OneCancelsOther input parameter is set to false). All objects are renamed by appending EA's Magic number to their initial names. This prevents creation of new pending orders.
  15. If PostEntrySLAdjustment is set to true, try to update stop-loss when a new candle opens following the breakout.
  16. Continue updating position's take-profit level according to TP object.
  17. Cease activity once the position is closed.
  18. Go to step one once the controlling chart objects are renamed back to their initial names.

Input Parameters

Objects

  • UpperBorderLine (default = "UpperBorder") — the name of the object (horizontal line or trend line) used to define the upper border of a breakout pattern. You can either name the object to the value of this parameter or change the parameter to fit the name you have used when created the chart object.
  • UpperEntryLine (default = "UpperEntry") — the name of the object (horizontal line or trend line) used to define the Buy entry level of a breakout pattern. You can either name the object to the value of this parameter or change the parameter to fit the name you have used when created the chart object.
  • UpperTPLine (default = "UpperTP") — the name of the object (horizontal line or trend line) used to define take-profit level of a Buy order. You can either name the object to the value of this parameter or change the parameter to fit the name you have used when created the chart object.
  • LowerBorderLine (default = "LowerBorder") — the name of the object (horizontal line or trend line) used to define the lower border of a breakout pattern. You can either name the object to the value of this parameter or change the parameter to fit the name you have used when created the chart object.
  • LowerEntryLine (default = "LowerEntry") — the name of the object (horizontal line or trend line) used to define the Sell entry level of a breakout pattern. You can either name the object to the value of this parameter or change the parameter to fit the name you have used when created the chart object.
  • LowerTPLine (default = "LowerTP") — the name of the object (horizontal line or trend line) used to define take-profit level of a Sell order. You can either name the object to the value of this parameter or change the parameter to fit the name you have used when created the chart object.
  • BorderChannel (default = "Border") — the name of the equidistant channel object used to define both upper and lower borders of a breakout pattern. You can either name the object to the value of this parameter or change the parameter to fit the name you have used when created the chart object.
  • EntryChannel (default = "Entry") — the name of the equidistant channel object used to define both Buy and Sell entry levels. You can either name the object to the value of this parameter or change the parameter to fit the name you have used when created the chart object.
  • TPChannel (default = "TP") — the name of the equidistant channel object used to define both Buy and Sell take-profit levels. You can either name the object to the value of this parameter or change the parameter to fit the name you have used when created the chart object.

Order Management

  • OneCancelsOther (default = true) — if true, a triggered pending order will cancel the opposite pending order. If false, the opposite order will remain intact and may trigger after the first position hits stop-loss or take-profit.
  • UseSpreadAdjustment (default = true) — if true, spread will be added to Buy entry level and Sell SL/TP levels. It compensates the difference when Ask price is used, while all chart objects are drawn at Bid level. Setting it to false will reduce the flow of order modification requests to the broker's trading server.
  • UseExpiration (default = true) — if true, pending orders will expire at the end of the current bar or in 11 minutes (MT4) or 2 minutes (MT5) after creation — whatever is further. Setting it to false may be required if a broker does not support order expiration.
  • DisableBuyOrders (default = false) — if true, new Buy orders will not be created, existing Buy orders and positions will be ignored.
  • DisableSellOrders (default = false) — if true, new Sell orders will not be created, existing Sell orders and positions will be ignored.
  • PostEntrySLAdjustment (default = false) — if true, the EA will try to adjust the stop-loss as a new candle opens after the breakout one. It will check whether the High/Low of the breakout candle still qualifies for SL. It may potentially break the position sizing rules but will define stop-loss more precisely according to the trading strategy's exit rules.

Position Sizing

  • CalculatePositionSize (default = true) — if true, position size is calculated based on given risk tolerance, account size (balance or equity), account currency and traded currency pair. The calculation process is the same as in Position Size Calculator. If false, a fixed position size is used.
  • UpdatePendingVolume (default = true) — if true, pending order's volume is updated whenever new position size gets calculated. This may cause excessively high amount of orders to the trading server because it is not possible to modify order's volume; instead, it has to be deleted and then created with a new volume. If false, order's volume remains constant until expiration and following recreation. This parameter is ignored if CalculatePositionSize = false.
  • FixedPositionSize (default = 0.01) — if CalculatePositionSize = false, the expert advisor will use the value of this parameter as a volume of created pending orders.
  • Risk (default = 1) — risk tolerance in percentage of account balance/equity. Works only if CalculatePositionSize = true. This input parameter is ignored if UseMoneyInsteadOfPercentage is set to true.
  • MoneyRisk (default = 0) — risk tolerance in account currency. Works only if CalculatePositionSize = true. Requires UseMoneyInsteadOfPercentage to be set to true.
  • UseMoneyInsteadOfPercentage (default = false) — if true, position size is calculated based on risk amount given in account currency (MoneyRisk) instead of balance/equity percentage risk (Risk). Works only if CalculatePositionSize = true.
  • UseEquityInsteadOfBalance (default = false) — if true, position size is calculated based on account equity instead of balance. Works only if CalculatePositionSize = true. Ignored if UseMoneyInsteadOfPercentage = true.
  • FixedBalance (default = 0) — if set to non-zero value, it is used instead of account balance/equity for position size calculation. Works only if CalculatePositionSize = true.
  • LotDigits (default = 2) — number of decimal places allowed by your broker in order volume. For example, if your broker allows micro lots (0.01), then this parameter should be set to 2. If your broker allows only mini lots (0.1) this parameter should be set to 1. Required only if CalculatePositionSize = true.

Miscellaneous

  • Magic (default = 20130116) — number used by the expert advisor to distinguish own orders (MT4 and MT5) and positions (MT4 only). You may need to change it only if you have other EAs running with the same Magic number or if you wish to add two or more instances of Chart Pattern Helper to one currency pair.
  • Slippage (default = 30) — maximum tolerable slippage in broker's pips.
  • Silent (default = false) — if true, no status information will be output to the chart comment. This come helpful if you use some indicator or other EA that modify chart comment and want to give them priority.
  • ErrorLogging (default = true) — if true, the EA will log all errors and other non-standard situations to a log file. It is named as "CPH-Errors-<date-time>" and can be found in /experts/files/ subfolder of MetaTrader 4 installation folder or /MQL5/Files/ subfolder of MetaTrader 5 installation folder (or a user application data folder designated for your MetaTrader 5 if you are on Vista or newer Windows version.)

MiniFAQ

Is it safe to turn this EA off once the orders are placed?

Yes, but the orders will expire if not triggered. The running EA is required to recreate and update them.

Does it use any trailing stop?

No, stop-loss is fixed after order gets executed. But you can apply your own trailing stop, even in a form of a separate expert advisor.

Can I modify position's stop-loss or take-profit once pending order is triggered?

Sure! You can start modifying stop-loss immediately and you can modify take-profit once you rename/delete the respective TP object or disable the expert advisor.

I use channels to draw the pattern but want the EA to trade only one side — either long or short. How do I do it?

You can prevent the expert advisor from using long (Buy) or short (Sell) orders by setting DisableBuyOrders or DisableSellOrders input parameters to true.

Can you change something for me, please?

No, sorry. There are hundreds of ways to modify this EA to trade differently and to comply with someone else's trading style. I am not going to implement any of them as it is practically impossible to satisfy everyone. However, the source code is open and well commented — you are free to implement your own changes.

Examples

MT4

The following example chart demonstrates the trading process of the Chart Pattern Helper. This descending channel pattern on M15 EUR/USD chart is marked with three channel objects: Border (yellow), Entry (turquoise) and TP (lime green.) The expert advisor has detected all objects and calculated entry, stop-loss and take-profit levels accordingly. The calculated values are displayed in the chart comment (top-left corner.) Pending stop orders have been placed, and their TP and SL levels are visible on the chart too.

Chart Pattern Helper — example chart showing stop orders in MetaTrader 4.

MT5

The next chart shows how Chart Pattern Helper places a pending buy limit order to get into a trade missed on breakout of the double bottom pattern. The weekly GBP/JPY chart uses horizontal lines to define Border (yellow), Entry (turquoise) and Take-Profit (lime green.) The same as in the previous example, the chart comment in top-left corner of the screen shows the detected levels. Since the lower objects are absent, only buy-specific levels are calculated. One pending buy limit order has been placed because the current price is above the entry level.

Chart Pattern Helper — example chart showing limit order in MetaTrader 5.

This EA is ECN-safe. You can freely use this expert advisor with ECN (market execution) brokers as it either does not apply any stop-loss and take-profit levels in its trading orders or sends only pending orders.

Downloads

Download Chart Pattern Helper for MT4

Download zipped Chart Pattern Helper for MT4

Download Chart Pattern Helper for MT5

Download zipped Chart Pattern Helper for MT5

Discussion

Warning! Before you ask basic questions regarding installation of the expert advisors, please, read this MT4 Expert Advisors Tutorial to get the elementary knowledge on handling them.

Do you have your own trading results or any other remarks regarding this expert advisor? Discuss Chart Pattern Helper with other traders and MQL programmers on the experts forums.



© 2005—2014 EarnForex.com. Design — Mart Studio.
Do You Believe in Forex Tick Volume? Poll.