TradingView → MT4/MT5 Signal Executor
A webhook server and MetaTrader Expert Advisor that turn TradingView alerts into managed trades, packaged as one-click Windows executables for non-technical users.
The problem
TradingView can fire alerts but can’t place orders on MetaTrader. The client sold a TradingView indicator and wanted his users to auto-trade its alerts on their own MT4 or MT5 accounts, with real risk management and no paid third-party bridge. Most users were not technical, so setup had to be one click.
What I built
- Webhook receiver in Python (Flask) with a shared-secret check. It parses JSON, plain-text and compact alert formats and exposes
/webhook,/status,/cleanupand/test. - File-queue handoff: each signal becomes a JSON file that moves through Pending → Processing → Executed or Failed folders in MetaTrader’s common files area.
- Expert Advisor for MT5 and MT4 that polls the queue and manages each trade:
- three sizing modes: fixed lot, risk percent or custom pips
- three take-profits with partial closes
- breakeven by three methods, and fixed, step or percent trailing
- equity drawdown and daily profit and loss limits, a spread filter, max trades per symbol and a direction filter
- automatic broker symbol mapping for suffixes like
.mor.cash, and a duplicate-signal filter
- Pine Script changes: a webhook-ready variant of the client’s indicator that emits the alert payload, plus a random-signal generator for end-to-end testing.
- Packaging: PyInstaller builds of the server, a setup wizard and a launcher, with a bundled ngrok tunnel and batch scripts to start, stop and test. It is delivered as a one-click zip, so users don’t need Python.
- Multi-account variant: one execution API routes to several MT5 terminals, with health checks and position-management endpoints.
- Docs: installation and user guides in English and Vietnamese, alert templates and support workflows.
Details
- MetaTrader’s file sandbox is the usual blocker for this kind of bridge. Writing to the common files folder with
FILE_COMMONlets the Python server and the EA share one queue without extra DLLs. - The folder-based states make every signal traceable. A failed order stays in
Failedwith its payload, instead of disappearing. - Tests cover the webhook sender and queue cleanup.