MT5 Grid EA with Auto Re-Anchor, Anti-Failure Logic, and Global Take Profit System

Tâche terminée

Temps d'exécution 12 jours
Commentaires du client
approved! thank you Rodrigue
Commentaires de l'employé
Happy to work with you

Spécifications

💼 Job Description (full text for MQL5 Jobs)

Project Overview

I need a MetaTrader 5 Expert Advisor (MQL5, Hedge account) that executes a grid-based anti-failure strategy.
The EA should anchor at the latest top (highest high), place BUY LIMIT orders at predefined retracement levels, and close all positions simultaneously when the average price reaches a global Take Profit target (in %).

After the global closure (TP, SL, or manual), the EA must cancel all remaining pending orders, re-anchor automatically to the latest high, and rebuild the entire grid.

⚠️ I already have a partial version of this system.
The main issue to fix is: when one trade closes at TP, other pending orders remain stuck on the chart.
I need it to close everything, reset, and start over cleanly after each cycle.


Strategy Logic

1. Anchor Logic (Top Reference)

  • Anchor at the highest high of a user-defined timeframe (e.g. D1) within a defined lookback period (e.g. 10,000 bars).

  • Re-anchor only if:

    1. There are no open BUY positions, and

    2. A new high ≥ (previous_anchor * (1 + ReanchorThrPct / 100)) occurs.

  • While any BUY position remains open, the anchor must not change.

  • After all positions close, the EA checks for a new high and rebuilds the grid.


2. Grid Placement (BUY LIMIT Orders)

  • Up to 10 levels, each with:

    • LevelPctN → retracement % from anchor top

    • LotN → fixed lot size for that level

  • BUY LIMIT price = AnchorHigh * (1 - LevelPctN/100)

  • Prevent duplicates:
    If a pending order already exists within PriceTolPts (price tolerance in points), do not resend it.

  • Orders use DeviationPts (slippage/deviation setting).


3. Global Take Profit by Average Price

  • When one or more BUY positions are open (same Magic Number), calculate volume-weighted average entry price.

  • Set global Take Profit = AvgPrice * (1 + TP_Percent / 100)

  • All open BUY trades must share this same TP.

  • If the difference between current TP and target TP > ModifyTolPts , the EA updates all positions’ TP accordingly.


4. Reset & Re-Arm Sequence
After all BUY positions are closed:

  1. Cancel all pending BUY LIMITs for that Magic Number.

  2. Recalculate AnchorHigh (check for new top using the rules above).

  3. Rebuild the grid with the same parameters from the new anchor.

This reset must also trigger if trades close via TP, SL, or manual closure.
Use OnTradeTransaction with DEAL_ENTRY_OUT to detect when all positions are closed.


Magic (ulong)
AnchorTF (ENUM_TIMEFRAMES)
BarsLookback (int)
ReanchorThrPct (double)
LevelsCount (int)
LevelPct1..10 (double)
Lot1..10 (double)
TP_Percent (double)
PriceTolPts (int)
ModifyTolPts (int)
DeviationPts (int)

Technical Requirements

  • Must be coded in pure MQL5 (no MT4 or conversion).

  • Must use CTrade (Trade/Trade.mqh) and OnTradeTransaction.

  • Fully compatible with Hedge accounts.

  • Must compile with 0 errors and 0 warnings on the latest MT5 build.

  • Handle different symbol digits/points (e.g., XAUUSD, BTCUSD).

  • Must run and optimize properly in "Every tick based on real ticks" mode.

  • Include clear internal logs for:

    • Anchor/re-anchor detection

    • Grid creation/deletion

    • TP updates

    • Reset/Re-arm events


Acceptance Criteria

  1. Compiles cleanly (0 errors/warnings) on MetaEditor 5.

  2. In a visual backtest, the EA must:

    • Place BUY LIMIT grid at the anchor top.

    • When one or more trades hit TP → close all open positions + cancel all pending orders.

    • Re-anchor to the next valid top and rebuild the grid automatically.

    • Not re-anchor while trades are still open.

    • Avoid duplicate pending orders within PriceTolPts .

    • Update global TP properly when average entry changes.

  3. Works consistently on XAUUSD, BTCUSD, and other CFD pairs.


Deliverables

  • One .mq5 file (full source code, well-commented).

  • Short “readme” with:

    • How to attach EA to chart

    • Recommended test settings

    • Suggested parameters for XAUUSD and BTCUSD (H1, 10/20/30/40/55 retracements, lots 0.01–0.03, TP=12%).

  • 30-day bug fix period after delivery (minor corrections included).


Optional (Nice to Have)

  • Option for partial close (close X% of positions at an intermediate TP).

  • CSV export of anchor, TP, and deal data.

  • Backtest cost simulation (spread/commission/slippage).


What to Include in Proposal

  • Links or screenshots of previous MT5 EAs using OnTradeTransaction .

  • Confirmation that all acceptance criteria will be met.

  • Delivery time and final price.


🟢 Notes from client (Wily Machado):
I already have partial working logic, but compilation and event handling keep failing.
The goal is a stable, clean, and testable EA that can run long-term safely with low drawdown and consistent profits.
If you deliver that, I’ll likely hire you again for optimization and advanced modules (partial exits, trailing TP, etc.). 



Répondu

