İş Gereklilikleri
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 codeThe 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:
📍 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:
🔹 Recovery activation
v = LotSizes[CurIdx]; if (IsLoss[CurIdx]) { ... }
➡️ Recovery starts only if the last trade was a loss.
🔹 Core recovery formula
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
✔ 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.