The advanced trendlines indicator draws two sloped lines and watches for a close through either one. Res Trendline joins recent fractal highs and Sup Trendline joins the lows. Buy and Sell arrows mark the break rather than the line itself.
This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H4.
| Platforms | MT4 (.ex4) + MT5 (.ex5) |
|---|---|
| Chart window | Main price chart |
| Plots | 4: Res Trendline, Sup Trendline, Buy, Sell |
| Alerts | popup, push notification, email, sound |
| Inputs | 8 |
On the chart: plots and colours
Res Trendline (tomato) runs through two fractal highs and extends forward at their slope.
Sup Trendline (blue) does the same across two fractal lows.
Buy (lime, code 233) sits under the low when a close pushes above Res Trendline.
Sell (red, code 234) sits above the high when a close drops under Sup Trendline.
- Res Trendline: line, tomato, width 1
- Sup Trendline: line, dodger blue, width 1
- Buy: arrow, lime, width 4, arrow code 233
- Sell: arrow, red, width 4, arrow code 234

Following the source
Finding the pivots
FractalDepth decides how many bars either side a high must beat before it counts as a pivot. At the default of 4 a bar needs to be the extreme across that stretch.
The scan collects the two most recent qualifying highs, and separately the two most recent lows.
Turning two points into a line
Slope is the price difference between the two pivots divided by the bar distance between them. That single number defines the line.
Projecting it forward gives a value on every bar, including bars after the second pivot. Each line therefore keeps extending until a fresher pivot replaces it.
Marking the break
A break needs the previous close on one side of the projected line and the current close on the other. Both bars have already printed when the check runs.
ArrowOffsetPoints separates the marker from its candle by a fixed number of points and plays no part in the test.
Interpreting what you see
Line angle carries most of the meaning. A steep resistance line needs a much larger move to break than a flat one.
Both lines recalculate whenever a fresher pivot appears, so their slope can change between one bar and the next.
An arrow marks the bar that closed through, never the bar the line was drawn from.
Nothing prints until two qualifying pivots exist on that side, so a fresh chart starts empty.
Alert channels in this build: popup, push notification, email and sound, one message per closed bar.
Alerts cover popup, push, email and sound on each break. A bar time check keeps it to one alert per closed bar.
Every Advanced Trendlines Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
FractalDepth |
FractalDepth is how many bars either side a pivot has to beat. It defaults to 4. Larger values find fewer and more significant pivots. | 4 |
Display settings
| Setting | What it does | Default |
|---|---|---|
ArrowOffsetPoints |
ArrowOffsetPoints is the cosmetic gap between a marker and its candle, 35 points by default. | 35 |
Alert settings
| Setting | What it does | Default |
|---|---|---|
EnableAlerts |
EnableAlerts gates the message block and defaults to true. | on |
EnablePopup |
(see inputs panel) | on |
EnablePushNotify |
(see inputs panel) | off |
EnableEmail |
(see inputs panel) | off |
EnableSound |
EnableSound plays a file from the MT4 Sounds folder on a break. It defaults to false. | off |
SoundFile |
(see inputs panel) | alert.wav |

Suitable charts
The screenshot uses EURUSD H4. Sloped lines need swings with room in them, so H1 and above give the pivot scan something to work with. On M5 a FractalDepth of 4 finds pivots in ordinary noise and the lines redraw constantly. Raising FractalDepth is the usual fix on a fast chart.
Where it falls down
Two points define any straight line, including a meaningless one. Nothing here judges whether those two pivots belong on the same trendline.
The line moves when a newer pivot appears, so a break that looked clean can be measured against a different slope a few bars later.
A projected line extends forever. Far from its pivots it drifts a long way from anything price respects.
There is no trend context. A break upward through resistance during a larger downtrend looks identical to one with the trend.
Copy the compiled Advanced Trendlines 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.
Download the Advanced Trendlines Indicator for MT4 and MT5
The zip holds the compiled Advanced Trendlines 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 many pivots does each line use?
Two on each side. The scan keeps the most recent pair of qualifying highs for Res Trendline and the most recent pair of lows for Sup Trendline. Slope comes from the price difference divided by the bar distance, and the line then projects forward from there.
What does raising FractalDepth from 4 do?
A pivot then has to beat more bars either side before it qualifies, so fewer bars pass the test. The lines join larger swings, redraw less often and produce fewer breaks. On a fast chart that usually improves the result noticeably.
Does a break arrow mean the trendline is gone?
No. The line keeps projecting forward after a close pushes through, and it only changes when a newer qualifying pivot replaces one of its two points. So price can cross back the other way without anything being removed from the chart.
Why does the Res Trendline slope change between bars?
A fresher pivot has qualified and replaced one of the two points. The line is always built from the most recent pair, so a new swing high rewrites Res Trendline from that bar onward, including its projection.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Advanced Trendlines Indicator as one input. Always backtest before trading live.
Category: this is part of our Trend collection. Next, browse more Trend for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.
External references
- For background on this concept, see Market trend on Wikipedia.
- For broader market context, see Trend Lines at StockCharts ChartSchool.
