MT5 Portfolio Hedge Supervisor EA (Gold Grid Protection Bot)

MQL5 エキスパート

仕事が完了した

実行時間2 日
開発者からのフィードバック
Thanks for the project. Looking forward to the next one!

指定

I need an MT5 Expert Advisor (MQL5) that works as a portfolio-level hedge supervisor for my gold grid EAs.

Key idea:

The EA will NOT open normal trading positions. It will only:

– Monitor account margin level.
– When margin level drops below a defined threshold (for example 250%), open a hedge position in the opposite direction of my net exposure.
– Use the hedge profit to “pay off” the oldest losing trade.
– If the market reverses and my grids recover, close the hedge at break-even (hedge loss offset by grid profit) and let the grids continue normally.

This EA will run on one chart only and manage risk for the whole portfolio (multiple XAU pairs and multiple magic numbers).

Platform and account

– MetaTrader 5
– Hedging account (not netting)
– Symbols mainly XAU pairs (XAUUSD, XAUJPY, XAUEUR etc.)
– Multiple grid EAs already running, each with its own magic number

Logic – high level

  1. The EA runs on one chart (any symbol).
  2. On every tick it reads:
    – Balance, Equity, Margin, MarginLevel%.
  3. It builds a list of “protected trades”:
    – Only trades whose symbol is in a user-defined list (e.g. XAUUSD,XAUJPY,XAUEUR).
    – Only trades whose magic is in a user-defined list (e.g. 1001,1002,1003).
    – It must exclude its own hedge trades (separate hedge magic number).

Hedge activation (when there is no active hedge)

– If MarginLevel < MarginLevel_Trigger (for example 250%) and there is at least one losing trade in the protected set:

  1. Find the “oldest losing trade” (Profit < 0, earliest open time).
  2. Decide the hedge symbol:
    – Either the same symbol as that oldest losing trade, or a master symbol such as XAUUSD (user input).
  3. Calculate exposure:
    – Option 1 (BY_NET_EXPOSURE): sum all buy lots minus sum all sell lots of protected trades and take the absolute value.
    – Option 2 (BY_OLDEST_TRADE): use only the lot size of the oldest losing trade.
  4. Hedge lot size:
    – TargetHedgeLot = exposure_lots × HedgeFactor (e.g. 0.30).
    – Calculate MaxLotByMargin based on FreeMargin, Margin per lot, and a SafetyFactor (e.g. 0.7 so we do not use all free margin).
    – HedgeLot = min(TargetHedgeLot, MaxLotByMargin, MaxHedgeLot).
    – If HedgeLot < MinHedgeLot (e.g. 0.01), then do not open a hedge.
  5. Hedge direction:
    – Always opposite to the main exposure (or opposite to the oldest losing trade if using that mode).
  6. Open one market hedge position with a separate hedge magic number.
  7. Only one hedge position can exist at any time.

Hedge management (when a hedge is active)

There are two main behaviours:

A) Recoup oldest loser (trend continues against the grids)

– Rebuild the protected trades list.
– Find all losing trades (Profit < 0). If none exist, skip recoup and go to neutralisation logic.
– Select the oldest losing trade.
– Let:
– hedge_profit = profit of the hedge (money, can be positive or negative).
– oldest_profit = profit of the oldest losing trade (negative).
– Recoup rule:
– If hedge_profit + oldest_profit ≥ Recoup_Threshold (usually 0):
– Close the hedge position.
– Close that oldest losing trade.
– Reset internal state (no active hedge).
– Respect a cool-down time between actions (e.g. 60 seconds) so the EA does not over-trade.

Result: the hedge has effectively “paid for” the oldest loser, reducing grid exposure and improving margin.

B) Neutralise hedge (market reverses in favour of the grids)

– Calculate total_grid_profit = sum of Profit for all protected trades (can be overall positive when grids are recovering).
– Optionally require MarginLevel to be above a buffer (e.g. Neutralise_Margin_Buffer = 260) to avoid neutralising too early.
– Neutralisation rule:
– If hedge_profit + total_grid_profit ≥ Neutralise_Threshold (usually 0):
– Close the hedge position only.
– Do NOT close any grid trades.
– Reset internal state.

Result: the hedge is removed at or near break-even (its loss is offset by the grid profit), and the grid trades are left to reach their normal take-profit.

