Ghost trades from webhooks haunt MT5 automation. You check your MT5 account in the morning. There are 3 open positions you did not place. Or worse — your strategy should have closed a trade at TP1, but the position is still running in the opposite direction. These are ghost trades, and they haunt webhook-based trading systems.
A recent Reddit thread in r/algotrading described this exact scenario: "I wake up to ghost trades — phantom orders that my strategy never signaled." The post got 200+ comments, most from traders dealing with the same problem. Here is why it happens and how to fix it.
What Are Ghost Trades?
Ghost trades are unwanted positions on your MT5 account that result from webhook automation errors. They come in three forms:
- Duplicate trades: The same signal executes twice (or more)
- Orphaned trades: A position is opened but the close signal never arrives
- Phantom orders: Orders appear with no corresponding TradingView alert
Cause 1: TradingView Webhook Retries
This is the most common cause. When TradingView sends a webhook, it expects an HTTP 200 response within a few seconds. If your server (or copier) is slow to respond — maybe it is busy executing a previous trade — TradingView assumes the delivery failed and resends the exact same webhook.
Your copier processes both requests. Two identical trades open.
The Fix: Idempotent Signal Processing
Your copier EA must deduplicate incoming signals. The approach:
- Generate a hash of each incoming signal (action + symbol + timestamp)
- Check if this hash was processed in the last 5–10 seconds
- If duplicate, respond with 200 but skip execution
- If new, execute and store the hash
TradingView Copier Pro handles this automatically with built-in deduplication. Every incoming webhook is hashed and compared against a sliding window of recent signals.
Cause 2: Race Conditions
When copying to multiple MT5 accounts, a race condition occurs when two EA instances try to process the same signal simultaneously. If the EA does not have proper concurrency handling, both instances may pass the "is this a duplicate?" check before either records it.
The Fix: Atomic Signal Locking
The EA should use a mutex or file lock to ensure only one instance processes a given signal at a time. This is particularly important on VPS setups where multiple terminals share the same data directory.
Cause 3: Failed Close Signals
Your strategy sends a close signal, but it arrives when the market is closed, the terminal is disconnected, or the symbol is different (broker suffix mismatch). The close fails silently. The position stays open. Your next entry signal fires, and now you have two positions where you should have zero.
The Fix: Close Confirmation Loop
- Verify close execution: After processing a close signal, the EA should confirm the position is actually closed
- Symbol remapping: Ensure your copier handles broker-specific symbol names.
EURUSDin TradingView vsEURUSDmon your broker - Market hours check: Queue close orders during market closure and execute when the market reopens
Cause 4: TradingView Alert Misconfiguration
Some ghost trades come from the alerts themselves:
| Misconfiguration | Result | Fix |
|---|---|---|
| Alert set to "Once Per Bar" on 1-min chart | Fires every minute if condition persists | Use "Once Per Bar Close" or "Only Once" |
| Multiple alerts on same symbol | Each fires independently | Consolidate into one alert per symbol |
| Strategy alert without proper exit logic | Entries fire but exits do not | Add strategy.close() calls to Pine Script |
| Invalid JSON in alert message | EA rejects close but opens next entry | Validate JSON format |
Cause 5: Network Interruption During Execution
Your VPS loses internet for 2 seconds. During that window:
- TradingView sends a close webhook → your server is unreachable → TradingView retries later
- TradingView sends a new entry webhook → this one gets through
- The close retry finally arrives → but now it closes your new position instead of the old one
The Fix: Order-Linked Close Signals
Use magic numbers or trade comments to link close signals to specific orders. When your close signal says "close the trade opened at 10:00", the EA knows exactly which position to target — not just "close all EURUSD."
Pro tip: Always include a magic number or comment field in your webhook JSON to uniquely identify each trade cycle. This prevents close signals from affecting the wrong positions.
Prevention Checklist
| Check | Action |
|---|---|
| Signal deduplication | EA must ignore duplicate signals within 5–10 second window |
| Fast webhook response | EA must respond HTTP 200 within 1 second to prevent retries |
| Symbol remapping | Verify broker symbol names match your copier config |
| Alert frequency | Use "Once Per Bar Close" not "Once Per Bar" for strategy alerts |
| Close confirmation | EA verifies positions are actually closed after processing close signals |
| Magic numbers | Use unique trade identifiers to link entries and exits |
| VPS uptime | Monitor VPS uptime — 99.9% means 8.7 hours of downtime per year |
| Webhook monitoring | Log all incoming webhooks with timestamps for debugging |
Zero Ghost Trades. Built-In Deduplication.
TradingView Copier Pro automatically deduplicates signals, confirms close execution, and handles symbol remapping. No phantom orders.
Get TradingView Copier Pro →