Trendline Price Alert Indicator for MT4 and MT5

Written by Dominic Walsh · Published · Last updated

Setting a price alert on a sloping trendline is fiddly because the level changes every bar. The trendline price alert indicator draws the lines for you, through the last two swing highs and the last two swing lows, and marks the bar that closes through either one.

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: TL Price Break Up, TL Price Break Down
Alerts popup, push notification, email, sound
Inputs 13

Chart elements

Two trendlines and two marks on price.

`ResColor` `clrOrangeRed` draws the resistance line.

`SupColor` `clrDodgerBlue` draws the support line.

`TL Price Break Up` prints lime with arrow 233.

`TL Price Break Down` prints red with arrow 234.

`LineWidth` `2` sets the line weight.

  • TL Price Break Up: arrow, lime, width 2, arrow code 233
  • TL Price Break Down: arrow, red, width 2, arrow code 234
trendline price alert indicator: Auto trendlines with close breaks, EURUSD H1.
Auto trendlines with close breaks, EURUSD H1.

Following the source

Swings

`PivotDepth` `6` bars on each side confirm a swing. The two newest highs set the resistance line.

Lines

Each line runs through its two swings and is projected forward, so its price changes bar by bar.

Break

A close above the resistance line, after a close at or below it, prints a buy. `ArrowATR` `0.60` spaces the marks.

How to use what it draws

Orange red slopes across the recent highs.

Blue slopes across the recent lows.

Lines move when a new swing confirms.

Marks show closes through a line.

`TouchATR` `0.35` sets the touch band.

Swings confirm six bars late.

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

A close through either line reports as a buy or sell. `EnableAlerts` is the master switch, and at first only the popup delivers.

Every Trendline Price Alert Indicator input

Core settings

Setting What it does Default
PivotDepth Fractal depth (bars each side of a swing pivot). Bars on each side of a swing, `6`. 6
AtrPeriod ATR period (touch tolerance + arrow offset). Range window, `14`. 14
TouchATR Touch band width as ATR multiple. Touch band in ranges, `0.35`. 0.35

Display settings

Setting What it does Default
ArrowATR Arrow offset from candle as ATR multiple. Mark gap in ranges, `0.60`. 0.60
ResColor Resistance trendline colour. Resistance line colour, `clrOrangeRed`. orange red
SupColor Support trendline colour. Support line colour, `clrDodgerBlue`. dodger blue
LineWidth Trendline width. Line width, `2`. 2

Alert settings

Setting What it does Default
EnableAlerts Master alert switch, `true`. on
EnablePopup Popup, `true`. on
EnablePushNotify (see inputs panel) off
EnableEmail (see inputs panel) off
EnableSound Speaker, `false`. off
SoundFile (see inputs panel) alert.wav
trendline price alert indicator: Inputs panel, swing depth above the line styles.
Inputs panel, swing depth above the line styles.

Choosing a market

Six-bar swings give lines that last days on hourly charts. EURUSD H1 is the reference chart. On M15 lines redraw often. On D1 they match the lines traders draw by hand.

Where the Trendline Price Alert Indicator struggles

Two swings make a fragile line.

Steep lines break quickly and falsely.

Lines redraw as new swings confirm.

The popup is the only route live at first.

Copy the compiled Trendline Price 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.

Related on forexmt4systems.com: Price Action Strategy.

Download the Trendline Price Alert Indicator for MT4 and MT5

The zip holds the compiled Trendline Price 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

Which swings does PivotDepth 6 join?

The two most recent swing highs, each with six lower highs on both sides, form the resistance line. The two latest swing lows form support.

Why does the line price change every bar?

A trendline slopes, so its value moves with time. The build projects it forward and compares each close with the line’s price on that bar.

When does TL Price Break Up print?

On a closed bar that closes above the resistance line after the bar before closed at or below it. The alert follows on the same bar.

What is TouchATR 0.35 for?

It defines how close price must come to count as touching a line, about a third of a range. Break marks do not use it; it frames the lines.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Trendline Price 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