指定
Objective:
Create a MetaTrader 5 (MT5) Expert Advisor (EA) that acts as a protective shield for manually placed trades. The EA will manage open trades based on strict price movement rules, ensuring minimal losses and precise re-entries.
Core Logic Overview
1. Manual Trade Anchoring
-
Bot only activates after a manual trade is opened.
-
Uses the original manual entry price as the anchor.
-
Anchor price never changes unless a new manual trade is opened.
-
One active trade per symbol (per currency pair) at a time.
2. Trade Closing Logic
-
If price moves against the trade by 3 pips from the anchor, bot must close the trade immediately.
-
Precise closure rules:
-
BUY trade: Close if price drops 3 pips below entry.
-
SELL trade: Close if price rises 3 pips above entry.
-
-
Closure must happen exactly at 3 pips.
3. Re-Entry Logic
-
After closing a trade, bot waits for price to cross back favourably through the original entry price.
-
Re-entry conditions:
-
BUY trade: Reopen if price crosses 2 pips above the original entry price.
-
SELL trade: Reopen if price crosses 2 pips below the original entry price.
-
-
Reopened trades must use the same lot size as the original manual trade.
4. One Trade Per Currency Pair
-
Bot must only manage one active trade per currency pair.
-
Multiple pairs can be managed independently.
5. Passive Mode if Price Moves Away
-
If price moves further away from the entry after closure, bot does nothing.
-
Bot will only react again if price returns to entry level.
-
Bot remains passive until:
-
Price crosses the re-entry level.
-
Or a new manual trade is opened (resets anchor).
-
6. 24/7 Auto Operation
-
Bot operates continuously without manual interaction.
-
Must react instantly even during high volatility or fast price movements.
7. Take Profit Respect
-
After re-opening a trade, bot must assign the same Take Profit (TP) as the original manual trade.
-
TP must always be preserved for all re-entries.
8. Graphical User Interface (GUI) Panel
-
Display real-time status per currency pair:
-
If trade is active and in profit: "Trade in Profit"
-
If trade was closed and waiting for re-entry: "Trade Closed, Waiting for Re-Entry"
-
If no manual trade yet: "Waiting for Manual Entry"
-
-
Display status for multiple pairs independently:
-
Example:
-
EURUSD: Trade in Profit
-
XAUUSD: Waiting for Re-Entry
-
-
9. Chart Visuals
-
White dotted line at the anchor (entry) price when manual trade is opened.
-
Red line at stop-loss level (closure trigger):
-
BUY trade: 3 pips below entry.
-
SELL trade: 3 pips above entry.
-
-
Blue line at re-entry level:
-
BUY trade: 2 pips below original entry.
-
SELL trade: 2 pips above original entry.
-
10. Sound Alerts
-
Play a sound (" operationinicialized.wav ") every time a manual trade is opened.
11. Post Take Profit Behavior
-
After hitting Take Profit, bot must:
-
Shut off management for that symbol.
-
Wait for the next new manual trade to reset and restart.
-