C) Optional hedge stop-loss

– If hedge_profit ≤ -Max_Hedge_Loss (if this input is > 0), close the hedge as an emergency stop, then reset state.

Cooldown and stability

– The EA must use a minimum time between actions (SecondsBetweenActions) to avoid opening or closing multiple trades too fast during spikes.
– It must handle cases where:
– The user manually closes trades or the hedge.
– The broker rejects an order (log the error and continue gracefully).

Inputs (example list)

– MarginLevel_Trigger (double, e.g. 250.0).
– Neutralise_Margin_Buffer (double, e.g. 260.0 or 0 to disable).
– Include_By_Symbol (string, comma separated).
– Include_By_Magic (string, comma separated).
– Hedge_Sizing_Mode (enum: BY_NET_EXPOSURE or BY_OLDEST_TRADE).
– HedgeFactor (double, e.g. 0.30).
– MaxHedgeLot (double).
– MinHedgeLot (double).
– Hedge_Symbol_Mode (enum: SAME_SYMBOL or MASTER_SYMBOL).
– Master_Hedge_Symbol (string, e.g. XAUUSD).
– SafetyFactor (double, e.g. 0.7).
– Max_Hedge_Loss (double, 0 = disabled).
– SecondsBetweenActions (integer, e.g. 60).
– Recoup_Threshold (double, usually 0.00).
– Neutralise_Threshold (double, usually 0.00).
– Hedge magic number (integer, separate from all grid EAs).
– Enable_Logging (bool).

Requirements for the code

– MQL5, clean and well commented.
– No DLLs.
– Must work in the MT5 Strategy Tester and on live trading.
– Use standard CTrade / trade classes and proper error handling.
– Must correctly support hedging accounts.
– Should be efficient enough to run on every tick with multiple symbols and positions.

Deliverables

– Source code (.mq5) and compiled file (.ex5).
– Brief note explaining how to set:
– Margin trigger
– HedgeFactor
– Symbols list
– Magic numbers
– Optional: basic Strategy Tester file or screenshots to prove the EA compiles and runs.

Please only apply if you have experience:

– Coding portfolio-level EAs that manage multiple symbols and magic numbers.
– Working with margin calculations and hedge logic.
– Working with gold (XAU) and high-volatility instruments is a plus.

–––––––––––––––––––––
SHORT “MUST-HAVE” LIST (OPTIONAL)
–––––––––––––––––––––

You can paste this either at the top or in the “Requirements” field:

– MT5 EA (MQL5), hedging account, no DLLs.
– One EA on one chart, monitoring margin level for whole account.
– Triggers when MarginLevel < 250%.
– Opens one hedge position (partial lot size, based on exposure and free margin).
– Uses hedge profit to close oldest losing trade at break-even (close hedge + that trade together).
– If market reverses and grids recover, closes hedge at break-even (hedge loss offset by grid profit), leaving grid trades open.
– Works across multiple XAU symbols and multiple magic numbers.
– Clean, robust code with comments and error handling.

If you want, I can also help you write a short first message to the devs once you start getting proposals (for example, how to check they actually understand the logic).


ファイル:

応答済み

