Momentum Rotation EA
Attach this to any chart - the chart's own symbol is used only for the bar clock that drives the rotation timer. Every ranking and trading decision reads the comma-separated symbols in InpWatchlist instead, and the EA can hold a position in any one of them at a time. That cross-symbol reading is the trap this EA is built to avoid. A symbol with no chart currently open has no guarantee its price history is loaded in the terminal, so MarketInfo() or iClose() called on it can silently return zero, or a stale value, rather than failing loudly. Scoring a symbol on a zero-return close would rank it as a momentum collapse it never actually had. Every symbol in the watchlist is put through SymbolSelect() and a minimum bar-count check before its momentum is trusted; a symbol that fails either check is simply dropped from that cycle's ranking, logged, and reconsidered next time. Momentum itself is a plain trailing rate of change over InpMomentumPeriod bars. The leader is whichever watchlist symbol has the highest reading, provided it also clears InpMinMomentum - a floor that keeps the EA flat rather than long the "best of a bad lot" when every candidate is falling. Rotation is checked every InpRotationBars closed bars rather than every bar, which is both closer to how this class of system is normally run (weekly or monthly rebalancing) and avoids switching horses on noise. Only one position is held at a time, sized by ATR-based risk on whichever symbol is currently the leader, using MODE_TICKVALUE and MODE_TICKSIZE rather than assuming every watchlist symbol shares a contract size. Notes and limitations - Long-only. It rotates into the strongest symbol or stays flat; it does not short the weakest. - Every watchlist symbol must have enough bars of history loaded for InpMomentumPeriod to compute. A symbol that fails the check is dropped from that cycle's ranking, not treated as a zero score. - Ranking uses trailing rate of change only - no volatility adjustment, so a low-volatility symbol with a modest steady gain can be ranked below a volatile symbol's larger, choppier one. - One position at a time across the whole watchlist, tracked by InpMagicNumber, regardless of which symbol it is currently on. - Requires AutoTrading enabled and IsTradeAllowed() true; if trading is disabled the EA logs it and skips both the rotation-out and rotation-in legs that bar.
Expert advisor · MT4 · v1.0 · Free
About Momentum Rotation EA
Momentum Rotation EA is an expert advisor (trading robot) for MetaTrader 4 based on ATR. It can size trades from your balance and risk percent. It has 13 settings, such as Watchlist, Momentum period and Rotation bars. MQL source code included.
Files in the download: MomentumRotationEa.ex4, MomentumRotationEa.mq4, MomentumRotationEa.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 |
|---|---|---|
| Watchlist | EURUSD,GBPUSD,USDJPY,AUDUSD,USDCAD | Comma-separated symbols to rank |
| Momentum period | 60 | Bars used to measure trailing rate of change |
| Rotation bars | 240 | Bars between rotation checks (0 = check every closed bar) |
| Min momentum | 0.0 | Minimum rate of change (percent) the leader must clear to hold anything |
| Atr period | 14 | ATR period, used only to size the position by risk |
| Stop atr multiple | 3.0 | Stop loss distance from entry, in ATR multiples |
| 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 | 20260708 | 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: Momentum · Trailing Stop & Break-even · Risk & Lot Size · ATR · MT4 Expert Advisor · MQL4 Source Code