Binary Trend Indicator: A KAMA Slope In Two Colours

Written by Dominic Walsh · Published · Last updated

The binary trend indicator gives one answer at a time. Up or down, nothing in between. Behind it sits Kaufman adaptive smoothing, which speeds up in a clean trend and slows down in chop. The slope of that line sets the colour, and a flip prints an arrow.

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

What the Binary Trend Indicator draws on the chart

Binary Up is the lime green line drawn while the baseline is rising.

Binary Down is the red line drawn while it falls.

Trend Buy and Trend Sell mark the bar where the slope changed sign.

A corner panel built from OBJ_LABEL and OBJ_TEXT reports the current bias.

  • Binary Up: line, lime green, width 3
  • Binary Down: line, red, width 3
  • Trend Buy: arrow, lime green, width 3, arrow code 233
  • Trend Sell: arrow, red, width 3, arrow code 234
Binary trend indicator on EURUSD H1 with the two-colour KAMA baseline and flip arrows
Binary trend indicator on EURUSD H1 with the two-colour KAMA baseline and flip arrows

How the Binary Trend Indicator calculates its values

Measuring how clean the move is

The efficiency ratio takes net travel over total path. change holds the distance from the close to the close `InpErPeriod` bars back. volSum adds up every bar-to-bar step in between. A ratio near 1 means a straight run. A ratio near 0 means the market went nowhere the long way round.

Turning that ratio into smoothing

sc slides between the fast and slow constants set by `InpFastEma` `2` and `InpSlowEma` `30`. The code then squares it. A clean trend pushes sc toward the fast end, so the baseline hugs price. Chop pushes it toward the slow end and the line flattens out.

Reading the slope

KamaBuf recurses from the oldest bar forward, seeded on the first close so it never spikes. slope takes 1 when the new value exceeds the previous one and -1 when it does not. A change of sign writes the arrow and switches which line buffer carries the value.

How to read the signals

Colour is the whole signal. Green means the baseline rose on this bar.

A flat stretch of line means the efficiency ratio has collapsed.

Flips cluster when the market ranges, which is the honest cost of a two-state tool.

The panel repeats what the colour already tells you, in words.

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

`EnableAlerts` ships on and `EnablePopup` carries the message. `EnablePushNotify`, `EnableEmail` and `EnableSound` are off by default. `SoundFile` names the clip. The guard allows one flip message per closed bar.

Every Binary Trend Indicator input

Core settings

Setting What it does Default
InpErPeriod Efficiency Ratio period. Bars in the efficiency ratio, default `10`. Raise it to judge cleanliness over a longer stretch. 10
InpFastEma Fast EMA constant. Fast smoothing constant, default `2`. This is the speed the line reaches in a clean trend. 2
InpSlowEma Slow EMA constant. Slow smoothing constant, default `30`. This is where the line settles in chop. 30

Display settings

Setting What it does Default
InpArrowOffset Arrow offset (points). Flip arrow distance from the bar in points, default `60`. 60
ShowPanel Show CALL/PUT bias panel. Draws the corner bias panel, default `true`. on
PanelCorner Corner (0=UL,1=UR,2=LL,3=LR). Panel corner, default `0` for upper left. 0
PanelBg Panel background colour, default black. black

Alert settings

Setting What it does Default
EnableAlerts Switches the flip alerts on as a group, default `true`. on
EnablePopup Raises the terminal dialog on a flip, default `true`. on
EnablePushNotify Sends the flip to the MetaTrader mobile app, default `false`. off
EnableEmail Mails the flip through the terminal, default `false`. off
EnableSound Plays a file when the slope flips, default `false`. off
SoundFile Name of the wav file the flip alert uses, default `alert.wav`. alert.wav
Binary trend indicator inputs: InpErPeriod, InpFastEma, InpSlowEma, ShowPanel
Binary trend indicator inputs: InpErPeriod, InpFastEma, InpSlowEma, ShowPanel

Settings that fit your chart

Adaptive smoothing earns its keep where trends and ranges alternate. EURUSD H1 is the reference chart. There `InpErPeriod` at `10` covers under half a day. On M5 the line still adapts, but flips arrive often enough to tire you out. On H4 each colour stretch tends to cover a real leg.

When the Binary Trend Indicator fails

Two states means the line always claims a direction, even when there is not one.

The efficiency ratio reacts to the last `InpErPeriod` bars only. A regime change further back is invisible to it.

A flip marks the bar the slope turned, which is after the turn in price.

Copy the compiled Binary 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.

Background reading on the method behind the Binary Trend Indicator: National market system plan on Wikipedia, Daytrader at Investopedia.

Download the Binary Trend Indicator for MT4 and MT5

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

What does InpErPeriod at 10 actually measure?

How direct the last ten bars were. The code divides the net distance travelled by the sum of every individual bar step. A straight run gives a ratio near 1. A market that wandered up and down to the same place gives a ratio near 0.

Why do InpFastEma and InpSlowEma read 2 and 30?

They are the two ends of the smoothing range, not periods you would plot. The efficiency ratio slides the actual smoothing between them each bar. `InpFastEma` `2` is how quick the line gets in a clean trend, and `InpSlowEma` `30` is how slow it goes in chop.

What separates the Binary Up and Binary Down plots?

Only the sign of the slope. Both carry the same baseline value. When the new reading sits above the previous one the lime buffer takes it, otherwise the red one does. The code also backfills one bar at each flip so the colours join without a gap.

Does the ShowPanel readout add anything?

It repeats the current bias in words and puts it in a fixed corner. That helps when several tools share a chart and the line colour is hard to pick out. Set `ShowPanel` to false and nothing about the calculation changes.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Binary 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