Martingaletrademanager Settings/Inputs Guide for MT4 & MT5

Martingaletrademanager Settings/Inputs Guide for MT4 & MT5

12 March 2026, 08:47
Biswarup Banerjee
0
185

Complete User Documentation — MT4 & MT5

1. OVERVIEW

The EA MartingaleTradeManager automates a classic Martingale recovery strategy: after a losing trade, it immediately opens an opposite-direction trade with a larger lot size. The core idea is that a single winning trade can recover a sequence of prior losses, but you need tight control over the multiplier, step count, and risk parameters to avoid blowing your account. This EA handles all that logic for you, checking each closed trade's profit and firing the next counter-trade automatically.

Who Should Use It: Experienced retail forex traders who understand Martingale risk mechanics and want a disciplined, automated way to run a recovery strategy without manual monitoring.

Main Benefit: You get a fully configurable Martingale engine that handles trade sequencing, lot scaling, and virtual stop-loss/take-profit management, freeing you from having to watch every tick.


2. INPUT PARAMETERS & SETTINGS

This product shares a common set of general input settings with all Utility products in this series. The following sections are covered in the common guide: Position Sizing, Alert Settings (popup, push notification, email), Trade Time Settings (session-based time filters), Trade Days Settings (per-day enable/disable with broker start and end times, covering Monday through Sunday), and Day-wise Time Filter Settings (close trades if outside valid trading time). For full details refer to the Common General Input Settings Guide. The sections below cover only the product-specific inputs unique to this product.

General Settings

These parameters define how the EA starts trading, what trade direction it takes first, how it handles virtual SL/TP lines, and whether swap costs and historical trade data factor into its profit calculations.

Setting Name Type Default Value Description Example
Enable first trade bool true Controls whether the EA places the initial trade automatically. Set to false if you want to manually open the first position and let the EA handle only the recovery sequence from there. false — Use when you already have a position open and want the EA to manage only the Martingale recovery after that trade closes.
First trade type frist_trade_type FIRST_TRADE_BUY Selects whether the EA's first trade is a buy or a sell. This sets the initial direction for the entire Martingale cycle, so choose based on your market bias or trend analysis. FIRST_TRADE_SELL — Pick this if you expect a downtrend and want the recovery sequence to start with a short position.
Chart lines for virtual SL/TP (never drawn during optimization) bool false When enabled, draws horizontal lines on the chart showing where the virtual stop loss and take profit levels are placed. Useful for visual verification during live trading, but never drawn during backtest optimization to avoid clutter. true — Turn this on when running on a demo account to see exactly where your virtual SL/TP sits relative to price action.
Include Swap charges in Profit bool true Determines whether overnight swap fees are included when calculating whether a closed trade was profitable. Set to false if you want the EA to ignore swap costs and consider only raw price movement. false — Use when trading pairs with high swap rates (e.g., exotic crosses) to prevent swap charges from triggering false recovery signals.
Enable history for backtests or optimization bool false When enabled, the EA loads historical trade data from the account to simulate the Martingale sequence during backtests. Leave disabled for standard backtests; enable only if you need to test recovery from a specific prior trade history. true — Enable this when running a custom backtest scenario where you want the EA to start from a known losing streak in the history.

Trend Filter Settings

These settings let you gate the Martingale recovery logic behind a trend filter, so the EA only opens counter-trades when a majority (or all) of your enabled trend indicators agree on the direction.

Setting Name Type Default Value Description Example
Trend filter gating mode ENUM TREND_FILTER_LOGIC_ALL See options explained below. See options explained below.
Quorum: minimum enabled-filter votes required (0 = majority) int 3 When gating mode is set to quorum, this defines how many of the enabled trend filters must agree before the EA opens a recovery trade. Set to 0 to use a simple majority of enabled filters. 2 — If you have 5 trend filters enabled, setting this to 2 means at least 2 must agree, which is a looser filter than requiring all 5.

Trend filter gating mode — Options Explained

This setting controls how the EA decides whether the current market trend supports opening a recovery trade. You can require all enabled filters to agree, or use a quorum system where only a subset must align.

TREND_FILTER_LOGIC_ALL: Every single enabled trend filter must produce a signal in the same direction before the EA will open a Martingale counter-trade. This is the strictest setting and reduces false entries, but may cause the EA to skip trades during choppy or low-conviction markets. Use this when you


3. HOW IT WORKS

Core Calculation & Logic

The EA MartingaleTradeManager watches the outcome of the last closed trade on the chart it's attached to. It checks whether that trade ended in profit or loss. If it was a loss, the EA immediately opens a new trade in the opposite direction — that's the core Martingale recovery mechanism. The idea is that a single winning trade in the opposite direction will recoup the previous loss, plus generate a small profit. The EA keeps repeating this process — loss triggers an opposite trade — until it finally books a winner. It does not use any indicators, price patterns, or market analysis; it's purely a sequence-based recovery system.

Mathematically, the EA relies on the assumption that losses will eventually be followed by a winning trade, and that the trade size (lot) stays constant. Unlike a classic Martingale that doubles lot size after each loss, this EA keeps the lot size fixed — which limits risk but also means recovery may take more steps if losses string together. The EA does not calculate probabilities or adjust for volatility; it simply reacts to the last trade's result.

