Fractals Adjustable Period Trend Lines Indicator: Wider Fractals

Written by Dominic Walsh · Published · Last updated

The fractals adjustable period trend lines indicator fixes the one thing the standard fractal cannot do: change its width. FractalPeriod sets how many bars either side a pivot must beat. Fractal Up and Fractal Dn mark the qualifying bars, and trend line objects join them.

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: Fractal Up, Fractal Dn
Alerts popup, push notification, email, sound
Inputs 12

What the Fractals Adjustable Period Trend Lines Indicator draws on the chart

Fractal Up marks a bar whose high beats every neighbour within the window, drawn slightly above the bar.

Fractal Dn does the same for a low, drawn slightly below.

Trend line objects connect the recent pivots, in the resistance colour above and the support colour below.

LineWidth and LineStyle control how those lines are drawn.

  • Fractal Up: arrow, lime, width 2, arrow code 233
  • Fractal Dn: arrow, red, width 2, arrow code 234
EURUSD H1: the fractals adjustable period trend lines indicator marking Fractal Up pivots with joined lines.
EURUSD H1: the fractals adjustable period trend lines indicator marking Fractal Up pivots with joined lines.

How the Fractals Adjustable Period Trend Lines Indicator calculates its values

A widened fractal test

For every candidate bar the code walks outward one step at a time. A high fails the moment any bar within FractalPeriod on either side matches or beats it.

The standard platform fractal fixes that window at two bars each way. Making it an input is the whole point of this build, since a wider window finds fewer and more meaningful pivots.

Both sides matter

The test checks bars in front as well as behind, which is what makes a fractal a fractal. A pivot cannot confirm until FractalPeriod bars have printed after it.

That delay is structural, not a flaw. A pivot confirmed without the bars to its right would simply be the current extreme.

Drawing the lines

Once pivots exist, trend line objects join them across the chart, with LookbackBars limiting how much history gets scanned.

Highs and lows get their own colours, so the resistance and support sides stay distinguishable at a glance.

How to read the signals

A pivot appears FractalPeriod bars after the bar it marks, which is the cost of confirming both sides.

Wider settings find fewer pivots, and the ones they find span larger swings.

Lines join pivots as they were found rather than judging whether two belong on the same trendline.

LookbackBars caps the history, so older structure drops out of the drawing entirely.

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

Alerts cover popup, push, email and sound when a pivot confirms. A bar time check keeps it to one alert per closed bar.

Every Fractals Adjustable Period Trend Lines Indicator input

Core settings

Setting What it does Default
FractalPeriod Fractal half-window (3..15). FractalPeriod is how many bars either side a pivot has to beat. It defaults to 5, which is already wider than the platform standard of two. 5
LookbackBars Bars to scan for fractals. LookbackBars limits how much history the scan covers, 600 bars by default. 600

Display settings

Setting What it does Default
ResistanceColor Down-fractal trend line (resistance). red
SupportColor Up-fractal trend line (support). lime
LineWidth LineWidth sets the thickness of the drawn trend lines, 2 by default. 2
LineStyle LineStyle picks the line style, solid by default. STYLE_SOLID

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 (see inputs panel) off
SoundFile (see inputs panel) alert.wav
Inputs panel for the fractals adjustable period trend lines indicator showing FractalPeriod and LookbackBars.
Inputs panel for the fractals adjustable period trend lines indicator showing FractalPeriod and LookbackBars.

Settings that fit your chart

The screenshot uses EURUSD H1. A five bar window on H1 finds pivots worth drawing lines between. On M1 and M5 even five bars qualifies inside ordinary noise, so raising FractalPeriod helps far more than changing timeframe. On daily charts five bars covers a week and pivots become rare.

When the Fractals Adjustable Period Trend Lines Indicator fails

A pivot cannot confirm until FractalPeriod bars have closed after it, so the newest part of the chart always carries unconfirmed structure.

Two pivots make a line whether or not the swings between them belong together.

Widening the window finds fewer pivots and delays each one further, so the two costs move together.

Nothing here rates one pivot against another. A minor swing that passes the test counts the same as a major one.

Copy the compiled Fractals Adjustable Period Trend Lines 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 Fractals Adjustable Period Trend Lines Indicator for MT4 and MT5

The zip holds the compiled Fractals Adjustable Period Trend Lines 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

How is this different from the standard MT4 fractal?

The platform fractal fixes its window at two bars either side and cannot be changed. Here FractalPeriod is an input, defaulting to 5. A wider window means a bar has to beat more neighbours to qualify, which finds fewer pivots and larger swings.

Why does a Fractal Up appear several bars late?

Because the test checks bars in front of the candidate as well as behind it. At FractalPeriod 5 the code needs five closed bars to the right before it can confirm nothing beat that high. Without that check it would only be reporting the current extreme.

What does LookbackBars 600 limit?

How much history the pivot scan and the line drawing cover. Older bars are left alone entirely. On a chart with deep history that keeps the first calculation quick and stops the screen filling with lines from structure that stopped mattering.

Does FractalPeriod judge whether two pivots belong together?

No. It joins the pivots it found, and the judgement about whether those two swings form a meaningful trendline is left to you. That is worth knowing before treating a drawn line as a level.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Fractals Adjustable Period Trend Lines Indicator as one input. Always backtest before trading live.

Category: this is part of our Trend collection. Also, truly, 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