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

MQL5 Esperti

Lavoro terminato

Tempo di esecuzione 4 ore
Feedback del cliente
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.
Feedback del dipendente
Thanks for the project. Looking forward to the next one!

Specifiche

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


Con risposta

1
Sviluppatore 1
Valutazioni
(21)
Progetti
27
7%
Arbitraggio
9
33% / 33%
In ritardo
1
4%
In elaborazione
2
Sviluppatore 2
Valutazioni
(108)
Progetti
179
25%
Arbitraggio
24
17% / 75%
In ritardo
16
9%
Gratuito
3
Sviluppatore 3
Valutazioni
(328)
Progetti
514
19%
Arbitraggio
35
46% / 31%
In ritardo
34
7%
In elaborazione
4
Sviluppatore 4
Valutazioni
(62)
Progetti
90
29%
Arbitraggio
24
13% / 58%
In ritardo
7
8%
In elaborazione
5
Sviluppatore 5
Valutazioni
(16)
Progetti
35
23%
Arbitraggio
4
0% / 50%
In ritardo
2
6%
In elaborazione
6
Sviluppatore 6
Valutazioni
(2)
Progetti
3
0%
Arbitraggio
0
In ritardo
0
Gratuito
7
Sviluppatore 7
Valutazioni
(1)
Progetti
2
0%
Arbitraggio
1
0% / 100%
In ritardo
1
50%
Gratuito
Pubblicati: 4 codici
8
Sviluppatore 8
Valutazioni
(144)
Progetti
186
41%
Arbitraggio
24
58% / 21%
In ritardo
13
7%
Gratuito
9
Sviluppatore 9
Valutazioni
(510)
Progetti
977
74%
Arbitraggio
27
19% / 67%
In ritardo
100
10%
Gratuito
Pubblicati: 1 articolo, 6 codici
10
Sviluppatore 10
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
11
Sviluppatore 11
Valutazioni
(4)
Progetti
6
17%
Arbitraggio
2
0% / 100%
In ritardo
3
50%
Gratuito
12
Sviluppatore 12
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
13
Sviluppatore 13
Valutazioni
(271)
Progetti
553
50%
Arbitraggio
57
40% / 37%
In ritardo
227
41%
In elaborazione
14
Sviluppatore 14
Valutazioni
(318)
Progetti
565
35%
Arbitraggio
81
31% / 44%
In ritardo
204
36%
Gratuito
15
Sviluppatore 15
Valutazioni
(10)
Progetti
15
27%
Arbitraggio
0
In ritardo
3
20%
Gratuito
16
Sviluppatore 16
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
17
Sviluppatore 17
Valutazioni
(13)
Progetti
22
41%
Arbitraggio
8
0% / 50%
In ritardo
3
14%
Gratuito
18
Sviluppatore 18
Valutazioni
(16)
Progetti
20
0%
Arbitraggio
10
0% / 80%
In ritardo
6
30%
Gratuito
19
Sviluppatore 19
Valutazioni
(25)
Progetti
31
13%
Arbitraggio
13
0% / 77%
In ritardo
9
29%
Gratuito
20
Sviluppatore 20
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
21
Sviluppatore 21
Valutazioni
Progetti
2
0%
Arbitraggio
4
25% / 50%
In ritardo
1
50%
Gratuito
22
Sviluppatore 22
Valutazioni
(635)
Progetti
1005
47%
Arbitraggio
33
36% / 36%
In ritardo
99
10%
In elaborazione
Pubblicati: 6 codici
23
Sviluppatore 23
Valutazioni
(268)
Progetti
602
34%
Arbitraggio
65
20% / 57%
In ritardo
147
24%
In elaborazione
Pubblicati: 1 articolo, 22 codici
24
Sviluppatore 24
Valutazioni
(162)
Progetti
289
35%
Arbitraggio
18
22% / 61%
In ritardo
43
15%
Gratuito
25
Sviluppatore 25
Valutazioni
(3)
Progetti
1
100%
Arbitraggio
3
0% / 100%
In ritardo
0
Gratuito
26
Sviluppatore 26
Valutazioni
(48)
Progetti
58
34%
Arbitraggio
15
27% / 60%
In ritardo
1
2%
In elaborazione
27
Sviluppatore 27
Valutazioni
(258)
Progetti
267
30%
Arbitraggio
0
In ritardo
3
1%
In elaborazione
Pubblicati: 2 codici
28
Sviluppatore 28
Valutazioni
(7)
Progetti
6
0%
Arbitraggio
4
25% / 75%
In ritardo
2
33%
Gratuito
29
Sviluppatore 29
Valutazioni
(22)
Progetti
29
34%
Arbitraggio
4
50% / 25%
In ritardo
5
17%
In elaborazione
30
Sviluppatore 30
Valutazioni
Progetti
0
0%
Arbitraggio
0
In ritardo
0
Gratuito
Ordini simili
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

Informazioni sul progetto

Budget
50 - 120 USD