Hedgetrademanager Settings/Inputs Guide for MT4 & MT5

Hedgetrademanager Settings/Inputs Guide for MT4 & MT5

12 March 2026, 08:47
Biswarup Banerjee
0
316

Complete User Documentation — MT4 & MT5

1. OVERVIEW

The Hedge Trade Manager is an expert advisor that automatically opens a hedge trade when the last position hits a user-defined loss in pips. It uses a step-based hedging algorithm where each new hedge position can increase in lot size — either by multiplication or increment — to recover losses. This solves the problem of manually monitoring losing trades and deciding when to hedge, giving you a systematic, rules-based approach to protecting capital.

Who Should Use It: Retail forex traders who run multiple positions and want an automated safety net against adverse moves without constantly staring at the screen.

Main Benefit: Automatically deploy hedge trades at a precise loss threshold, with configurable lot scaling, so you can let the EA manage the risk while you focus on the bigger picture.


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 settings control the initial trade behavior, how virtual stop-loss and take-profit lines appear on your chart, and whether swap costs and historical data are factored into the EA's calculations.

Setting Name Type Default Value Description Example
Enable first trade bool true Turns the initial trade on or off. Set to false if you only want the EA to manage existing manual trades without opening new ones — handy for testing or when you're already in a position. true — Use this when you want the EA to start trading immediately upon activation.
First trade type frist_trade_type FIRST_TRADE_BUY See options explained below. FIRST_TRADE_BUY — Choose this for a bullish market outlook.
Chart lines for virtual SL/TP (never drawn during optimization) bool false When true, draws horizontal lines on the chart showing where your virtual stop-loss and take-profit levels sit. The EA never draws these during optimization runs to keep things fast. Useful for visual confirmation during live trading or manual backtesting. true — Enable this on your live chart to see exactly where your virtual SL/TP levels are placed.
Include Swap charges in Profit bool true Decides whether overnight swap fees are added to the profit calculation that triggers hedging. Set to false if you want to ignore swap costs and only consider pure price movement — useful for short-term strategies where swaps are negligible. false — Use this when scalping on low-swap pairs to avoid swap charges skewing your hedge trigger.
Enable history for backtests or optimization bool true Controls whether the EA loads historical tick data during backtests or optimization. Disable it if you're only testing the current market state and want faster runs. Keep enabled for realistic backtests that simulate past conditions. true — Keep this on for a thorough backtest over the last 6 months of EURUSD data.

First Trade Type — Options Explained

This setting determines the direction of the first trade the EA opens. Pick the one that matches your market bias — it's the foundation for the entire hedging sequence.

FIRST_TRADE_BUY: Opens a buy position first. Use this when you expect the market to rise. The EA will then hedge with sell trades if the buy goes into loss. This is the default and works well in bullish trends.

FIRST_TRADE_SELL: Opens a sell position first. Choose this for bearish expectations. The EA will hedge with buy trades if the sell goes into loss. Good for downtrends or when you're short-biased.

Trend Filter Settings

These settings let you gate trade signals through a multi-filter voting system, so a trade only fires when enough 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. TREND_FILTER_LOGIC_ALL — Use when you want maximum confirmation before any trade is taken.
Quorum: minimum enabled-filter votes required (0 = majority) int 3 Sets how many of the enabled trend filters must agree before a trade is allowed. A value of 0 means a simple majority of the enabled filters is enough. This gives you fine control over how strict the filter is — higher numbers mean fewer but higher-conviction trades. 2 — Use this when you have 5 filters enabled and want at least 2 to agree, reducing false signals without being too restrictive.

Trend Filter Gating Mode — Options Explained

This setting defines the logic for how multiple trend filters combine to gate


3. HOW IT WORKS

Core Calculation & Logic

The Hedge Trade Manager continuously monitors the floating profit or loss of the most recently opened position, measuring the drawdown in pips from the opening price. When that drawdown exceeds the user-defined loss threshold (set via the Stoploss in Pips or equivalent amount/percent input), the EA calculates the required hedge trade size and direction. The core math is straightforward: it compares the current price against the last position's open price, converts the difference into pips using the symbol's point value adjusted for 3- or 5-digit brokers, and triggers a hedge if the loss exceeds the limit. This pip-based approach works across all instruments without needing to know account currency or margin rates.

What sets this apart from a simple martingale or grid is that it only hedges the last position, not the entire basket. This prevents runaway exposure and keeps the hedge proportionate to the most recent adverse move. The EA also respects the Risk Reward Ratio input — if set above zero, it will calculate take-profit levels based on the loss distance, ensuring the hedge has a favorable risk profile.

How It Operates

The EA attaches to a single chart and monitors all positions for that symbol. On every tick (or every bar, depending on the Scan Mode setting), it checks if a hedge trade is already open for the last position. If not, it calculates the current loss in pips. When that loss exceeds the stop-loss value you've configured, it opens a hedge trade in the opposite direction — if the last position was a buy, it opens a sell hedge, and vice versa. The hedge trade uses the lot size defined in Lot Size and applies the stop-loss and take-profit settings you've chosen.

