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
| Setting | Default | What it does |
|---|---|---|
| Ma period | 50 | Moving average period for the slope vote |
| Ma slope lookback | 10 | Bars back to measure the MA slope over |
| Adx period | 14 | ADX / DI period for the ADX vote |
| Adx threshold | 22.0 | Minimum ADX to allow the ADX vote to fire at all |
| Structure lookback | 20 | Bars used for the higher-highs/higher-lows structure vote |
| Donchian period | 20 | Donchian channel period for the breakout-position vote |
| Donchian band pct | 0.25 | Fraction of channel width counted as "near the edge" (0-0.5) |
| Min agree votes | 3 | Minimum agreeing votes out of 4 required to enter (supermajority) |
| Atr period | 14 | ATR period used to size the stop |
| Atr multiplier | 2.0 | Stop distance = ATR * this multiplier |
| Use risk sizing | false | Size by percent risk instead of a fixed lot |
| Risk percent | 1.0 | Percent of equity risked per trade, when risk sizing is on |
| Fixed lots | 0.10 | Lot size when risk sizing is off, or as a fallback |
| Magic number | 20260611 | Magic number for orders opened by this EA |
| Slippage pips | 3 | Slippage tolerance, in pips |
| Max retries | 5 | Attempts per trade action before giving up |
| Retry wait ms | 500 | Pause between attempts, milliseconds |
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Experts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the expert advisor from the Navigator onto a chart, check the settings, allow Algo/Auto Trading and press OK.
- Test it first on a demo account or in the Strategy Tester.
Tags: Breakout · Pivot Points · ADX · Channels & Envelopes · Trend · Trading Sessions · Martingale · Risk & Lot Size · MT4 Expert Advisor · MQL4 Source Code