Update recovery logic EA

MQL5 Indicateurs Experts

Tâche terminée

Temps d'exécution 11 jours
Commentaires du client
Mahdi is an excellent developer! Already working with him in some improvement points and will work together in the next projects. 5* +++
Commentaires de l'employé
MMIMMI,One of the best clients I've worked with. Very understanding, cooperative, and fair.Recommended A++

Spécifications

Hi Developers!


Looking for an experienced dev ( 50 jobs + on the platform ) to make an update on the recovery logic I currently have.


The logic as per now is not a classic recovery martingale, is computing the loss diving by 2 and computing automatically the lots needs to do it in order to make the recovery. ( You can have a look at in the attachments )

Now the logic is done at a daily level ( in case is touching the max entries or the trading day is finished the EA it stops trading ) the update needs to recover a loss in case there are some previous days losses.

Bellow you can find the logic of the actual recovery implementation

Some more details about the core of the EA

🔁 Where and how the recovery is implemented in the code

The recovery system is not in a single line. It is implemented through three components that work together:


1️⃣ Loss tracking – UpdateHistory()

👉 This is where the EA decides which trades were losses and stores their lot sizes

📍 Function:

void UpdateHistory(int idx, int jdx)

📍 Key code:

LotSizes[nTrades] = HistoryDealGetDouble(tk, DEAL_VOLUME); if (pro >= 0) IsLoss[nTrades] = false; else IsLoss[nTrades] = true; nTrades++;

What this does:

  • Reads account trade history

  • Filters only trades:

    • with the current Magic Number

    • after SeqStartTime[idx][jdx] (current sequence only)

  • For every closed trade (DEAL_ENTRY_OUT):

    • stores:

      • LotSizes[] → used volume

      • IsLoss[] → whether it was a loss

📌 Without UpdateHistory() there is no recovery, because GetLot() would have no data.


2️⃣ Recovery lot calculation – GetLot()

👉 THIS is the actual recovery engine

📍 Function:

double GetLot()


🔹 Recovery activation

v = LotSizes[CurIdx]; if (IsLoss[CurIdx]) { ... }

➡️ Recovery starts only if the last trade was a loss.


🔹 Core recovery formula

vv = v / nRecov * SL / TP;

Where:

  • v = lot size of the losing trade

  • nRecov =

    • 2 for the first recovery

    • 4 for chained recoveries

  • SL / TP = risk-to-reward compensation ratio

📌 This is NOT classic martingale
✔ Lot size does not double
✔ Lot grows proportionally to SL / TP


🔹 Recursive recovery (loss chains)

CurIdx++; if (CurIdx == nTrades) { return vv; } else { if (IsLoss[CurIdx]) { res = GetLot(); if (res > 0) break; } }

📌 Meaning:

  • For multiple consecutive losses:

    • the EA walks through the loss chain

    • calculates a controlled recovery volume

    • avoids explosive growth

👉 Recursive but capped recovery


🔹 Safety limits

if (AddInitLot) limit += LotSize; if (Vol > MaxLot) Vol = MaxLot; if (Vol > 0.0001 && Vol < 0.01) Vol = 0.01;

✔ Maximum lot cap
✔ Minimum volume enforcement
✔ Optional addition of initial lot


3️⃣ Applying recovery to real trades – OnTick()

👉 This is where recovery becomes an actual trade

📍 Key code:

Vol = GetLot(); cmnt = "r "; if (Vol < 0 || nTrades == 0) { cmnt = "i "; Vol = UpdatedLotSize(); SeqStartTime[i][k] = TimeCurrent() - 1; }

Decision logic:

Condition Action
GetLot() > 0 Recovery trade ( "r " )
GetLot() < 0 Initial trade
nTrades == 0 Initial trade
Profit achieved Sequence resets

Order comments:

  • "i " = initial

  • "r " = recovery


❌ What this recovery system does NOT do

❌ No forced trades
❌ No grid entries
❌ No lot doubling
❌ No guaranteed breakeven
❌ No recovery without a valid signal

✔ Recovery only affects position sizing, not entries


🧠 Final conclusion

  • Loss detection → UpdateHistory()

  • Recovery math → GetLot()

  • Execution decision → OnTick()

👉 Recovery is volume-based, signal-dependent, and risk-capped.


Répondu

