The automatic trendlines v2 indicator draws the two lines you would draw by hand. It walks back through the chart, takes the two most recent swing highs for resistance and the two most recent swing lows for support, then extends a straight line through each pair.
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: Resistance, Support |
| Alerts | popup, push notification, email, sound |
| Inputs | 10 |
What the Automatic Trendlines V2 Indicator draws on the chart
Resistance is the tomato line through the two newest swing highs.
Support is the medium sea green line through the two newest swing lows.
Both lines extend across the chart rather than stopping at the second pivot.
Nothing draws until the scan has found two pivots on that side.
- Resistance: line, tomato, width 2
- Support: line, medium sea green, width 2

How the Automatic Trendlines V2 Indicator calculates its values
Finding two pivots per side
The scan runs from the newest bar backwards and stops once it holds two swing highs and two swing lows. A swing needs `SwingDepth` `6` bars on each side that fail to beat it. `MaxLookback` `400` caps how far back the walk goes.
Solving the line
slopeR takes the price difference between the two highs divided by their bar distance. interR then takes the newer price minus slope times its bar index. Two points define a straight line exactly, which is why no fitting is needed here.
Where the tolerance applies
`AtrTol` `0.3` scales a tolerance band around each line in ATR units. It decides how close price must come before the tool treats the line as reached. Scaling by ATR keeps that band sensible across instruments.
How to read the signals
Each line rests on exactly two pivots, so it is a hypothesis rather than a fit.
A new swing replaces the older pivot and the whole line moves.
Converging lines mean the chart is coiling into a triangle shape.
The lines carry no direction. Which one matters depends on where price sits.
Alert channels in this build: popup, push notification, email and sound.
`EnableAlerts` starts on and `EnablePopup` carries the text. `EnablePushNotify`, `EnableEmail` and `EnableSound` begin false. `SoundFile` picks the clip. This build has no once-per-bar guard, so leave the noisier channels off unless repeats suit you.
Every Automatic Trendlines V2 Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
SwingDepth |
Bars each side of a swing pivot, default `6`. | 6 |
MaxLookback |
How far back the pivot walk goes, default `400` bars. | 400 |
AtrTol |
Tolerance band around each line in ATR units, default `0.3`. | 0.3 |
Display settings
| Setting | What it does | Default |
|---|---|---|
ArrowOffsetPoints |
(see inputs panel) | 30 |
Alert settings
| Setting | What it does | Default |
|---|---|---|
EnableAlerts |
Master switch for the trendline touch alerts, default `true`. | on |
EnablePopup |
Terminal dialog on a trendline touch, default `true`. | on |
EnablePushNotify |
Phone push on a trendline touch, default `false`. | off |
EnableEmail |
Mail delivery on a trendline touch, default `false`. | off |
EnableSound |
Sound playback on a trendline touch, default `false`. | off |
SoundFile |
Wav clip for the trendline alert, default `alert.wav`. | alert.wav |

Settings that fit your chart
Two-point lines suit charts with clear swings rather than drifting ones. EURUSD H1 is the reference chart, where `SwingDepth` at `6` picks turns lasting most of a session. On M5 the pivots change constantly and both lines swing wildly. On H4 the lines settle and hold for days.
When the Automatic Trendlines V2 Indicator fails
Two points always define a line, whether or not that line means anything.
A fresh swing replaces the older pivot, so the line can jump between bars.
`SwingDepth` `6` needs six bars on the right, so the newest pivot confirms late.
Copy the compiled Automatic Trendlines V2 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 Automatic Trendlines V2 Indicator: International Federation of Technical Analysts on Wikipedia, Heikinashi at Investopedia.
Download the Automatic Trendlines V2 Indicator for MT4 and MT5
The zip holds the compiled Automatic Trendlines V2 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.
FAQ
How does SwingDepth decide a pivot?
The bar must beat every bar within six positions on each side. Six is a fairly demanding window, which keeps the two lines resting on turns you would recognise by eye. Raise it for lines built from larger structure only.
Why only two pivots per line?
Because two points define a straight line exactly, with no fitting involved. It is also how most traders draw trendlines by hand. The cost is fragility, since replacing either pivot moves the whole line.
How far back does the MaxLookback walk go?
How far back the walk searches before giving up. Four hundred bars on EURUSD H1 is a little over two weeks. Shorten it to keep both lines resting on recent structure, or extend it when the chart has been quiet.
What is AtrTol at 0.3 measuring?
The width of the tolerance band around each line, in ATR units. At 0.3 price has to come within about a third of a typical bar range before the line counts as reached. Scaling by ATR keeps that sensible on any instrument.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Automatic Trendlines V2 Indicator as one input. Always backtest before trading live.
Category: this is part of our Trend collection. Also, still, hence, plainly, truly, browse more Trend for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.
External references
- For background on this concept, see International Federation of Technical Analysts on Wikipedia.
- For broader market context, see Heikinashi at Investopedia.
