MetaTrader Script to Add Parallel Channels

Sometimes, I post a sort of chart pattern analysis that often consists of channel patterns — descending, ascending or horizontal. They all share some common traits:

  • Each one has a main pattern — a channel. On my charts, it is marked with yellow lines.
  • Each has two entry lines for channel breakouts. The upper one is located at upper border + 10% of channel’s height. The lower one is located at lower border — 10% of channel’s height. They are depicted using cyan (or more precisely, turquoise) lines on my charts.
  • Each has two target lines. Similarly to the entry lines, they are placed at 100% of the channel’s height from the border lines. Their color is green (actually, lime green).
  • Recently I have been asked by one of the blog readers about how do I draw the entry/target channels at 10%/100% distance of the channel’s height accurately. Until yesterday, I did it this way:

  • I used the standard Equidistant Channel object to draw the channel borders.
  • I placed the control dot of the Equidistant Channel’s auxiliary line directly above or below the first or last control dot of the Equidistant Channel’s main line:
  • Then, right-clicking the channel and choosing “Channel properties…”, and then “Parameters” tab would show me exact price levels for those control dots:
  • Subtracting the price levels with the same time coordinates would yield the exact channel height value.
  • Then, it could be used to place both Entry and TP channels. Two new channels would be placed with their control dots aligned in time to the control dots of the Border channel.
  • Adding and subtracting 10% and 100% of height from the Border’s channel price levels would position Entry and TP channels exactly where needed.
  • Yesterday, I have decided to code a MetaTrader 4 script that would do all this automatically. Now, all I need to do is only 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. Unfortunately, MetaTrader does not support input parameters for scripts, but the percentage levels and some other properties can be easily modified via the script’s source code: Thanks to Medhat Ramses, you can now easily modify all the parameters of the script via MetaTrader native Inputs tab.
    You can download the .mq4 file of the script or the same source code in .zip. Please do not forget that scripts should be placed in your MetaTrader’s /experts/scripts/ folder.
    Update 2013-02-27: 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.
    Update 2013-02-28: The script is now also available for MetaTrader 5: .mq5 and .zip.
    Update 2013-04-13: Fixed the error in MT4 version of the script that caused division by zero on horizontal channel processing.
    Update 2013-10-01: Input parameters are now working in both MT4 and MT5 versions. Also fixed the type of the style input parameters.
    Update 2014-06-05: New version allows drawing one-sided entry/TP lines and fixes a serious bug in MT5.

    If you have any comments or questions about this channel markup script, please post them using the form below.

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    forty eight − forty three =