The perfect trendline indicator does not pick one line. It takes the last eight confirmed pivots, joins every valid pair and keeps up to six lines running on each side. A break of any of them prints a mark, so you see the whole structure rather than one drawn guess.
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 | 4: PTL Up Pivot, PTL Dn Pivot, PTL Buy Break, PTL Sell Break |
| Alerts | popup, push notification, email, sound |
| Inputs | 14 |
What the Perfect Trendline Indicator draws on the chart
Four arrow plots and chart lines.
`PTL Up Pivot` dots a swing low in dodger blue.
`PTL Dn Pivot` dots a swing high in orange.
`PTL Buy Break` uses arrow 233 in lime.
`PTL Sell Break` uses arrow 234 in red.
Lines draw lime rising and red falling.
- PTL Up Pivot: arrow, dodger blue, width 1, arrow code 159
- PTL Dn Pivot: arrow, orange, width 1, arrow code 159
- PTL Buy Break: arrow, lime, width 2, arrow code 233
- PTL Sell Break: arrow, red, width 2, arrow code 234

How the Perfect Trendline Indicator calculates its values
Pivots first
Two windows define one. `PivotLeft` `5` bars before and `PivotRight` `5` bars after must both stay lower than a high. That right-hand window is the confirmation cost.
Valid pairs only
Direction has to be right. A falling line needs the newer high below the older one. A rising line needs the newer low above. Pairs failing that get skipped.
Breaks and spacing
A close through a line marks it. The bar before must have sat on the other side. A cooldown of `PivotRight` plus three bars then holds the next mark off.
How to read the signals
Dots show which pivots the lines were built from.
Several lines per side is normal, not a fault.
The steepest line breaks first in a fast move.
`MaxPivots` `8` limits how far back pairs reach.
A break of the shallowest line matters most.
Marks arrive on the closed bar only.
Alert channels in this build: popup, push notification, email and sound, one message per closed bar.
`EnableAlerts` heads the break alerts and ships true with `EnablePopup` and `EnableSound`, which plays `SoundFile`. `EnablePushNotify` reaches a phone and `EnableEmail` posts mail, both off at the start.
Every Perfect Trendline Indicator input
Core settings
| Setting | What it does | Default |
|---|---|---|
PivotLeft |
pivot left bars. Bars before a pivot, `5`. | 5 |
PivotRight |
pivot right bars (confirmation). Bars after it, `5`. | 5 |
MaxPivots |
recent pivots to consider. Recent pivots considered, `8`. | 8 |
MaxLines |
max active trendlines per side. Live lines kept per side, `6`. | 6 |
Display settings
| Setting | What it does | Default |
|---|---|---|
UpTrendColor |
Rising line colour, `clrLime`. | lime |
DnTrendColor |
Falling line colour, `clrRed`. | red |
LineWidth |
Line thickness, `2`. | 2 |
ShowPivotDots |
Dot each pivot, `true`. | on |
Alert settings
| Setting | What it does | Default |
|---|---|---|
EnableAlerts |
Master switch, `true`. | on |
EnablePopup |
(see inputs panel) | on |
EnablePushNotify |
(see inputs panel) | off |
EnableEmail |
(see inputs panel) | off |
EnableSound |
Cue on a break, `true`. | on |
SoundFile |
(see inputs panel) | alert.wav |

Settings that fit your chart
Five bars each side is a fast pivot rule, so lines form readily. EURUSD H1 is the reference chart. Six lines per side there stay legible. On M5 the pivots are noise and the chart fills up. On H4 each line covers weeks.
When the Perfect Trendline Indicator fails
Twelve lines on one chart is a lot to read.
A five-bar pivot is a small structure.
Every line arrives five bars after its pivot.
A break of a steep line usually means very little.
Copy the compiled Perfect Trendline 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 Perfect Trendline Indicator for MT4 and MT5
The zip holds the compiled Perfect Trendline 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
Why keep MaxLines 6 running per side?
Because there is rarely one correct trend line. Six candidates drawn from recent pivots show the whole structure, and which one breaks first tells you more than any single hand-drawn line would.
What makes PivotRight 5 the confirmation cost?
Five bars have to print after the high before it counts as a pivot. Until then it could still be exceeded, so every line built from it appears five bars later than the pivot itself.
How far back does MaxPivots 8 reach?
Eight confirmed pivots, which on H1 usually covers two or three days. Only pairs drawn from those eight get considered, which keeps the lines tied to current structure.
Why does the tool use a cooldown after a break?
Because several lines often break within a bar or two of each other. The cooldown of PivotRight plus three bars turns that cluster into one mark instead of five.
Are results guaranteed?
No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Perfect Trendline 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
- The core method is documented in Denomination effect on Wikipedia.
- Additional market context is at Crossrate at Investopedia.