1
Développeur 1
Évaluation
(17)
Projets
21
19%
Arbitrage
5
40% / 40%
En retard
0
Gratuit
2
Développeur 2
Évaluation
(22)
Projets
28
7%
Arbitrage
9
33% / 33%
En retard
1
4%
Travail
3
Développeur 3
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
4
Développeur 4
Évaluation
(75)
Projets
80
6%
Arbitrage
46
11% / 54%
En retard
7
9%
Travail
5
Développeur 5
Évaluation
(319)
Projets
569
35%
Arbitrage
83
30% / 45%
En retard
206
36%
Travail
6
Développeur 6
Évaluation
(4)
Projets
3
33%
Arbitrage
2
0% / 100%
En retard
0
Gratuit
7
Développeur 7
Évaluation
(10)
Projets
14
43%
Arbitrage
0
En retard
3
21%
Gratuit
8
Développeur 8
Évaluation
(3)
Projets
1
100%
Arbitrage
3
0% / 100%
En retard
0
Gratuit
9
Développeur 9
Évaluation
(144)
Projets
186
41%
Arbitrage
24
58% / 21%
En retard
13
7%
Gratuit
10
Développeur 10
Évaluation
(16)
Projets
35
23%
Arbitrage
4
0% / 50%
En retard
2
6%
Travail
11
Développeur 11
Évaluation
(4)
Projets
4
25%
Arbitrage
1
0% / 100%
En retard
0
Gratuit
Publié : 2 articles
12
Développeur 12
Évaluation
(2675)
Projets
3414
68%
Arbitrage
77
48% / 14%
En retard
342
10%
Gratuit
Publié : 1 code
13
Développeur 13
Évaluation
(11)
Projets
18
28%
Arbitrage
4
50% / 50%
En retard
1
6%
Gratuit
14
Développeur 14
Évaluation
(16)
Projets
21
29%
Arbitrage
2
50% / 0%
En retard
4
19%
Travail
15
Développeur 15
Évaluation
(1)
Projets
1
0%
Arbitrage
3
0% / 100%
En retard
1
100%
Gratuit
16
Développeur 16
Évaluation
(2)
Projets
2
0%
Arbitrage
3
0% / 100%
En retard
1
50%
Gratuit
17
Développeur 17
Évaluation
Projets
0
0%
Arbitrage
0
En retard
0
Gratuit
18
Développeur 18
Évaluation
(29)
Projets
36
44%
Arbitrage
4
50% / 50%
En retard
3
8%
Gratuit
19
Développeur 19
Évaluation
(390)
Projets
416
30%
Arbitrage
74
19% / 72%
En retard
52
13%
Travail
20
Développeur 20
Évaluation
(13)
Projets
20
40%
Arbitrage
1
0% / 100%
En retard
1
5%
Gratuit
Commandes similaires
Create a bot that can trade and read indicators easy to read for first time users. Bot that can be used on a phone and connect to MT5. It should be easy to install or use on any device especially phone and laptop, preferably the bot that can run over night and controllable when needed
Need Grid + Martingale Type Averaging EA ( Directional Buy or Sell entry then uses grid/martingale for Recovery if need ) * Must Work Buy + Sell Both Side ( Do not Open Buy or Sell at Once Let the Previous Order Close ) * Min Lot size 0.01 * Max Lot Size 1 ( Can be Edited to maximum ) * Auto TP Shift * Auto Averaging Position also Auto Shift TP as per Averaging * After Averaging Close the Trade in Maximum Profit (
C'est un Expert Advisor (EA) MQL5 pour MetaTrader 5, conçu pour l' XAUUSD , combinant un filtre de tendance et une grille adaptative avec gestion de panier ("basket") et protections contre le drawdown. Version 1.00. Logique de trading Filtre de tendance (H4 par défaut) • EMA rapide (50) vs EMA lente (200) pour déterminer la direction (UP/DOWN) • Filtre ADX (période 14, seuil 18) pour éviter de trader en
I have 2 trading view indicators by GainzAlgo that I want code to mt5 , could u advise? I need you to give me response if you can convert This
Looking for an MT4/MT5 independent risk-management service or system that can monitor and automatically close trades opened and managed by another trader’s EA. The existing EA continuously removes/overrides manually added Stop Losses and may also override SLs placed by another EA. I need a solution that does not rely on modifying the existing trade or placing a Stop Loss. Instead, it should independently monitor each
I currently sell a white-label XAUUSD EA, but the existing supplier owns the source code. I now need a new, independently developed EA and licensing system that my company fully owns and controls. I am not requesting decompilation or copying of proprietary code. Existing settings, presets and trading examples will be provided as reference. The developer must first identify any missing strategy rules before
I am looking for an experienced trader, preferably a manual trader, with a minimum 12-month verifiable live trading track record. Requirements: - Target: Up to 10% monthly return - Maximum risk/drawdown tolerance: 20% - Maximum trade duration: 5 hours - No Martingale - No Hedging - No grid or other high-risk strategies - Minimum 12 months continuous track record - Track record must be independently verifiable through
Hello! I'm looking for an experienced programmer to help me fix bugs in NEOLOGICA, PROFIT. The code is written, without errors or warnings, but not everything works correctly. Please help me. I'm looking for a programmer for a long-term collaboration, so that this project can open doors to other interesting projects. :) You need to have access to this platform, but I think that's obvious
I DO NOT need any programming or strategy development. I already have a working NinjaTrader 8 automated strategy based on a 3/5 EMA crossover. I need you to run my existing strategy through NinjaTrader Strategy Analyzer/Optimizer, test the existing adjustable parameters, and find robust settings with the best profit factor and lowest reasonable drawdown. I will provide the existing NinjaScript ZIP. I do not want the
I need this MT5 EA to work according to the following exact logic: SYMBOL: Primarily optimized for XAUUSD/Gold. All important values such as lot size, SL, TP, spread and MA periods must remain adjustable from Inputs

Informations sur le projet

Budget
30 - 80 USD