Loading…

Envelope Fade EA

A trending market makes price "walk the band" - close after close pinned against the outer envelope while the moving average underneath keeps climbing or falling with it. Fading the very first touch trades straight into that walk and loses repeatedly during any real trend. This implementation requires one more step: the prior bar has to have closed outside the band, and the current bar has to close back inside it, before a fade is taken. That confirms rejection rather than guessing that a touch is automatically a reversal. Stop loss and take profit are fixed pip distances, converted to points per symbol from the broker's own digit count. Position sizing can run as a fixed lot or, with InpUseRiskSizing on, as a percentage of equity risked to the stop distance, using the symbol's tick value and tick size rather than a hardcoded contract size so it prices correctly on gold, indices and JPY crosses as well as plain FX pairs. Notes and limitations - The re-entry confirmation reduces, but does not remove, the risk of fading a genuine trend - a strong move can briefly close back inside the band and then resume outward. - Envelope width is a fixed percentage of the moving average, not volatility-adjusted, so the same setting behaves differently in calm and turbulent conditions - review it per symbol. - Signals are evaluated once per closed bar, not on every tick. - One position at a time, tracked by InpMagicNumber. It will not manage or interfere with trades opened manually or by another EA. - Requires AutoTrading enabled and trading permitted at the terminal, account and program level; if trading is disabled the EA logs it and skips the entry. - On MQL5 netting, opening the new fade after closing the opposite position is refused outright if a foreign-magic position already sits on the symbol, rather than risk merging into it.

Expert advisor · MT4 · v1.0 · Free

About Envelope Fade EA

Envelope Fade EA is an expert advisor (trading robot) for MetaTrader 4 based on Channels & Envelopes. It can size trades from your balance and risk percent. It has 11 settings, such as Ma period, Deviation percent and Stop loss pips. MQL source code included.

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

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

Settings

SettingDefaultWhat it does
Ma period20Envelope basis moving average period
Deviation percent0.2Envelope band width, percent of the basis
Stop loss pips40Stop loss distance, in pips
Take profit pips60Take profit distance, in pips (0 = none)
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 number20260702Magic 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: Moving Average · Channels & Envelopes · Trend · Risk & Lot Size · MT4 Expert Advisor · MQL4 Source Code

Expert advisors (EA) for MT4 & MT5 · PolyMaria