Auto Trend Indicator: Structure Rather Than An Average

Written by Dominic Walsh · Published · Last updated

The auto trend indicator decides direction from structure, not from an average. It remembers the last confirmed swing high and swing low. Direction changes only when a close breaks one of those two levels.

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: Auto Trend Up, Auto Trend Down, Auto Buy, Auto Sell
Alerts popup, push notification, email, sound
Inputs 11

What the Auto Trend Indicator draws on the chart

`Auto Trend Up` runs lime green while direction reads up.

`Auto Trend Down` runs crimson on the other side.

`Auto Buy` uses arrow 233 and `Auto Sell` uses arrow 234 at each flip.

A panel reports the current state and the two levels behind it.

  • Auto Trend Up: line, lime green, width 2
  • Auto Trend Down: line, crimson, width 2
  • Auto Buy: arrow, lime, width 3, arrow code 233
  • Auto Sell: arrow, red, width 3, arrow code 234
Auto trend indicator structure state line and flip arrows on the EURUSD H1 chart.
Auto trend indicator structure state line and flip arrows on the EURUSD H1 chart.

How the Auto Trend Indicator calculates its values

Two levels get remembered

`InpSwing` `4` confirms a fractal with four bars either side. The most recent confirmed high and low get carried forward on every bar until something newer replaces them.

A close decides the flip

Closing above the remembered high sets direction up. Closing below the remembered low sets it down. Between the two the previous state simply holds.

Why an average is missing

Averages lag by construction and produce a direction even in a flat market. Reading structure instead means the state changes only when price does something a chart reader would notice.

How to read the signals

A long unchanged state means price stayed between the two levels.

Flips confirm on a close, so a wick through a level changes nothing.

`InpSwing` `4` puts each level at least four bars behind the current candle.

Marks sit `InpArrowOffset` `45` points from the bar.

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

`EnableAlerts` covers the routes and ships true with `EnablePopup`. Flip `EnablePushNotify` for a phone, `EnableEmail` for mail, or `EnableSound` to sound `SoundFile`. Those three sit off. State changes report once a bar.

Every Auto Trend Indicator input

Core settings

Setting What it does Default
InpSwing Swing fractal strength (bars each side). Bars either side that confirm a fractal, default `4`. 4

Display settings

Setting What it does Default
InpArrowOffset Arrow offset (points). Points between a flip mark and the bar, default `45`. 45
ShowPanel Show trend-state panel. Show the trend state readout, default `true`. on
PanelCorner Corner (0=UL,1=UR,2=LL,3=LR). Which corner the state readout uses, default `0`. 0
PanelBg Readout background colour, default `clrBlack`. black

Alert settings

Setting What it does Default
EnableAlerts Master switch over the flip alerts, default `true`. on
EnablePopup Terminal message on a flip, default `true`. on
EnablePushNotify Phone buzz on a flip, default `false`. off
EnableEmail Email on a flip, default `false`. off
EnableSound Audio cue on a flip, default `false`. off
SoundFile (see inputs panel) alert.wav
Auto trend indicator inputs panel with InpSwing, InpArrowOffset and ShowPanel.
Auto trend indicator inputs panel with InpSwing, InpArrowOffset and ShowPanel.

Settings that fit your chart

Structure reading suits charts with real swings. EURUSD H1 is the reference chart, where the state flips every few days. On M5 the levels update constantly. H4 holds one state for weeks.

When the Auto Trend Indicator fails

A four-bar fractal is shallow, so minor swings can set the levels.

In a tight range price breaks both levels repeatedly.

The state is binary, so it never reports a market with no direction.

Copy the compiled Auto Trend 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: Ichimoku Trend Strategy.

Background reading on the method behind the Auto Trend Indicator: High Speed vendor Feed on Wikipedia, ibands (BANDS) at the MQL5 Documentation.

Download the Auto Trend Indicator for MT4 and MT5

The zip holds the compiled Auto Trend 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

Why does InpSwing 4 use a fractal rather than an average?

Because a fractal marks a place price actually turned. An average produces a number on every bar whether or not anything happened, which is why it reports a direction even in a flat market.

What does InpSwing hold between flips?

The last remembered swing high and low. While price closes between them nothing changes, so a long unchanged state simply means the market has stayed inside that range.

Can a wick flip the Auto Trend Up state?

No. The test reads the close only, so a spike beyond a remembered level that pulls back inside the same bar leaves the direction untouched. Only a completed close can change it.

How late is a level set by InpSwing 4?

At least four bars, since the fractal needs four newer bars to close without beating it. The level a flip tests is therefore never the freshest turn on the chart.

Are results guaranteed?

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

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