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

MQL5 Эксперты

Работа завершена

Время выполнения 4 часа
Отзыв от заказчика
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.
Отзыв от исполнителя
Thanks for the project. Looking forward to the next one!

Техническое задание

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
Оценка
(18)
Проекты
22
9%
Арбитраж
6
33% / 50%
Просрочено
1
5%
Загружен
2
Разработчик 2
Оценка
(104)
Проекты
168
24%
Арбитраж
23
9% / 78%
Просрочено
16
10%
Работает
3
Разработчик 3
Оценка
(328)
Проекты
510
19%
Арбитраж
33
45% / 30%
Просрочено
34
7%
Загружен
4
Разработчик 4
Оценка
(60)
Проекты
87
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%
Свободен
8
Разработчик 8
Оценка
(144)
Проекты
186
41%
Арбитраж
24
58% / 21%
Просрочено
13
7%
Свободен
9
Разработчик 9
Оценка
(509)
Проекты
977
74%
Арбитраж
27
19% / 67%
Просрочено
101
10%
Свободен
Опубликовал: 1 статью, 6 примеров
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
Оценка
(311)
Проекты
557
35%
Арбитраж
79
32% / 43%
Просрочено
202
36%
Работает
15
Разработчик 15
Оценка
(10)
Проекты
15
27%
Арбитраж
0
Просрочено
3
20%
Свободен
16
Разработчик 16
Оценка
Проекты
0
0%
Арбитраж
0
Просрочено
0
Свободен
17
Разработчик 17
Оценка
(10)
Проекты
19
42%
Арбитраж
6
0% / 50%
Просрочено
3
16%
Работает
18
Разработчик 18
Оценка
(16)
Проекты
20
0%
Арбитраж
10
0% / 80%
Просрочено
6
30%
Свободен
19
Разработчик 19
Оценка
(24)
Проекты
30
13%
Арбитраж
12
0% / 75%
Просрочено
8
27%
Свободен
20
Разработчик 20
Оценка
Проекты
0
0%
Арбитраж
0
Просрочено
0
Свободен
21
Разработчик 21
Оценка
Проекты
2
0%
Арбитраж
4
25% / 50%
Просрочено
1
50%
Свободен
22
Разработчик 22
Оценка
(627)
Проекты
989
47%
Арбитраж
33
36% / 36%
Просрочено
98
10%
Работает
Опубликовал: 6 примеров
23
Разработчик 23
Оценка
(266)
Проекты
598
35%
Арбитраж
64
20% / 58%
Просрочено
147
25%
Свободен
Опубликовал: 1 статью, 22 примера
24
Разработчик 24
Оценка
(162)
Проекты
287
34%
Арбитраж
18
22% / 61%
Просрочено
42
15%
Работает
25
Разработчик 25
Оценка
(3)
Проекты
1
100%
Арбитраж
3
0% / 100%
Просрочено
0
Свободен
26
Разработчик 26
Оценка
(40)
Проекты
47
28%
Арбитраж
14
21% / 64%
Просрочено
1
2%
Занят
27
Разработчик 27
Оценка
(255)
Проекты
262
30%
Арбитраж
0
Просрочено
3
1%
Свободен
Опубликовал: 2 примера
28
Разработчик 28
Оценка
(6)
Проекты
5
0%
Арбитраж
2
50% / 50%
Просрочено
2
40%
Свободен
29
Разработчик 29
Оценка
(12)
Проекты
16
13%
Арбитраж
4
50% / 25%
Просрочено
4
25%
Загружен
30
Разработчик 30
Оценка
Проекты
0
0%
Арбитраж
0
Просрочено
0
Свободен
Похожие заказы
Hi, I’m looking for a top-tier, profit-optimized EA that has the potential to scale trading returns significantly. My goal is to maximize growth over time. Can you help develop a bespoke EA that could potentially scale to high six or seven figures
This is yakubu Jnr trading bots I create the trading robots to help my self and others traders to be successful please you can join my live trading bots or subscribe to my trading robots
Nyasco 90+ USD
Fast trading bot for starters less losses which leads to bigger profits made for thousands of people making billions of dollars .be the best trader for your self all the way
Nyasco 30+ USD
Faster robot with less losses which can be used for a long term earning money every day creating a bot for more than thousands of people to earn billions of money
Max amount grid 30+ USD
max amount grid step for magic number do keep deleting .only when it is in negative floating .but when it is profit allow to go over the max and replays to grid step
Apply with a screen of your work . Symbol Specific Logic . Live Chart Optimization Check the Core logic . [back tests as well] Change points to pips . Create buffer for the zone
I will pay 3000+ USD (negotiable) for an EA for existing MT5 that generates a minimum of 15-20% or higher a month consistently (provide source code after final deal) Looking for a highly profitable EA Please send demo version directly subject (Buying profitable EA Budget up to $ 3000 USD), past results and optimal settings so I can test, if it performs in a strategy tester i will also need option to forward test it
EA fx 30+ USD
Hello, I need an already developed EA similar to the one trading XAUUSD, with consistent entries and good risk management. Before we proceed, I would like to verify its performance. Please provide a live or demo account login along with the investor (read-only) password so I can monitor the trading results. I am looking for stable performance, controlled drawdown, and consistent profit on gold (XAUUSD). Once I
The strategy records the highest and lowest prices within a specified duration (default 15 minutes) after the New York market opens, forming the opening range. Post-Formation Breakout: When the price breaks above or below the opening range after its formation, it may indicate the direction of the day’s price movement. Trend Confirmation: The strategy uses two EMAs (default 20-period and 50-period) as trend filters to

Информация о проекте

Бюджет
50 - 120 USD