MT5 Safety EA: Close Oldest Losing Trade On Low Margin Level (Pepperstone, 30:1, Fixed Grid)

MQL5 エキスパート

仕事が完了した

実行時間4 時間
開発者からのフィードバック
Thanks for the project. Looking forward to the next one!
依頼者からのフィードバック
Superb service. Andrey delivered a flawless system in half a day — no revisions needed. Fast, professional, and highly skilled. He’s now my go-to MQL5 developer. Strongly recommended.

指定

I need a simple but reliable safety EA for MetaTrader 5 (MQL5) to protect my account from margin calls while running multiple Dark Gold EAs on Pepperstone UK.

My setup

– Broker: Pepperstone UK
– Platform: MT5
– Stop-out: 50%
– Leverage: 30:1
– Strategy: Several Dark Gold EAs (around 6 charts). Each uses a fixed grid with no martingale, for example: 0.01, 0.01, 0.01 … up to about 15 positions. All grid positions are equal lot size.

Goal of the EA

I want a separate safety EA that I attach to ONE chart only. It does not open trades. It only:

– Monitors account margin level
– When margin level gets too low (for example 80%), it closes exactly ONE trade: the oldest losing trade
– Waits a configurable cooldown time
– Repeats if needed, until margin improves or there are no more trades

Reasoning

Because I use a fixed grid with equal lot size, the oldest trades are usually the ones furthest away from the current price and doing the most damage to the basket’s average entry and take profit. Closing the oldest losing trade removes the “tail” of the grid and pulls the basket TP closer to current price, so a smaller retrace can clean up the rest.

Functional requirements

  1. Attachment and scope
    – EA runs on exactly one chart (any symbol).
    – It monitors all open positions on the whole account, not just the chart symbol.
    – It must be compatible with running multiple Dark Gold EAs in parallel.

  2. Margin level trigger
    – On every tick, the EA reads ACCOUNT_MARGIN_LEVEL (percentage).
    – Input: MarginLevelThreshold (double, default 80.0).
    – If margin level > threshold: do nothing.
    – If margin level <= threshold: trigger the close logic.

  3. Trade selection logic
    – EA scans all open positions.
    – Optional filter by Magic Number:
    – Input: MagicFilter (long, default -1).
    – If MagicFilter = -1: manage all trades.
    – If MagicFilter = some value: manage only trades with that magic.
    – Optional filter “only losing trades”:
    – Input: OnlyCloseLosing (bool, default true).
    – If true: only trades with POSITION_PROFIT < 0 are considered.
    – From the remaining eligible trades, select the oldest by POSITION_TIME.
    – Close exactly that one position.

  4. Closing and cooldown
    – After closing one position successfully, the EA must wait a minimum cooldown time before closing another, even if margin is still low.
    – Input: CooldownSeconds (int, default 5).
    – The idea is a “slow bleed” of risk, not an instant flush of the whole account.

  5. Notifications
    – Input: SendPushNotifications (bool, default true).
    – If enabled, when the EA closes a position it should send SendNotification() with: ticket, symbol, volume, and margin level at the moment of closing.
    – Also log this clearly in the Experts tab.

  6. Safety conditions
    – The EA must not open trades.
    – It must not modify SL/TP of existing trades.
    – It must only close trades as per the margin logic above.
    – It must not freeze or block the terminal (no heavy loops).

Inputs (must be configurable in EA parameters)

– MarginLevelThreshold (double, default 80.0)
– OnlyCloseLosing (bool, default true)
– CooldownSeconds (int, default 5)
– MagicFilter (long, default -1)
– SendPushNotifications (bool, default true)
– Optional: BrokerStopOutLevel (double, default 50.0) just for logging / information

Example behaviour

– Margin level at 300%: EA does nothing.
– Margin level falls to 82%: still above 80%, EA does nothing.
– Margin level drops to 80% or below:
– EA scans eligible trades (respecting MagicFilter and OnlyCloseLosing).
– Picks the oldest losing trade by POSITION_TIME.
– Closes this single trade.
– Logs it and optionally sends a push notification.
– Starts a cooldown (for example 5 seconds).
– After the cooldown, if margin is still <= threshold, it repeats and closes the next oldest losing trade.
– This continues until margin recovers above threshold or there are no more eligible positions.

Deliverables

– MQL5 source code (.mq5) with clear comments.
– Compiles and runs cleanly on latest MT5 build.
– Brief explanation in comments or text where:
– Margin level is checked
– Oldest losing trade is selected
– Cooldown is managed
– MagicFilter is applied


応答済み

