TradingView vs MetaTrader 5 for automated strategies
TradingView is practical when a signal begins as a Pine study or strategy on a chart. For a TradingView-to-webhook workflow, receiving the alert, translating the symbol and placing the order belong to the connected application. In MetaTrader 5, an Expert Advisor can process terminal events and submit requests through the account connection. Both workflows benefit from a decision log but put it in different places.
| Question | TradingView with webhook | MetaTrader 5 Expert Advisor |
|---|---|---|
| Where is the decision made? | In the alert’s server-side copy of the Pine script and chart context. Recreate the alert when changing the inputs used by that alert. | In your EA on terminal events. Check the current chart symbol and the closed bars required by the algorithm. |
| What proves a trade? | A venue acknowledgment and fill in your connected execution logs. A Pine alert proves the signal fired. | A terminal trade transaction or reconciled trade history. Log the request result alongside the execution event. |
| What to do on a restart? | Persist accepted intents and reconcile from the executing venue. | Reload strategy state and compare the journal with active orders and deal history. |
TradingView alert semantics · Webhook configuration and timeout · MQL5 tick events · MQL5 trade transactions
Write a narrow acceptance test
Choose a timeframe and compare just two signals around a known bar close. Store the exchange symbol, bar-close UTC, calculation version, side and unique strategy ID. Treat a valid, received alert as a new intent. Put actual fills in a second log with a broker ID, quantity, execution price and fee. Compare events by normalized timestamps and symbol rather than by a screenshot of the chart.
With a webhook, keep the receiver’s response path short and do the venue work separately after a durable acceptance step. With an EA, leave enough time for the expected terminal events and reconcile with trade history. If the timestamp of the completed bar is copied from a different timezone or timeframe, both integrations can evaluate a different signal even with matching indicator periods.
Screenshots and examples
Replay a delayed or duplicated signal
Three accepted intents out of six synthetic messages
Accept a fresh intent once if receive time minus bar close is within the configured limit.| Event | Bar close, ms | Receive, ms | Age, ms | Result | Accepted total |
|---|---|---|---|---|---|
| E1 | 0 | 950 | 950 | OK | 1 |
| E2 | 0 | 1450 | 1450 | DUP | 1 |
| E3 | 1000 | 4100 | 3100 | STALE | 1 |
| E4 | 4000 | 4650 | 650 | OK | 2 |
| E5 | 8000 | 7500 | -500 | EARLY | 2 |
| E6 | 8000 | 10000 | 2000 | OK | 3 |
The fixture uses a maximum age of 2,000 ms after the closed bar. E1 arrives at 950 ms and is accepted. E2 uses the same strategy, bar and side, so it is a duplicate. E3 arrives 3,100 ms after its bar close and is stale. E5 precedes the bar it refers to. E6 arrives exactly at the limit and is allowed. The labels in the table describe the decision log. Three accepted intents need their own execution evidence.
Preserve the identity through a restart
Include the venue, symbol, timeframe and strategy revision in the key when the same process handles several contexts. The in-memory fixture illustrates the state transition. In a deployed integration, persist the key together with the intent and reconcile after a restart or a submission timeout.
Reproduce the result in Python
import json
def classify(events, max_age_ms):
accepted = set()
rows = []
for label, strategy, close_ms, receive_ms, side in events:
age = receive_ms - close_ms
key = (strategy, close_ms, side)
if key in accepted:
outcome = "DUP"
elif age < 0:
outcome = "EARLY"
elif age > max_age_ms:
outcome = "STALE"
else:
outcome = "OK"
accepted.add(key)
rows.append([label, close_ms, receive_ms, age, outcome, len(accepted)])
return rows
def run():
arrivals = [
("E1", "A", 0, 950, "buy"),
("E2", "A", 0, 1450, "buy"),
("E3", "B", 1000, 4100, "buy"),
("E4", "A", 4000, 4650, "sell"),
("E5", "A", 8000, 7500, "buy"),
("E6", "A", 8000, 10000, "buy"),
]
rows = classify(arrivals, 2000)
assert [row[4] for row in rows] == ["OK", "DUP", "STALE", "OK", "EARLY", "OK"]
assert [row[5] for row in rows] == [1, 1, 1, 2, 2, 3]
return rows
if __name__ == "__main__":
print(json.dumps(run()))Change the age limit and replay the same sequence. Save the resulting event classification beside the signal definition. Replay trade and receive timestamps · Handle duplicate order submissions.