Docs › Setup guides › MetaTrader setup
MetaTrader setup
MetaTrader 5 and 4 can't send a webhook from an alert dialog. An Expert Advisor or script sends it with WebRequest(). Our free HoldAlarms.mqh does that for you: point it at your HoldAlarms webhook URL and HoldAlarms forwards each alert to your destinations, with retries.
What MetaTrader allows
WebRequest()works in Expert Advisors and scripts. In an indicator it fails with error 4014.- It doesn't run in the Strategy Tester.
- The server must be on the allowed list, or the call returns -1.
- It blocks your EA until the reply arrives or the timeout runs out, and it sends once.
Source: MQL5 reference: WebRequest.
1. Allow the HoldAlarms URL
- In MetaTrader, open Tools → Options → Expert Advisors.
- Tick Allow WebRequest for listed URL.
- Add
https://api.holdalarms.comand click OK.
2. Add the include
- Download
HoldAlarms.mqhfrom our MIT-licensed HoldAlarms snippets repository (foldermetatrader/MQL5ormetatrader/MQL4). - In MetaTrader, click File → Open Data Folder and copy it into
MQL5/Include(orMQL4/Include). - In your EA, add
#include <HoldAlarms.mqh>and an input for the URL.
#include <HoldAlarms.mqh>
input string InpWebhookUrl = ""; // paste your HoldAlarms webhook URL
// when your EA decides to alert:
HoldAlarmsAlert(InpWebhookUrl, "buy");
// or send your own body:
HoldAlarmsSend(InpWebhookUrl, "{\"ticker\":\"EURGBP\",\"action\":\"sell\"}");
HoldAlarmsAlert sends a small JSON alert with source, symbol, action, price and fired_at (UTC). A body that starts with { or [ goes as application/json, anything else as text/plain. HoldAlarms forwards it unchanged.
3. Timeouts and repeats
The include waits at most 3 seconds per try and tries twice, only on a network error or a 5xx. It doesn't repeat a 4xx such as 401 (wrong token). HoldAlarms answers as soon as the alert is queued, so your EA isn't held up by your own endpoint. If your endpoint needs to spot a repeat, pass your own id.
4. Test it
Run the HoldAlarmsTest script on any chart, then check recent alerts on your dashboard. The Experts tab shows the HTTP code. Your webhook URL is secret: don't share EA settings files that contain it.
Step-by-step guide with common problems: MetaTrader 5 and 4 webhook alerts.
HoldAlarms is not affiliated with MetaQuotes. MetaTrader is a trademark of MetaQuotes Ltd.
← TrendSpider setup · NinjaTrader setup →
HoldAlarms is not affiliated with TradingView. TradingView is a trademark of TradingView, Inc.