1
Développeur 1
Évaluation
(18)
Projets
22
9%
Arbitrage
6
33% / 50%
En retard
1
5%
Travail
2
Développeur 2
Évaluation
(4)
Projets
5
20%
Arbitrage
1
100% / 0%
En retard
0
Gratuit
3
Développeur 3
Évaluation
(160)
Projets
285
35%
Arbitrage
18
22% / 61%
En retard
42
15%
Chargé
4
Développeur 4
Évaluation
(14)
Projets
19
11%
Arbitrage
1
0% / 100%
En retard
5
26%
Gratuit
5
Développeur 5
Évaluation
(1)
Projets
3
0%
Arbitrage
0
En retard
0
Gratuit
6
Développeur 6
Évaluation
(308)
Projets
553
35%
Arbitrage
80
31% / 41%
En retard
200
36%
Chargé
7
Développeur 7
Évaluation
Projets
0
0%
Arbitrage
1
0% / 100%
En retard
0
Gratuit
8
Développeur 8
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
9
Développeur 9
Évaluation
(1)
Projets
2
0%
Arbitrage
1
0% / 100%
En retard
0
Gratuit
Publié : 2 codes
10
Développeur 10
Évaluation
(350)
Projets
421
54%
Arbitrage
20
55% / 15%
En retard
29
7%
Travail
11
Développeur 11
Évaluation
(16)
Projets
20
0%
Arbitrage
10
0% / 80%
En retard
6
30%
Gratuit
12
Développeur 12
Évaluation
(253)
Projets
259
30%
Arbitrage
0
En retard
3
1%
Gratuit
Publié : 2 codes
13
Développeur 13
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
Commandes similaires
Hello, I'm looking to find out the cost of creating a mobile trading robot. I've tried to describe it as thoroughly as possible in the following document. I look forward to your response. I'd like to know the costs, delivery time, and how you plan to implement it before making a decision
I am offering a ready-to-use trading system that connects MetaTrader 4 signals with automated trading on Polymarket. The system is already fully developed and working. What the system does: The bot copies signals from a custom MT4 indicator and executes trades automatically on Polymarket prediction markets. How it works: A custom MT4 indicator generates BUY or SELL signals using buffers. When a signal appears, it is
DO NOT RESPOND TO WORK WITH ANY AI. ( I CAN ALSO DO THAT ) NEED REAL DEVELOPING SKILL Hedge Add-On Rules for Existing EA Core Idea SL becomes hypothetical (virtual) for the initial basket and for the hedge basket . When price hits the virtual SL level , EA does not close the losing trades. Instead, EA opens one hedge basket in the opposite direction. Original basket direction Hedge basket direction (opposite) Inputs
Billionflow 30 - 100 USD
Trading specifications: Indicators: Bollinger band ( Period 40, Deviation 1 apply to close) Moving Average (Exponential ) Period 17 applied to high Moving Average ( Exponential ) Period 17 applied to low But Signal enter a buy trade when prices crosses the lower band of the bollinger band up and also crosses the moving average channel of high and low the reverse is true for sell signal
Hello, I am a user of the "BUY STOP SELL STOP V6" trading bot, which is an advanced Grid System bot. The bot is primarily designed for Gold (XAUUSD), but I want it to work on all currency pairs. "The bot contains a privacy/protection code that prevents it from running on other accounts or being modified on any platform, as it has a client account number lock mechanism" --- Bot Description & Current Settings Bot Type
I need Ea that executes trade based on trading view indicator called Market Structure CHoCH/BOS (Fractal) [LuxAlgo] I need developer to recreate the indicator as an Ea in MQL5 The core of the system will be a structured Market Structure engine that detects CHOCH (Change of Character) and BOS (Break of Structure) Signals will be confirmed once the indicator gave ( the bos/choch) no need to wait candle close
Looking to purchase a Good forex or gold/ BTC trading EA and it's source code. Must be compatible with low budget like less than $500 accounts, Must need no manual intervention and run fully automated. If you are interested in selling me the source code, please share the Read only account access where the EA has already been running on, so i can check past performance and get an idea on how it works or runs. Dont
Hello, I’m looking for an experienced MQL4/MQL5 developer to work with me on an ongoing basis. My clients request services such as: Converting TradingView Pine Script indicators/strategies into MT4 or MT5 Expert Advisors Converting MT4 EAs to MT5 (and MT5 to MT4) Compiling and fixing existing MQL4 / MQL5 EA code Adding simple features like alerts, SL/TP, lot size, and basic money management This job is for
I am looking someone to create an EA based on my MACD Histo indicator / strategy from Pinescript. I will send it to you for you to replicate. The EA shall have: - Divergence length in bars, min and max values. - Pivot Logic - Entry on close of divergence confirmation bar. - Dynamic lot size dependent on SL/TP, in monetary value. - SL / TP in percent away from entry, separate values for long and short. - Time, day and
Hello, I have a breakout EA with reversal logic. I own the full source code for both MT4 and MT5 versions. I need the modifications implemented for both MT4 and MT5 versions. I need several modifications: – Multiple reversals with configurable parameters – Breakeven functionality – Entry only after candle close beyond range + offset – Time-based activation – Alternative offset calculation logic – Automatic close at

Informations sur le projet

Budget
50+ USD