1
開発者 1
評価
(22)
プロジェクト
28
7%
仲裁
9
33% / 33%
期限切れ
1
4%
仕事中
2
開発者 2
評価
(111)
プロジェクト
184
25%
仲裁
25
16% / 76%
期限切れ
16
9%
暇
3
開発者 3
評価
(329)
プロジェクト
515
19%
仲裁
35
46% / 31%
期限切れ
34
7%
仕事中
4
開発者 4
評価
(62)
プロジェクト
90
29%
仲裁
24
13% / 58%
期限切れ
7
8%
仕事中
5
開発者 5
評価
(16)
プロジェクト
35
23%
仲裁
4
0% / 50%
期限切れ
2
6%
仕事中
6
開発者 6
評価
(2)
プロジェクト
3
0%
仲裁
0
期限切れ
0
暇
7
開発者 7
評価
(1)
プロジェクト
2
0%
仲裁
1
0% / 100%
期限切れ
1
50%
暇
パブリッシュした人: 4 codes
8
開発者 8
評価
(144)
プロジェクト
186
41%
仲裁
24
58% / 21%
期限切れ
13
7%
暇
9
開発者 9
評価
(511)
プロジェクト
978
74%
仲裁
27
19% / 67%
期限切れ
100
10%
暇
パブリッシュした人: 1 article, 6 codes
10
開発者 10
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
暇
11
開発者 11
評価
(4)
プロジェクト
6
17%
仲裁
2
0% / 100%
期限切れ
3
50%
暇
12
開発者 12
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
暇
13
開発者 13
評価
(271)
プロジェクト
553
50%
仲裁
57
40% / 37%
期限切れ
227
41%
仕事中
14
開発者 14
評価
(319)
プロジェクト
574
35%
仲裁
83
31% / 45%
期限切れ
207
36%
暇
15
開発者 15
評価
(10)
プロジェクト
15
27%
仲裁
0
期限切れ
3
20%
暇
16
開発者 16
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
暇
17
開発者 17
評価
(13)
プロジェクト
23
39%
仲裁
8
0% / 50%
期限切れ
4
17%
暇
18
開発者 18
評価
(16)
プロジェクト
20
0%
仲裁
10
0% / 80%
期限切れ
6
30%
暇
19
開発者 19
評価
(25)
プロジェクト
31
13%
仲裁
14
0% / 79%
期限切れ
9
29%
暇
20
開発者 20
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
暇
21
開発者 21
評価
プロジェクト
2
0%
仲裁
4
25% / 50%
期限切れ
1
50%
暇
22
開発者 22
評価
(637)
プロジェクト
1009
47%
仲裁
33
36% / 36%
期限切れ
99
10%
暇
パブリッシュした人: 6 codes
23
開発者 23
評価
(268)
プロジェクト
603
34%
仲裁
65
22% / 57%
期限切れ
146
24%
仕事中
パブリッシュした人: 1 article, 22 codes
24
開発者 24
評価
(162)
プロジェクト
289
35%
仲裁
18
22% / 61%
期限切れ
43
15%
暇
25
開発者 25
評価
(3)
プロジェクト
1
100%
仲裁
3
0% / 100%
期限切れ
0
暇
26
開発者 26
評価
(55)
プロジェクト
68
43%
仲裁
15
27% / 60%
期限切れ
1
1%
仕事中
27
開発者 27
評価
(258)
プロジェクト
269
29%
仲裁
2
50% / 0%
期限切れ
3
1%
仕事中
パブリッシュした人: 2 codes
28
開発者 28
評価
(7)
プロジェクト
6
0%
仲裁
4
25% / 75%
期限切れ
2
33%
暇
29
開発者 29
評価
(24)
プロジェクト
32
38%
仲裁
4
50% / 25%
期限切れ
5
16%
仕事中
30
開発者 30
評価
プロジェクト
0
0%
仲裁
0
期限切れ
0
暇
類似した注文
Hi I'm looking for this EA or Similar EA with optimizated set file. This bot is an automated trading robot, operating 24/7, and capable of trading all currency pairs. Compatible with all brokers. Features: Analysis of price action charts, trends, and support and resistance levels on any timeframe. The bot integrates stop-loss (SL), stop-loss (TP), and trailing stop-loss (SL) orders. Works on MT5 getshared . c o m
I wish to create 2 different Tradingview strategies to MT5 ea-s! Anyone? One is based on Heiken Ashi...the other based on different combination of my strategy. It is for 1 minute charts
نازدك 30+ USD
Specify your Requirements Specification here point by point. Try to describe your requirements briefly and clearly, so that your potential developer is able to correctly assess its complexity and cost, as well as the required execution time. A bad or too generic description will result in your order being ignored, or you will spend a lot of time negotiating the details with each applicant. Remember: It is better to
**IMPORTANT: PLEASE DISREGARD THE PREVIOUS SPECIFICATION TITLED "FULL TRADING PLATFORM – APPLICATION FLOW REQUIREMENTS."** I no longer need the complete trading platform outlined in my previous **"FULL TRADING PLATFORM – APPLICATION FLOW REQUIREMENTS"** specification. Originally, I considered building a complete trading platform with educational materials, training systems, user accounts, subscription features
I have indicators on my Trading view which will create zones automatically on H4 Candle confirmation. I am getting an alert also that specific zone is created. I want them to shift in automated trading like once zone is created, limits should be place automatically on basis of that zone with given lot size, number of layers and with TP and SL. I have checked on AI to convert this in auto but they need zone in numbers
I am looking for an experienced MQL5 developer to recreate my existing MT5 Expert Advisor (DSTR Novaa). I have the original compiled EX5 file, Vantage MT5 live trading history and original Strategy Tester report. Required Trading Logic: EMA Period: 3. BUY when price crosses below EMA 3. SELL when price crosses above EMA 3. Starting Lot: 0.01 (configurable). Martingale Multiplier: 2.0. Maximum Martingale Cycle: 9
Aviation 30+ USD
I wish to say I wanna go rich and clever in everything I do and trusting the Lord and working hard will boost me up and making me the best person
I need an ready-made MT5 profitable EA for Gold. 5/7% daily I need. Before applying please make sure you have one with proven ROI, Drawdown and Live performace result. I will Pay $500 for it but I need as I want. Must needs to supply Source code if I like it. Before I purchase I will test 7 days on my live account. If It's okay then apply othersie please pass this project. Hope you will respect the time for both of
I need a EA to test many EAS all in one to see the results For back testing I've got the EA I want to see the combined EAS what is the results
Hello, I need a high-quality, reliable, and well-coded Expert Advisor (EA) for MetaTrader 5. The code must be clean, without errors, and optimized for safe trading. The robot needs to trade based on basic technical indicators. Every trade must have a strict Stop Loss and Take Profit for risk management. Please apply only if you are an experienced MT5 developer with a high rating and clean coding history. Best

プロジェクト情報

予算
50 - 120 USD