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
評価
(395)
プロジェクト
556
41%
仲裁
30
57% / 3%
期限切れ
57
10%
暇
パブリッシュした人: 11 codes
2
開発者 2
評価
(13)
プロジェクト
20
40%
仲裁
3
0% / 67%
期限切れ
3
15%
暇
3
開発者 3
評価
(17)
プロジェクト
21
19%
仲裁
5
40% / 40%
期限切れ
0
暇
4
開発者 4
評価
(510)
プロジェクト
978
74%
仲裁
27
19% / 67%
期限切れ
101
10%
暇
パブリッシュした人: 1 article, 6 codes
5
開発者 5
評価
(268)
プロジェクト
603
34%
仲裁
65
22% / 57%
期限切れ
146
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
評価
(54)
プロジェクト
67
42%
仲裁
15
27% / 60%
期限切れ
1
1%
仕事中
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
暇
類似した注文
Bonjour ! Je vous ai contacté pour le développement de mon EA sur MetaTrader. Je souhaite intégrer une stratégie précise avec une gestion stricte des règles du courtier Exness. J'ai déjà préparé le cahier des charges complet sous format PDF avec toutes les spécifications techniques
SKBOT 35+ USD
want an MQL5 Expert Advisor (EA) for MetaTrader 5, mainly for XAUUSD (Gold). Strategy: The EA should trade based on market structure, Break of Structure (BOS), Fair Value Gaps (FVG), Order Blocks (OB), and Fibonacci retracement levels. BUY setup: Detect bullish market structure. Detect a bullish Break of Structure (BOS). Identify the relevant bullish FVG and/or Order Block created around the structure move. Use
Light 🕯️ 50+ USD
To apply, you must already have your EA running on an active MT5 trading account connected to the market. The account must have genuine trading history that can be independently reviewed and verified. EA Requirements 1. Prop-Firm Compatible Risk Management - The EA must include daily and overall drawdown protection. - Required inputs: "MaxDailyLoss = 5%" "MaxTotalDrawdown = 10%" - Once either limit is
Hello, I'm looking for developer or coder to create a custom expert advisor (EA) on mql4 according to my strategy. The developer should be able deliver both indicator and source code for the job. Thanks
​ Indicators: Fast MA (Period 10, Exponential) and Slow MA (Period 50, Exponential). ​ Buy Signal: When Fast MA crosses above Slow MA. ​ Sell Signal: When Fast MA crosses below Slow MA. ​ Risk Management & Parameters: ​Customizable Lot Size (Default: 0.01). ​Stop Loss (SL) and Take Profit (TP) in pips. ​Trailing Stop options. ​Max Spread filter. ​ Platform: MetaTrader 5 (MQL5)
​ Indicators: Fast MA (Period 10, Exponential) and Slow MA (Period 50, Exponential). ​ Buy Signal: When Fast MA crosses above Slow MA. ​ Sell Signal: When Fast MA crosses below Slow MA. ​ Risk Management & Parameters: ​Customizable Lot Size (Default: 0.01). ​Stop Loss (SL) and Take Profit (TP) in pips. ​Trailing Stop options. ​Max Spread filter. ​ Platform: MetaTrader 5 (MQL5)
A robot 30+ USD
Je souhaite trouver un développeur pour réaliser ce travail et effectuer les paiements via cette application. Je m'engage à ne communiquer avec les candidats que par cette application, y compris par messageries tierces, correspondance personnelle ou courriel. Je comprends que toute personne ne respectant pas ces conditions sera interdite de publier des commandes sur la plateforme Freelance
I am looking for an experienced MQL5/MT5 developer to develop a custom Expert Advisor based on a complete technical architecture already prepared by the client. This is not a request to design a trading strategy from scratch . The strategy architecture, entry/exit concepts, filters, risk-management requirements and testing requirements are already documented. The main responsibility will be MQL5 development
EAs 100+ USD
To apply, you must already have your EA running on an active MT5 trading account connected to the market. The account must have genuine trading history that can be independently reviewed and verified. EA Requirements 1. Prop-Firm Compatible Risk Management - The EA must include daily and overall drawdown protection. - Required inputs: "MaxDailyLoss = 5%" "MaxTotalDrawdown = 10%" - Once either limit is
Strategy 40 - 60 USD
yo i have a strategy i would really like to turn into a signal bot basically please this is very technical and serious to me the strategy needs more time 1 time frame and the bot most be 100% accurate

プロジェクト情報

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