The EA also applies a hidden SL/TP system. When Hide Stoploss and Takeprofit is enabled, the actual stop-loss and take-profit levels are set far away from the market, while the EA manages virtual levels internally. This keeps your strategy hidden from brokers and other market participants. The virtual levels are recalculated on every tick, and the EA closes the hedge trade when price hits the virtual take-profit or stop-loss. You can optionally display these virtual lines on the chart by enabling Chart lines for virtual SL/TP, though this is disabled during optimization to avoid clutter.

Key Features in Detail

The Hedge Trade Manager stands out by combining automated hedging with a hidden SL/TP system that protects your strategy from broker scrutiny. Unlike basic hedging tools, it supports three calculation modes for stop-loss and take-profit — pips, amount, or percentage — giving you flexibility across different account types and risk preferences. The EA also logs every action to the Experts tab when Capture Logs is enabled, making it easy to audit its decisions during backtesting or live trading. And because it works with both manually opened positions and those from other EAs, you can integrate it into an existing trading setup without changing your workflow.

Step-by-Step Workflow

Step 1: Attach the EA to a chart: Drag the Hedge Trade Manager onto any currency pair or instrument chart. Make sure auto-trading is enabled in the platform.

Step 2: Configure the first trade: Set Enable first trade to true and choose First trade type — Buy or Sell — depending on your market bias. The EA will open this initial position immediately.

Step 3: Set your lot size: Enter a value in Lot Size. Start with 0.01 for testing, then increase once you're comfortable with the hedging behavior.

Step 4: Define the loss threshold: In the Stoploss and Takeprofit calculation mode, choose Pips, Amount, or Percent. Then set the corresponding stop-loss value — this is the drawdown that triggers the hedge. For example, set Stoploss in Pips to 20 to hedge when the last position loses 20 pips.

Step 5: Set take-profit for the hedge: Enter a take-profit value in the same mode. If you want the hedge to target a 1:1 risk-reward ratio, set it equal to the stop-loss. Or enable Risk Reward Ratio and enter a multiplier like 2 to automatically calculate the take-profit as twice the loss distance.

Step 6: Enable hidden SL/TP (optional): Leave Hide Stoploss and Takeprofit set to true to keep your levels private. If you want to see the virtual lines on the chart, enable Chart lines for virtual SL/TP.

Step 7: Turn on logging for testing: Set Capture Logs to true during your first few runs. Check the Experts tab to see when hedges are opened and closed — this helps you verify the logic before going live.

Step 8: Monitor and adjust: Watch how the EA handles market moves. If the hedge triggers too early or too late, tweak the stop-loss value. You can also change the scan mode — Every tick gives faster reaction but uses more CPU; Check every period is lighter and works well on slower timeframes.


4. KEY FEATURES & CAPABILITIES

The Hedge Trade Manager packs several practical features that make it more than a simple hedging script. Here's what you can expect:

Feature Description
Automatic Hedge Trigger Opens a hedge trade in the opposite direction when the last position hits a user-defined loss in pips, amount, or percent. No manual intervention needed.
Three SL/TP Calculation Modes Choose between pips, fixed amount, or percentage for setting stop-loss and take-profit. Adapts to different account currencies and trading styles.
Hidden Stop-Loss & Take-Profit Virtual SL/TP levels managed internally while real levels are set far away. Keeps your strategy hidden from brokers and prevents stop-hunting.
Risk Reward Ratio Calculator Automatically sets the hedge's take-profit based on a multiplier of the loss distance. Enter 2 for a 1:2 risk-reward, or 0 to disable.
Flexible Scan Mode Choose between checking conditions on every tick for fast reaction, or once per bar for lower CPU usage. Useful for optimizing performance on slower machines.
Detailed Activity Logging When enabled, writes every hedge trigger, SL/TP hit, and trade closure to the Experts tab. Invaluable for debugging and backtest analysis.

Quick Start Guide

Follow these steps to get started in under 5 minutes:

  1. Download and install: Purchase the EA from the MQL5 Market and install it via the platform's Navigator panel. Drag it onto any chart — EURUSD works well for testing.
  2. Enable auto-trading: Click the AutoTrading button in MetaTrader (the green triangle) and make sure Algo Trading is enabled in the Tools > Options menu.
  3. Set the first trade: Leave Enable first trade as true and set First trade type to Buy. The EA will open a 0.01 lot buy immediately.
  4. Configure the hedge trigger: Set Stoploss in Pips to 15 (or use Amount mode with a value like 10 in your account currency). This tells the EA to hedge when the buy loses 15 pips.
  5. Set take-profit: Enter 15 in TakeProfit in Pips for a 1:1 risk-reward on the hedge. Or enable Risk Reward Ratio and set it to 2 for a 1:2 ratio.
  6. Enable logging: Set Capture Logs to true. Open the Experts tab (View > Terminal > Experts) to watch the EA's decisions in real time.
  7. Start the EA: Click OK on the input dialog. The EA will open the first trade, then wait for the loss threshold to be hit before placing the hedge. Let it run for a few hours on a demo account to see the logic in action.
  8. Review and tweak: Check the Experts tab for log entries like "Hedge trade opened" or "Virtual SL hit". Adjust the stop-loss value if hedges trigger too early or too late for your strategy.


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