Loading…

Trend Ensemble System

Every single-indicator trend filter is blind in a specific, well-known way. A moving-average slope lags badly at turns. ADX can sit low through a slow, real grind that never produces a sharp directional reading. A swing-structure read needs an actual pivot to have already formed. A channel breakout can be a single spiking bar that gives back the whole move next session. Trading off any one of these alone means inheriting exactly that method's blind spot as a recurring loss pattern. This system runs four independent votes every bar: a plain moving- average slope (value now vs InpMaSlopeLookback bars back), an ADX/DI reading that abstains rather than guesses whenever ADX sits below the threshold, a swing-structure comparison that requires BOTH the recent high and the recent low to have stepped in the same direction (true higher-highs-and-higher-lows, not just one extreme drifting), and a Donchian channel position that flags the close sitting in the outer band of the recent range. A trade only opens when at least InpMinAgreeVotes of the four agree and none of the remaining votes disagrees outright - a genuine supermajority, not a simple plurality. Every entry and every trend-driven exit prints the full four-way vote breakdown to the Experts log, so a losing trade can be diagnosed against exactly which votes carried it rather than treated as an opaque black box. The position is closed the moment the ensemble stops supporting the held direction at all - not necessarily reversing outright, just no longer reaching the supermajority threshold - because holding on a consensus that has already fallen apart defeats the point of requiring one to open the trade. Notes and limitations - Requiring a supermajority means fewer trades than any single-method system - this trades quality of confirmation for quantity of signals, by design. - The swing-structure vote needs InpStructureLookback bars of real price action to compare two halves against each other; on a very short history it can sit neutral for a while. - Only one position is held at a time per chart/magic combination. - Requires AutoTrading enabled to open or close anything.

Expert advisor · MT4 · v1.0 · Free

About Trend Ensemble System

Trend Ensemble System is an expert advisor (trading robot) for MetaTrader 4 based on Moving Average, ADX and ATR. It increases the lot size after a losing trade (martingale) and can size trades from your balance and risk percent. It has 17 settings, such as Ma period, Ma slope lookback and Adx period. MQL source code included.

Files in the download: TrendEnsembleSystem.ex4, TrendEnsembleSystem.mq4, TrendEnsembleSystem.txt.

Trading robots can lose money. Check every setting and test on a demo account before using real funds.

Settings

SettingDefaultWhat it does
Ma period50Moving average period for the slope vote
Ma slope lookback10Bars back to measure the MA slope over
Adx period14ADX / DI period for the ADX vote
Adx threshold22.0Minimum ADX to allow the ADX vote to fire at all
Structure lookback20Bars used for the higher-highs/higher-lows structure vote
Donchian period20Donchian channel period for the breakout-position vote
Donchian band pct0.25Fraction of channel width counted as "near the edge" (0-0.5)
Min agree votes3Minimum agreeing votes out of 4 required to enter (supermajority)
Atr period14ATR period used to size the stop
Atr multiplier2.0Stop distance = ATR * this multiplier
Use risk sizingfalseSize by percent risk instead of a fixed lot
Risk percent1.0Percent of equity risked per trade, when risk sizing is on
Fixed lots0.10Lot size when risk sizing is off, or as a fallback
Magic number20260611Magic number for orders opened by this EA
Slippage pips3Slippage tolerance, in pips
Max retries5Attempts per trade action before giving up
Retry wait ms500Pause between attempts, milliseconds

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
  3. Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
  4. Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
  6. Test it first on a demo account or in the Strategy Tester.

Download the PDF guide

Tags: Breakout · Pivot Points · ADX · Channels & Envelopes · Trend · Trading Sessions · Martingale · Risk & Lot Size · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria