Forex
EA

EA: Keltner Channel Breakout Expert Advisor

Last updated 2026-07-23

An indicator only plots a line or fires an alert — an Expert Advisor (EA) actually sends orders on your behalf, which means every design choice inside it carries real money consequences. This free EA trades a breakout strategy built directly on Keltner Channels: it waits for price to close beyond the EMA-and-ATR band that defines "normal" recent movement, then opens a trade in the direction of that breakout, with Stop Loss, Take Profit, and position size all calculated automatically from ATR and account risk.

How the Strategy Works

The entry signal is the same one covered in the Keltner Channels indicator lesson: has the just-closed bar's Close finished above the upper band (EMA + ATR × multiplier), or below the lower band (EMA − ATR × multiplier)? A close above the upper band means price has moved further from its recent EMA than its own recent bar-to-bar volatility would typically produce — read as a bullish breakout. A close below the lower band is the mirrored bearish case. Unlike a reversal strategy that fades a band touch expecting price to snap back, this EA trades in the direction of the break, on the premise that a move large enough to clear an ATR-scaled band is more likely to be the start of a genuine push than routine noise.

Because the EMA and ATR that define the band are recalculated on every bar, the channel itself widens and narrows with current volatility — the exact same distance in pips means something different in a quiet market than a volatile one, and the band adjusts for that automatically before the EA ever checks whether price has broken it.

Stop Loss, Take Profit, and Position Sizing

PriceTake Profit (TP)Stop Loss (SL)BUYUpper / Lower Keltner band
Entry conditions: BUY when price closes above the upper band — SELL when price closes below the lower band — SL and TP are placed automatically from ATR

Stop Loss and Take Profit are sized from ATR rather than a fixed pip distance, using the same ATRPeriod/ATRMultiplier pattern used throughout this site's EAs — note this is a separate ATR reading (ATRPeriod, default 14) from the one used to size the Keltner Channel band itself (ChannelATRPeriod, default 10), so the entry trigger and the risk sizing can be tuned independently. Stop Loss distance is ATRMultiplier × ATR (default multiplier 2.0), and Take Profit is then set at RiskRewardRatio × Stop Loss distance (default 2.0), giving every trade this EA opens the same fixed reward-to-risk shape regardless of pair or timeframe.

Position size follows the exact worked-example method from Risk Management Basics and Lot Sizes Explained: RiskPercent (default 1.0%) of account balance is divided by the Stop Loss distance to produce a lot size, so the dollar amount at risk stays roughly constant even as the ATR-based stop distance changes with volatility. The calculated lot is normalized to the broker's minimum, maximum, and step lot size before the order is sent, and UseFixedLot is available as an escape hatch for a constant lot size regardless of account risk.

Entry Conditions

  • BUY — the just-closed bar's Close is above the upper Keltner Channel band (EMA + ChannelATRMultiplier × ChannelATR).
  • SELL — the just-closed bar's Close is below the lower Keltner Channel band (EMA − ChannelATRMultiplier × ChannelATR).

Three safety mechanics govern every trade this EA can place, matching the standard used across every EA on this site: it evaluates entry conditions once per new bar only, tracked via the bar's open time, so a single qualifying bar can't trigger repeated entries within the same candle; it opens only one position at a time, checked by counting open trades filtered to this EA's own symbol and magic number before any new entry is considered; and it checks the current spread against MaxSpreadPoints (default 30) before sending an order, skipping the entry if the spread is too wide to trade at a reasonable price. Every order is tagged with MagicNumber (default 20260723), so the EA's position-counting logic never touches a trade opened manually or placed by a different EA running on the same account.

