📚 Full Documentation: MT5 Trading Bot with Dynamic Management of TP and SL via Telegram

Python Skripte Sonstiges Python

Spezifikation

📚 Full Documentation: MT5 Trading Bot with Dynamic Management of TP and SL via Telegram
📌 Introduction
This trading bot automates order management on MetaTrader 5 (MT5) by tracking signals sent via Telegram. It ensures:
✅ Intelligent management of order entries (LIMIT or STOP) according to the market.
✅ Dynamic trading tracking with automatic adjustment of Stop Loss (SL) and Take Profit (TP).
✅ A secure link between each MT5 trade and its Telegram message for real-time update.
✅ An automatic deletion of unexecuted orders as soon as the market increases by +2 points.
✅ An automatic stop of the tracking as soon as the trade is closed (SL or TP reached).

🔹 1. Global Bot Operation
The bot works in 5 main steps:

1️⃣ Detection and placing of the main order (LIMIT or STOP) according to the market.
2️⃣ Immediate placement of backup orders (LIMIT or STOP) every 0.5 points until the final price (Y).
3️⃣ Dynamic management of SL and TP (automatic movement according to the TP reached).
4️⃣ Deletion of pending orders after +2 points and adjustment of the SL.
5️⃣ Automatic stop of the tracking once the trade is closed (SL or TP final reached).

✅ 2. Telegram Signal Format and Parameter Identification
📌 Telegram signals can be written in several ways, but they still contain these elements:
1️⃣ A type of order (BUY or SELL)
2️⃣ An entry price range (X-Y) or a single price (@X)
3️⃣ Stop Loss (SL)
4️⃣ One or more Take Profits (TP1, TP2, etc.)

📢 Examples of Telegram signals:

📌 Example 1 - SELL with entry price range:

Sell Gold @2919.50-2922.50
SL: 2930
TP1: 2905.50
TP2: 2903.50
📌 Example 2 - BUY with single entry price:

Buy XAUUSD @1845.00
SL: 1835
TP1: 1850
TP2: 1855
📌 Example 3 - BUY with entry price range and reinforcements:

BUY GOLD @1860.50-1864.50
SL: 1855
TP1: 1870
TP2: 1875
📌 If a price range is shown (X-Y):

X = Main entry price (main order).
Y = Reinforcement limit (last possible entry).
📌 If only one prize is given (@X):

The bot considers that X = Y and does not place reinforcements.
✅ 3. Determining the Main Order (LIMIT or STOP)
Case 1️⃣ : SELL order
📌 If X > Current Price Place a SELL LIMIT
📢 Example:

Signal: Sell Gold @2919.50-2922.50
Current Price = 2915.00
✅ Main order:

SELL LIMIT 0.1 lot @2919.50
✅ Reinforcements:
SELL LIMIT 0.01 lot @2920.00
SELL LIMIT 0.01 lot @2922.50
📌 If X < Current Price Place a SELL STOP
📢 Example:

Signal: Sell Gold @ 1915.50-1918.50
Current price = 1920.00
✅ Main order:

SELL STOP 0.1 lot @ 1915.50
✅ Reinforcements:
SELL LIMIT 0.01 lot @1916.00
SELL LIMIT 0.01 lot @1918.50
Case 2️⃣ : BUY order
📌 If X < Current Price Place a BUY LIMIT
📢 Example:

Signal: Buy Gold @1860.50-1864.50
Current price = 1870.00
✅ Main order:

BUY LIMIT 0.1 lot @1860.50
✅ Reinforcements:
BUY LIMIT 0.01 lot @1861.00
BUY LIMIT 0.01 lot @1864.50
📌 If X > Current Price Place a BUY STOP
📢 Example:

Signal: Buy Gold @1845.50-1850.50
Current price = 1840.00
✅ Main order:

BUY STOP 0.1 lot @1845.50
✅ Reinforcements:
BUY LIMIT 0.01 lot @1846.00
BUY LIMIT 0.01 lot @1850.50
✅ 4. Removal of non-executed orders after +2 points
📌 As soon as the market reaches X 2 points:
✅ Delete all unexecuted orders.
✅ Move all SL (main + reinforcements) to (X + Y) / 2 immediately.

📢 SELL example

🚀 +2 points reached! Removal of pending orders...

✅ All pending orders deleted.

🔒 SL moved to 2921.00.

✅ 5. Dynamic SL Management after TP1, TP2, etc.

📌 If TP1 is reached Move the SL to X

📌 If TP2 is reached Move the SL to TP1

📌 If TP3 is reached Move the SL to TP2


✅ 6. Linking the MT5 Trade with the Telegram Message

📌 The bot must ensure that each Telegram message is linked to its MT5 trade.

✅ Use of the MT5 order ticket as unique identifier.

✅ Association of the MT5 ticket with the Telegram message ID.


📢 Example of link:


📩 New Telegram message (ID=1306)

✅ SELL LIMIT order placed @2919.50 (ticket=15510303)

🔗 Link created: Telegram 1306 Trade MT5 15510303

📌 If Telegram changes the TP:


📩 Message edited (ID=1306)

✅ TP update for position 15510303

✅ 7. Close the Trade and Stop the Follow-up

📌 If the final SL or TP is reached:

✅ All positions are closed.

✅ The bot stops tracking the trade.


📌 Log expected:


✅ Trade closed at 2903.50 (TP final reached)

🛑 Trade 1306 tracking completed.


Bewerbungen

1
Entwickler 1
Bewertung
(294)
Projekte
469
39%
Schlichtung
100
41% / 23%
Frist nicht eingehalten
77
16%
Beschäftigt
Veröffentlicht: 2 Beispiele
2
Entwickler 2
Bewertung
Projekte
0
0%
Schlichtung
1
0% / 0%
Frist nicht eingehalten
0
Arbeitet
Ähnliche Aufträge
Il peut résoudre des exercices , générer des images et donner des idées chaque fois que tu lui demandes quelques choses il doit te répondre et doit être capable de répondre à n’importe quel question

Projektdetails

Budget
30+ USD