How It Operates

The EA monitors the account's trade history for the current symbol. As soon as a trade closes, it evaluates the profit/loss of that trade. If the trade was a loss (negative profit), the EA opens a new trade in the opposite direction — if the loss was a buy, it opens a sell, and vice versa. If the trade was a profit, the EA does nothing and waits for the next trade to close. This cycle repeats indefinitely: each loss triggers an opposite-direction trade, and each win resets the sequence.

The EA also respects a scan mode setting. You can choose to have it check on every tick (most responsive) or on a periodic timer (less CPU load). In either mode, it only acts when a new closed trade is detected. The EA does not open multiple trades at once; it manages one trade at a time per chart. If you want to run multiple instances, you'll need separate charts and different magic numbers.

Key Features in Detail

What sets this EA apart from a simple script is its full automation of the Martingale recovery loop — you don't need to manually flip positions after each loss. It also offers hidden stop loss and take profit levels, which can be useful if you want to keep your exit strategy private on a shared platform. The flexible SL/TP calculation mode (pips, amount, percent, or none) lets you tailor risk management to your account size and trading style. And the scan mode option gives you control over how aggressively the EA checks for new trades.

Step-by-Step Workflow

Step 1: Enable first trade: Set Enable first trade to true so the EA will open the initial position when attached to a chart. If you prefer to start manually, set it to false .

Step 2: Choose trade direction: In First trade type, pick FIRST_TRADE_BUY or FIRST_TRADE_SELL — this sets the direction of the very first trade. After that, the EA will automatically flip direction after each loss.

Step 3: Set lot size: Enter your desired lot size in Lot Size. Start small — 0.01 is a safe bet for testing. The EA does not increase lot size after losses, so this value stays constant.

Step 4: Configure stop loss and take profit: Choose your SL/TP mode (Pips, Amount, Percent, or No Stoploss and Takeprofit). Then enter your stop loss and take profit values. For example, in Amount mode, set StopLoss in Amount to 10 and TakeProfit in Amount to 20 for a 1:2 risk-reward ratio.

Step 5: Decide on hidden SL/TP: If you want the stop loss and take profit to be invisible on the chart (they still work), set Hide Stoploss and Takeprofit to true . This is handy if you're on a platform where other traders can see your levels.

Step 6: Choose scan mode: In Scan Mode, select Every Tick for immediate reaction to trade closures, or Periodic to reduce CPU usage. For most users, Every Tick is fine.

Step 7: Set magic number (optional): If you're running multiple EAs or manual trades, enable a unique magic number to avoid conflicts. Otherwise, leave it disabled.

Step 8: Start the EA: Drag the EA onto your chosen chart, ensure AutoTrading is enabled in MetaTrader, and let it run. Monitor the first few trades to confirm it's behaving as expected.


4. KEY FEATURES & CAPABILITIES

This section highlights the main features that make the EA MartingaleTradeManager a practical tool for automated recovery trading.

Feature Description
First Trade Type Lets you choose whether the initial trade is a buy or sell. After that, the EA automatically flips direction after each loss, so you only set this once.
Fixed Lot Size Unlike classic Martingale EAs that double lot size, this one keeps the lot constant. That limits risk but also means recovery may take more steps if losses stack up.
Flexible SL/TP Mode Choose between pips, account currency amount, percent of balance, or no SL/TP at all. This lets you match your risk management style exactly.
Hidden SL/TP Stop loss and take profit levels can be hidden from the chart while still functioning. Useful if you're on a shared platform or want to keep your exits private.
Scan Mode Choose between checking every tick (instant reaction) or on a periodic timer (lower CPU load). Both work fine; pick based on your system's performance.

Quick Start Guide

Follow these steps to get started in under 5 minutes:

  1. Download and install: Get the EA from the MQL5 Market and place it in your Experts folder. Restart MetaTrader if needed.
  2. Open a chart: Select the currency pair you want to trade — EURUSD is a good starting point. Use the M1 or M5 timeframe; the EA doesn't rely on chart timeframes.
  3. Attach the EA: Drag the EA from the Navigator panel onto the chart. A settings dialog will open.
  4. Set your first trade: Leave Enable first trade as true and choose First trade type — buy or sell, based on your market bias.
  5. Configure risk: Set Lot Size to 0.01 for testing. Choose Stoploss and Takeprofit calculation mode as Pips and enter, say, 20 for stop loss and 40 for take profit.
  6. Enable AutoTrading: Click the AutoTrading button in MetaTrader (it should turn green). Also check that Algo Trading is enabled in the Tools > Options menu.
  7. Monitor the first cycle: Watch the EA open its first trade. If it closes at a loss, the EA should immediately open an opposite trade. Verify this behavior before leaving it unattended.


Installation Guide for MQL Products | Updating Purchased MQL Products on MT4/MT5 | General Troubleshooting Guide | Indicator Settings / Guide

Check all my products: https://www.mql5.com/en/users/biswait50/seller

Contact me for support: https://www.mql5.com/en/users/biswait50