ChannelPattern MetaTrader Script

ChannelPattern MetaTrader script is a simple tool to draw customizable breakout entry and exit levels based on a channel chart pattern. It is available both for MT4 and MT5. ChannelPattern script was developed to be used in combination with the ChartPatternHelper EA but can also be used without it.

Sometimes, a trader would need to work with channel pattern breakout setups. Such setups can be based on all sorts of channel — descending, ascending, or horizontal. Usually, such setups share some common traits:

  • Each one has the main pattern — a channel.
  • Each has two entry lines for channel breakouts. The upper one is located at the upper border plus 10% of the channel's height. The lower one is located at the lower border minus 10% of the channel's height.
  • Each has two target lines. Similar to entry lines, they are placed at 100% of the channel's height away from the border lines.

To avoid doing all these calculations and then placing the chart objects in MetaTrader manually, you can use the handy ChannelPattern script presented here.

For it to work, all you need to do is to place the initial Border channel, name it "Border", and run the script. It will do all the calculations and place the 10%/100% channels completely by itself.

Additionally, the ChannelPattern script is very customizable and can even draw Entry/TP levels as trendlines on a chosen side of the Border channel. By default, it will draw two channels (Entry and Take-Profit) around the given Border channel. If the input parameter Sides is set to Upper or Lower instead of Both, the script will draw trendlines on a selected side only. This may help when you only expect a breakout from that particular side.

Input parameters

  • BorderName (default = "Border") — the name of the border channel to work with.
  • EntryName (default = "Entry") — the name of the resulting entry channel to set.
  • TPName (default = "TP") — the name of the resulting take-profit channel to set.
  • PercentageEntry (default = 10) — the distance from border to entry in percentage points of the channel's height.
  • PercentageTP (default = 100) — the distance from border to take-profit in percentage points of the channel's height.
  • EntryColor (default = clrTurquoise) — the color for entry objects.
  • TPColor (default = clrLimeGreen) — the color for take-profit objects.
  • EntryStyle (default = STYLE_DASH) — the line style for entry objects.
  • TPStyle (default = STYLE_DASH) — the line style for take-profit objects.
  • Sides (default = Both) — if set to Both, draws channels on both sides of the given channel; if set to Upper, draws trendlines for bullish breakout; if set to Lower, draws trendlines for bearish breakout.
  • UpperBorder (default = "UpperBorder") — the name of the upper border trendline object when the channel is set using trendline chart objects.
  • LowerBorder (default = "LowerBorder") — the name of the lower border trendline object when the channel is set using trendline chart objects.
  • UpperEntry (default = "UpperEntry") — name for the trendlines object acting as Upper Entry level.
  • UpperTP (default = "UpperTP") — name for the trendlines object acting as Upper TP level.
  • LowerEntry (default = "LowEntry") — name for the trendlines object acting as Lower Entry level.
  • LowerTP (default = "LowerTP") — name for the trendlines object acting as Lower TP level.

Example

ChannelPattern Script - Example on MT5 Chart

Downloads (ver. 1.07, 2020-11-30)

Script Installation

To install the script in MetaTrader 4, please follow the instructions below:

  1. Download the script file.
  2. Open the MetaTrader 4 data folder (via File→Open Data Folder).
  3. Open the MQL4 folder.
  4. Copy all the folders from the archive directly to the MQL4 folder.
  5. Restart MetaTrader 4 or refresh the list of scripts by right-clicking the Navigator subwindow of the platform and choosing Refresh.

To install the script in MetaTrader 5, please follow the instructions below:

  1. Download the script file.
  2. Open the MetaTrader 5 data folder (via File→Open Data Folder).
  3. Open the MQL5 folder.
  4. Copy all the folders from the archive directly to the MQL5 folder.
  5. Restart MetaTrader 5 or refresh the list of scripts by right-clicking the Navigator subwindow of the platform and choosing Refresh.

You can also read a more detailed instruction on how to perform the installation.

Discussion

Do you have any suggestions or questions regarding this script? You can always discuss ChannelPattern with the other traders and MQL programmers on the scripts forum.

Changelog

1.07 — 2020-11-30

  • MT4 version now works identically to MT5 one with much fewer potential errors in calculations when dealing with channels where the auxiliary line is shifted horizontally in relation to the channel's main line. MT5 version had only one minor change that doesn't affect much.

1.06 — 2018-02-03

  • Tweaked the MT4 code to correctly detect Borders given as horizontal lines.
  • Both versions (MT4 and MT5) will now create Entry and TP lines as horizontal line objects whenever possible.

1.05 — 2014-07-05

  • The script can now work with borders drawn using trendlines or horizontal lines. It is the trader's responsibility to make sure that the lines are parallel. Otherwise, the resulting channel may not be very useful.

1.04 — 2014-06-07

  • Allowed drawing a one-sided set of entry/TP lines.
  • Fixed a bug in the MT5 version of the script. Previously, the script would calculate the height of the channel incorrectly if one of its lines was shifted horizontally. The new version addresses this case and calculates everything correctly.
  • Fixed a bug in MT4 version that would make script work incorrectly on weekly timeframe on some occasions.

1.03 — 2013-10-01

  • Input parameters are now working in both MT4 and MT5 versions.
  • Fixed the type of the style input parameters.

1.02 — 2013-04-13

  • Fixed the error in MT4 version of the script that caused division by zero on horizontal channel processing.

1.01 — 2013-02-28

  • The script was updated to work normally when Entry and TP objects are already on the chart. For example, when you have just repositioned the Border channel, running the script will also reposition Entry/TP channels properly.
  • The script is now also available for MetaTrader 5.

1.00 — 2013-02-24

  • Initial release of the script.

© 2005–2021

EarnForex.com

Design — Mart Studio

Forex trading bears intrinsic risks of loss. You must understand that Forex trading, while potentially profitable, can make you lose your money. Never trade with the money that you cannot afford to lose! Trading with leverage can wipe your account even faster.

CFDs are leveraged products and as such loses may be more than the initial invested capital. Trading in CFDs carry a high level of risk thus may not be appropriate for all investors.