Parameters

  • EMAPeriod (default 20) — the period of the Keltner Channel's center EMA line.
  • ChannelATRPeriod (default 10) — the ATR lookback used to size the Keltner Channel's band width.
  • ChannelATRMultiplier (default 2.0) — how many ATR-widths the entry band sits from the center EMA. Narrower values trigger more, smaller breakouts; wider values require a larger move before entering.
  • ATRPeriod (default 14) — the separate ATR lookback used for Stop Loss sizing.
  • ATRMultiplier (default 2.0) — Stop Loss distance = ATR × this multiplier.
  • RiskRewardRatio (default 2.0) — Take Profit distance = Stop Loss distance × this ratio.
  • UseFixedLot — switches position sizing from risk-based to a constant lot size.
  • FixedLotSize (default 0.01) — the lot size used when UseFixedLot is enabled.
  • RiskPercent (default 1.0) — percentage of account balance risked per trade when UseFixedLot is disabled.
  • MaxSpreadPoints (default 30) — skips new entries while the spread is wider than this.
  • MagicNumber (default 20260723) — tags every order this EA places so its position-management logic never touches trades opened by hand or by a different EA.
  • EnableTrading — a master on/off switch, useful for pausing the EA without removing it from the chart.

Why Two Separate ATR Readings Exist

It would be simpler to use one ATR calculation for both the Keltner Channel's band width and the Stop Loss distance, and early in development that's a reasonable starting point — but it couples two decisions that don't actually need to move together. The Keltner Channel's band width determines how far price has to travel before the EA considers a move a genuine breakout at all; the Stop Loss's ATR multiplier determines how much room a trade is given to breathe once it's opened. A trader who wants a tighter entry filter (a narrower ChannelATRMultiplier, catching breakouts earlier) doesn't necessarily want a tighter Stop Loss too — in fact a wider ATRMultiplier on the Stop Loss side is often the right pairing with an earlier, more sensitive entry, since an earlier entry means price has less room to prove the breakout is real before the Stop Loss would otherwise be tested. Keeping ChannelATRPeriod/ChannelATRMultiplier and ATRPeriod/ATRMultiplier as fully separate inputs lets a trader tune "how easily does this EA decide a breakout happened" independently from "how much room does a trade get once it's opened" — two genuinely different questions that happen to both be answered with an ATR multiple.

Installation and Setup

EAs install into a different folder than indicators, and this is the step people miss most often.

  1. Download the file below for your platform.
  2. Open MetaTrader → click FileOpen Data Folder.
  3. Place the file in MQL4/Experts (MetaTrader 4) or MQL5/Experts (MetaTrader 5) — not the Indicators folder.
  4. Restart MetaTrader, then drag the EA from the Navigator window onto a chart.
  5. Enable AutoTrading (MT4) or Algo Trading (MT5) in the toolbar — the EA will not place any trades while this is off, even if it's attached to a chart.
  6. Review and adjust the input parameters in the EA's settings dialog before confirming.

A Word of Caution

Test on a demo account first, across different market conditions and multiple pairs, before risking real money — a good backtest or demo run never guarantees future results. This EA can and will lose on individual trades: a breakout beyond the Keltner Channel confirms only that price has moved further than recent ATR-scaled volatility would typically predict, not that the move continues, and a sharp reversal immediately after entry will still get stopped out at a loss. Consider combining this EA with a trend or momentum filter (a higher-timeframe check, ADX, or Trend vs Range structure) rather than trading Keltner breakouts in every market condition, since a channel break during a genuinely range-bound market is more likely to revert than one during an established trend. Both the MT4 and MT5 files below are source code — open and read them fully, and understand exactly what every parameter does, before attaching this EA to a live account. This content is general education, not personalized investment advice.

Download the EA

How to Install — MetaTrader 4

  1. Download the keltner-channel-breakout-ea.mq4 file below.
  2. Open MetaTrader 4 → click FileOpen Data Folder.
  3. Place the file in the MQL4/Experts folder.
  4. Restart MetaTrader 4, then drag the EA from the Navigator window onto the chart.

How to Install — MetaTrader 5

  1. Download the keltner-channel-breakout-ea.mq5 file below.
  2. Open MetaTrader 5 → click FileOpen Data Folder.
  3. Place the file in the MQL5/Experts folder.
  4. Restart MetaTrader 5, then drag the EA from the Navigator window onto the chart.

Both files are source code — open and review the full code before using it, for your own safety.

Download keltner-channel-breakout-ea.mq4

For MetaTrader 4 — this is source code (.mq4), open and review it fully before using it.

Download File

Download keltner-channel-breakout-ea.mq5

For MetaTrader 5 — this is source code (.mq5), open and review it fully before using it.

Download File