Trend Exhaustion Harvest
Riding a trend is the easy half of a trend-following system; getting out before it gives the trade back is the hard half. Any single exhaustion signal fires constantly on ordinary trending days for reasons that have nothing to do with the trend actually ending: a volume spike on routine news, a momentum wobble mid-trend that resolves and continues, or price legitimately running hot for several bars during a genuine breakout. Exiting on any one of these alone gives back most of a good trend to false alarms. This system checks three genuinely independent exhaustion signals every bar the position is open. A volume climax compares the current bar's tick volume against its own recent average - a burst of participation often marking capitulation or a blow-off. A momentum divergence checks whether price has printed a fresh extreme (a new high for a long position, a new low for a short) that RSI does not confirm - a classic, well-known warning that the move's underlying momentum has already turned before price has. A stretch measure checks how many ATRs the close currently sits from a moving average - an unusually large distance being the ordinary definition of overextension. Only when at least InpMinExhaustionSignals of these three agree, in the direction that would hurt the held position, does the system harvest the trade and close it. Every exit logs which of the three signals fired. Entries are deliberately simple - a fast/slow moving-average cross - because the point of this submission is the exit ensemble, not a novel entry method. Notes and limitations - The exhaustion ensemble only evaluates while a position is open; it plays no role in entries, by design. - Volume here is tick volume (iVolume), the only volume MQL4 has access to on most FX-style symbols - not exchange traded volume. - The initial ATR stop is a hard backstop, not the primary exit; most winning trades are expected to close via the exhaustion ensemble rather than the stop. - 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 Exhaustion Harvest
Trend Exhaustion Harvest is an expert advisor (trading robot) for MetaTrader 4 based on RSI, Moving Average and ATR. It increases the lot size after a losing trade (martingale) and can size trades from your balance and risk percent. It has 18 settings, such as Entry fast ma, Entry slow ma and Volume avg period. MQL source code included.
Files in the download: TrendExhaustionHarvest.ex4, TrendExhaustionHarvest.mq4, TrendExhaustionHarvest.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 |
|---|---|---|
| Entry fast ma | 10 | Fast MA period for the trend-following entry |
| Entry slow ma | 30 | Slow MA period for the trend-following entry |
| Volume avg period | 20 | Bars used to average tick volume for the climax check |
| Volume multiplier | 2.0 | Climax fires when a bar's volume exceeds average * this |
| Rsi period | 14 | RSI period used for the divergence check |
| Divergence lookback | 20 | Bars searched for the prior swing extreme in the divergence check |
| Stretch ma period | 20 | MA period the stretch measure is taken from |
| Atr period | 14 | ATR period used for both the stretch measure and the stop |
| Stretch atr multiple | 3.0 | Stretch fires when price is this many ATRs from the stretch MA |
| Min exhaustion signals | 2 | Minimum of the 3 exhaustion signals required to exit (supermajority) |
| Atr stop multiplier | 3.0 | Initial 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 | 20260613 | 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: Moving Average · ATR · Volume · Divergence · Momentum · Buy/Sell Arrows · Trend · News Trading · MT4 Expert Advisor · MQL4 Source Code