LearnForexHub
EA

EA: TRIX Cross Expert Advisor

Written by , Founder & EditorLast updated How we write and review lessons

Indicators draw and alert; an Expert Advisor goes further and actually submits orders for you. This free EA trades the TRIX indicator's signal-line crossover directly: the moment the triple-smoothed momentum line crosses its own signal line, it opens a trade in that direction, 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 TRIX/Signal crossover itself: TRIX crossing above its signal line signals momentum in the triple-smoothed trend has turned up and triggers a BUY; TRIX crossing below its signal line triggers the mirrored SELL. Both lines are calculated internally by the EA — an EMA of Close, smoothed by another EMA, smoothed by a third EMA, then converted to a percentage rate of change, with the signal line a simple moving average of that result — since there's no built-in TRIX function in either MetaTrader 4 or MetaTrader 5 for the EA to call. Because the recursive EMA cascade needs a run of historical bars to converge to an accurate value, this EA recomputes it over a bounded 150-bar lookback window each time it checks for a new signal, rather than trying to track state tick to tick.

Unlike this site's Aroon Trend EA, which adds a threshold filter on top of its indicator's raw crossover to demand extra conviction, this EA trades the TRIX/Signal cross exactly as it comes, with no additional filter layered on. That's a deliberate choice rather than an oversight — TRIX's own triple-smoothing already does most of the filtering work a separate strength filter would otherwise need to do, which is covered in more detail below.

Stop Loss, Take Profit, and Position Sizing

PriceTake Profit (TP)Stop Loss (SL)BUYTRIX / Signal (oscillates around zero)TRIXSignal
Entry conditions: BUY when TRIX crosses above its Signal line — SELL on the mirrored cross — SL and TP are placed automatically from ATR

Both Stop Loss and Take Profit are sized from ATR rather than a fixed pip distance, so the stop always reflects how much the pair is actually moving right now. Stop Loss distance is ATRMultiplier × ATR (default multiplier 2.0, ATR calculated over ATRPeriod, default 14), and Take Profit is then set at RiskRewardRatio × Stop Loss distance (default 2.0) — every trade this EA opens, on any pair or timeframe, carries the same fixed reward-to-risk proportion.

Sizing uses the worked example from Risk Management Basics directly — RiskPercent (default 1.0%) of balance over the stop distance — so the money at risk stays near-constant as the ATR stop expands and contracts. See Lot Sizes Explained for how this lot size is then normalized to the broker's minimum, maximum, and step lot size before the order is sent. UseFixedLot remains available for anyone preferring a constant lot size independent of the risk calculation.

Entry Conditions

  • BUY — TRIX crosses above its signal line on the just-closed bar (TRIX was at or below the signal line the bar before, and is now above it).
  • SELL — TRIX crosses below its signal line on the just-closed bar — the mirrored condition.

The same three guardrails used across this site's EA collection apply here: signals are evaluated only when a new bar opens (tracked by its open time), so one bar can't fire twice; only one position may be open at once, verified by counting trades under this EA's symbol and magic number; and entries are skipped whenever the live spread exceeds MaxSpreadPoints (default 30). Every order is tagged with MagicNumber (default 20260815), 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

  • TrixPeriod (default 14) — the period used for all three EMA smoothing stages inside TRIX. A shorter period reacts faster but lets more noise through the smoothing; a longer period filters more aggressively at the cost of more lag before a crossover fires.
  • SignalPeriod (default 9) — the simple moving average period applied to TRIX to produce its signal line. A shorter signal period crosses more often and earlier; a longer one waits for a more decisive move.

All other inputs configure the common risk engine described on the EAs overview — how stops and targets are sized, how the lot is calculated from RiskPercent, and which safety checks gate every order. Its orders are tagged with magic number 20260815.

Why This EA Trades the Cross Without an Extra Filter

Several EAs on this site — the Aroon Trend EA and ADX Trend Strength EA most directly — layer a strength or freshness filter on top of a raw crossover, only acting once that extra reading confirms the signal is convincing. This EA doesn't do that, and the reason is specific to how TRIX itself is built: the triple EMA cascade behind TRIX already exists specifically to strip out the short-term, single-bar noise a filter would otherwise need to catch. A raw indicator crossover (like the one traded by Vortex Crossover EA) reacts to a single bar's relationship with the one before it, which is exactly the kind of noise a strength filter is meant to guard against; TRIX's crossover only fires after three layers of smoothing have already absorbed most of that noise, so bolting on a further filter would mostly just add redundant lag rather than meaningfully improve the signal.

The trade-off this EA accepts is the one described in the TRIX lesson itself: slower reactions than an unsmoothed crossover EA, in exchange for fewer whipsaw entries during choppy, directionless conditions. Traders who want an even more conservative version can raise TrixPeriod or SignalPeriod to smooth further; traders who find it too slow can lower them, accepting more of the noise the extra smoothing was filtering out.

A Word of Caution

Before real money, run it on a demo account across several pairs and market phases; good historical or demo results never guarantee the future. This EA can and will lose on individual trades, and because TRIX's triple smoothing means it confirms a shift well after it has already begun, it is especially prone to entering late in a fast-moving reversal after much of the move is already over. Consider combining this EA with a trend or structure filter — see Trend vs Range — rather than running it unfiltered through every market condition. Both platform versions below ship as source code; read them in full, and be sure each parameter's role is clear to you before going live with it. Treat everything here as general education rather than personalized investment advice.

Download trix-cross-ea.mq4

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

Download File

Download trix-cross-ea.mq5

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

Download File

How to install

An EA installs into the Experts folder, not Indicators — this is the step people miss most often.

MetaTrader 4

  1. Download trix-cross-ea.mq4 above.
  2. Open MetaTrader 4FileOpen Data Folder.
  3. Place the file in the MQL4/Experts folder.
  4. Restart MetaTrader 4, then drag it from the Navigator window onto a chart.
  5. Enable AutoTrading (MT4) or Algo Trading (MT5) in the toolbar — the EA places no trades while this is off, even when attached to a chart.
  6. Review and adjust the input parameters in the settings dialog before confirming.

MetaTrader 5

  1. Download trix-cross-ea.mq5 above.
  2. Open MetaTrader 5FileOpen Data Folder.
  3. Place the file in the MQL5/Experts folder.
  4. Restart MetaTrader 5, then drag it from the Navigator window onto a chart.
  5. Enable AutoTrading (MT4) or Algo Trading (MT5) in the toolbar — the EA places no trades while this is off, even when attached to a chart.
  6. Review and adjust the input parameters in the settings dialog before confirming.

Both files are source code. Open and read them in MetaEditor before running them on any account.