1
開発者 1
評価
(394)
プロジェクト
555
41%
仲裁
30
57% / 3%
期限切れ
57
10%
仕事中
パブリッシュした人: 11 codes
2
開発者 2
評価
(13)
プロジェクト
20
40%
仲裁
3
0% / 67%
期限切れ
3
15%
3
開発者 3
評価
(16)
プロジェクト
20
15%
仲裁
5
40% / 40%
期限切れ
0
4
開発者 4
評価
(510)
プロジェクト
977
74%
仲裁
27
19% / 67%
期限切れ
100
10%
パブリッシュした人: 1 article, 6 codes
5
開発者 5
評価
(268)
プロジェクト
602
34%
仲裁
65
20% / 57%
期限切れ
147
24%
仕事中
パブリッシュした人: 1 article, 22 codes
6
開発者 6
評価
(22)
プロジェクト
29
3%
仲裁
4
25% / 0%
期限切れ
3
10%
仕事中
7
開発者 7
評価
(3)
プロジェクト
1
100%
仲裁
3
0% / 100%
期限切れ
0
8
開発者 8
評価
(4)
プロジェクト
8
0%
仲裁
3
33% / 67%
期限切れ
4
50%
9
開発者 9
評価
(2)
プロジェクト
3
0%
仲裁
0
期限切れ
0
10
開発者 10
評価
(10)
プロジェクト
15
27%
仲裁
0
期限切れ
3
20%
11
開発者 11
評価
(48)
プロジェクト
58
34%
仲裁
15
27% / 60%
期限切れ
1
2%
仕事中
12
開発者 12
評価
(1)
プロジェクト
3
0%
仲裁
0
期限切れ
0
13
開発者 13
評価
(2)
プロジェクト
1
0%
仲裁
1
0% / 100%
期限切れ
0
14
開発者 14
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
15
開発者 15
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
類似した注文
Online Ordering System para sa Milk Tea Shop* *1. Layunin ng Project* Gumawa ng website at mobile app kung saan makaka-order ang mga customer ng milk tea online. Para hindi na pumila at para mas madali i-track yung mga orders. *2. Mga Kailangan / Features* - *Para sa Customer:* - Mag-register at mag-login gamit ang email at number - Makita ang menu na may picture, presyo, at description - Makapag-customize ng
Hi there developer, I need someone who can create an trading ea that place order in points using an. Vps with an stop loss in 2 point behind the order price automatically it close order in 1 point if the market reverse
I am looking for a highly experienced developer to build a professional, commercial-grade trading indicator for MT4/MT5. I am not looking for a basic indicator or a modified public script. I need a custom solution based on real market logic with high-quality coding standards. Requirements 100% Non-Repainting indicator. Accurate Entry signals. Automatic Stop Loss placement based on real market structure. Automatic
I need a custom MT5 Expert Advisor (MQL5) for XAUUSD. Strategy: 1. Trend Filter (H1) - EMA 20, EMA 50 and EMA 200. - Buy only when EMA20 > EMA50 > EMA200 and price is above EMA200. - Sell only when EMA20 < EMA50 < EMA200 and price is below EMA200. 2. Confirmation (M15) - M15 trend must confirm the H1 trend before taking any trade. 3. Entry (M5) - Wait for price to pull back to EMA20 only. - After touching EMA20, wait
Mac200 50+ USD
I need a Trend following Bot. Here we took entries by looking at two indicator which are 200 period ema and 12 26 9 MacD. Rules for entry exit are: Buy trade: When market is above 200 ema and MacD Line cross over the signal line and this cross over happened below the zero line of MacD indicator. We simply put Buy trade. Sell trade: When market is below 200 ema and MacD line crosses below the signal line and this
I I would like to create a trading robot based on 2 ema crossing. The robot is pretty simple, it should open buy position when fast ema cross slow ema and vise versa. Also it should use martingale after the loss position. It should has expiration period inside the code and alerts l
Iconic Boy 300 - 400 USD
Am looking for a bot to trade .so that I can be able to trade and become very successful and make some profit so that I cannot sleep on a empty stomach
MT5 Global Stop Loss & Take Profit Manager for Manual Trades I need an Expert Advisor (EA) for MetaTrader 5 that manages ONLY existing manual trades. GENERAL REQUIREMENTS - Works only on the current chart symbol (example: XAUUSD). - Supports Hedging accounts. - Detects all manually opened market positions. - Never opens trades automatically. - Never closes trades automatically. - Never places pending orders. - Never
Supply and Demand EA 50 - 250 USD
I need a SnD EA. Prefer coder who has previous experience coding SnD EA. PO are based on (CHoCH or BoS) and 3EMA, order block (from my TradingView indicator), area based on Fibonacci. SL options are based on fix pips or zone size; CL is based on candle closing. TP1 and TP2 options are based on fix pips or fix ratio. Canceling PO is based on market structure or Fibonacci. Money management are based on fix volume or
Hi MQL5 Community, With over 10 years of live market experience as a Quantitative & Trading System Developer, I specialize in building robust, highly scalable Expert Advisors (EAs), custom indicators, and automated architectures. I’ve recently put together a comprehensive showcase demonstrating my flagship Modular Multi-Engine Architecture , designed to bring institutional-grade logic and real-time telemetry into

プロジェクト情報

予算
250 - 350 USD
締め切り
最低 1 最高 5 日