Trendline Touch Alert Indicator for MT4 and MT5

Written by Dominic Walsh · Published · Last updated

Horizontal levels are the easy case. The trendline touch alert indicator handles the harder one: it joins two pivots into a sloping line, works out where that line sits on every later bar, and marks the bar that reaches it and then closes back on the original side.

This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.

Platforms MT4 (.ex4) + MT5 (.ex5)
Chart window Main price chart
Plots 2: Support Touch (Buy), Resistance Touch (Sell)
Alerts popup, push notification, email, sound
Inputs 13

What the build shows

Two arrow plots plus the lines themselves.

`Support Touch (Buy)` prints deep sky blue at width 2.

`Resistance Touch (Sell)` prints orange red beside it.

Lines join two pivots and run forward.

`SupLineColor` and `ResLineColor` tint each side.

`LineWidth` `2` sets how heavy they draw.

  • Support Touch (Buy): arrow, deep sky blue, width 2, arrow code 233
  • Resistance Touch (Sell): arrow, orange red, width 2, arrow code 234
trendline touch alert indicator: A sloping line with a rejection marked, EURUSD H1.
A sloping line with a rejection marked, EURUSD H1.

Under the hood

Picking the anchors

`PivotDepth` `6` bars either side must fail to beat a bar. Six is wide, so the two anchors a line runs through describe real turns rather than passing wobbles.

Reading the line at a bar

Straight interpolation does it. Knowing the two anchor prices and how far the current bar sits between them gives the line’s exact value on that bar.

What counts as a touch

`TouchATRmult` `0.60` times an `ATRPeriod` `14` range sets the band. The high must land inside it and the close must finish back under the line for a sell mark.

How to take a reading

The line’s value changes on every bar.

A touch means reach and rejection together.

A clean break through prints nothing at all.

`TouchCooldown` `5` keeps repeat marks apart.

Band width follows the market’s own range.

Six-bar pivots confirm six bars late.

Alert channels in this build: popup, push notification, email and sound, one message per closed bar.

A touch and rejection together is what speaks. `EnableAlerts` is the master switch over it and `EnablePopup` shows a terminal dialog already. The handset delivery, the terminal mail and the desktop sound behind `SoundFile` all start closed.

Every Trendline touch alert Indicator input

Core settings

Setting What it does Default
PivotDepth fractal half-width for swing pivots. Bars either side defining an anchor, `6`. 6
TouchATRmult touch tolerance = ATR * this. Range multiple that sets the touch band, `0.60`. 0.60
ATRPeriod ATR lookback for the touch band. Window behind that range figure, `14`. 14
TouchCooldown minimum bars between same-side touches. Bars held between same-side touches, `5`. 5

Display settings

Setting What it does Default
ResLineColor Tint on the upper line, `clrOrangeRed`. orange red
SupLineColor Tint on the lower one, `clrDeepSkyBlue`. deep sky blue
LineWidth How heavy both draw, `2`. 2

Alert settings

Setting What it does Default
EnableAlerts Master switch over the touch message, `true`. on
EnablePopup Shows it in a terminal dialog, `true`. on
EnablePushNotify (see inputs panel) off
EnableEmail (see inputs panel) off
EnableSound (see inputs panel) off
SoundFile Clip it sounds, `”alert.wav”`. alert.wav
trendline touch alert indicator: Inputs panel, PivotDepth above the touch band settings.
Inputs panel, PivotDepth above the touch band settings.

Placing it well

A six-bar pivot rule needs swings with some size to them. EURUSD H1 is the reference chart, where a line stays usable for days. On M5 the anchors move before a line earns a touch. On H4 one line can define a whole month.

What it misses

A sloping line depends entirely on which pivots got picked.

Two anchors can be drawn through almost any pair of turns.

A rejection mark says nothing about what follows.

Every anchor confirms six bars after it printed.

Copy the compiled Trendline touch alert Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.

Background reading on the method behind the Trendline touch alert Indicator: Trend line (technical analysis) on Wikipedia, Average True Range at Investopedia.

Download the Trendline touch alert Indicator for MT4 and MT5

The zip holds the compiled Trendline touch alert Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.

Download this indicator free

Enter your email and the file is yours. You also get the full MT4 and MT5 library.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

Why must the close finish back inside for a touch?

Because reaching a line and respecting it are different events. Requiring the close on the original side turns a bar that merely pierced the line into nothing, which is the whole point of calling it a touch.

How does TouchATRmult 0.60 size the band?

It multiplies the fourteen-bar range figure, so the tolerance is six tenths of what the market has recently been moving. A fixed pip band would be far too wide on gold and far too tight on a quiet cross.

Where do the two PivotDepth anchors put the line?

Straight-line interpolation between them. The code knows both anchor prices and both bar positions, so it works out exactly where the sloping line sits on whichever bar it is currently testing.

What does TouchCooldown 5 prevent?

A run of marks on consecutive bars. Price hugging a trendline can satisfy the touch test several times in a row, and five bars of spacing keeps the chart showing events rather than a cluster.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Trendline touch alert Indicator as one input. Always backtest before trading live.

Category: this is part of our Trend collection. Browse more Trend for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.

External references

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment