Documentation

Using AlertConnector

From installing the EA to the full syntax of every order type. Already have an account? The guide in your dashboard fills in your own values and includes an alert builder.

Contents

Quick start

About fifteen minutes, with MetaTrader 5 on your own computer or a VPS.

  1. 1
    Get your Account ID, EA Token and webhook: click “Start free trial” on the home page (no sign-up), or create an MT5 account in the dashboard if you have a license.
  2. 2
    Install the EA in MetaTrader 5 and paste the Account ID and EA Token.
  3. 3
    Create an alert on TradingView with the webhook URL and the signal message.
  4. 4
    Test on a demo account first and check the result in the signal history.

Install the EA in MT5

  1. 1
    In MT5 choose File → Open Data Folder and copy the EA file into MQL5/Experts. In the Navigator window, right-click → Refresh.
  2. 2
    Open Tools → Options → Expert Advisors, tick “Allow WebRequest for listed URL” and add https://alertconnector.vercel.app. Without this the EA cannot reach the server.
  3. 3
    Drag the EA onto one chart — any chart; one EA handles every symbol. Paste AccountId and EaToken in the Inputs tab.
  4. 4
    Turn on Algo Trading in the toolbar. When the Experts tab at the bottom shows the AlertConnector start-up line, the EA is running.

MetaTrader must be open for orders to go through. To run all day without leaving a personal computer on, use a Windows VPS.

Create a TradingView alert

  1. 1
    Open the alert dialog (the alarm-clock icon) on a chart or strategy.
  2. 2
    Notifications tab: turn on Webhook URL and paste an address like https://alertconnector.vercel.app/api/webhook/<Account ID>.
  3. 3
    Message tab: clear the default text and paste the JSON signal (see syntax).
  4. 4
    Set a trigger frequency that suits your strategy, then save.

Webhooks are a feature of TradingView’s paid plans, and your TradingView account must have two-factor authentication on.

Signal syntax

Each signal is a JSON object. Field names are lowercase; numbers are written without quotes.

{
  "secret": "<Webhook Secret>",
  "symbol": "XAUUSD",
  "action": "buy",
  "volume": 0.05,
  "sl_pips": 30,
  "tp_pips": 60
}
FieldRequiredMeaning
secretRequiredThe account’s Webhook Secret (from the dashboard). It is never stored in the history.
symbolRequiredThe symbol name exactly as in your broker’s Market Watch, e.g. XAUUSD, XAUUSDm. The EA enables the symbol if it is hidden.
actionRequiredOne of the nine order types.
volumeOptionalVolume in lots. If missing, the EA’s DefaultLot is used. The EA rounds to the broker’s lot step and clamps to its minimum and maximum.
sl_price · sl_points · sl_pipsOptional, pick oneStop loss as a price, a distance in points, or in pips. If missing, the EA’s DefaultSl is used.
tp_price · tp_points · tp_pipsOptional, pick oneTake profit, same rules as SL. If missing, DefaultTp is used.
offset_pointsBreak-even onlyMoves the SL to the entry price plus this many points in the profitable direction, to lock in a small gain. Default 0.

Units: points are the symbol’s smallest price step; 1 pip = 10 points for every symbol. Each SL (and each TP) may use only one form — sending both sl_price and sl_points is rejected.

The nine order types

Modify, break-even and close_all orders only affect positions AlertConnector opened (identified by MagicNumber), on the same symbol and in the same direction.

buy / sell

Opens a buy / sell at market price.

Needs: symbol; optional volume, SL, TP.

{ "secret": "…", "symbol": "XAUUSD", "action": "buy", "volume": 0.05, "sl_pips": 30, "tp_pips": 60 }

close_all

Closes every position of that symbol that AlertConnector opened. Manual trades and other EAs are not touched.

Needs: symbol.

{ "secret": "…", "symbol": "XAUUSD", "action": "close_all" }

modify_sl_long / modify_sl_short

Moves the SL of every buy (long) or sell (short) position of that symbol.

Needs: symbol and one of sl_price / sl_points / sl_pips.

{ "secret": "…", "symbol": "EURUSD", "action": "modify_sl_long", "sl_price": 1.085 }

modify_tp_long / modify_tp_short

Moves the TP of every buy or sell position of that symbol.

Needs: symbol and one of tp_price / tp_points / tp_pips.

{ "secret": "…", "symbol": "EURUSD", "action": "modify_tp_short", "tp_points": 400 }

breakeven_long / breakeven_short

Moves the SL of buy or sell positions to their entry price (break-even).

Needs: symbol; optional offset_points.

{ "secret": "…", "symbol": "BTCUSD", "action": "breakeven_long", "offset_points": 50 }

Which field works with which action

Fieldbuy · sellbuy_limit · …_stopclose_*cancel_pending*modify_sl_*modify_tp_*breakeven_*
secretrequiredrequiredrequiredrequiredrequiredrequiredrequired
symbolrequiredrequiredrequiredrequiredrequiredrequiredrequired
actionrequiredrequiredrequiredrequiredrequiredrequiredrequired
volume · risk_percent · risk_moneyoptional, one typeoptional, one type—————
price—required—————
stoplimit_price—required—————
expiry_minutes—optional—————
sl_price · sl_points · sl_pipsoptional, one typeoptional, one type——required, one type——
tp_price · tp_points · tp_pipsoptional, one typeoptional, one type———required, one type—
close_oppositeoptional——————
close_percent——optional————
offset_pointsoptionaloptional————optional
be_trigger_pointsoptionaloptional—————
trail_points · trail_trigger_points · trail_step_pointsoptionaloptional—————
max_spread_pointsoptional——————
commentoptionaloptional—————

stoplimit_price: buy_stop_limit · sell_stop_limit (MetaTrader 5 only.)

1 pip = 10 points on every symbol. Distances in points/pips are measured from the current price (from the order price for pending orders).

Load a ready-made example…

Market order

buy · BTCUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "BTCUSD",
  "action": "buy"
}

sell · 0.05 lot · XAUUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "XAUUSD",
  "action": "sell",
  "volume": 0.05
}

buy · SL/TP points · 0.01 lot · BTCUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "BTCUSD",
  "action": "buy",
  "volume": 0.01,
  "sl_points": 50000,
  "tp_points": 100000
}

sell · SL/TP pips · 0.1 lot · EURUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "EURUSD",
  "action": "sell",
  "volume": 0.1,
  "sl_pips": 20,
  "tp_pips": 40
}

buy · SL/TP price · 0.02 lot · XAUUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "XAUUSD",
  "action": "buy",
  "volume": 0.02,
  "sl_price": 2030.5,
  "tp_price": 2070
}

sell · SL/TP price · 0.1 lot · GBPUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "GBPUSD",
  "action": "sell",
  "volume": 0.1,
  "sl_price": 1.2765,
  "tp_price": 1.2615
}

buy · SL/TP pips · 1% · XAUUSD

The EA computes the lot from the SL distance, so hitting the SL loses exactly this amount.

{
  "secret": "<Webhook Secret>",
  "symbol": "XAUUSD",
  "action": "buy",
  "risk_percent": 1,
  "sl_pips": 30,
  "tp_pips": 60
}

sell · SL price · $50 · EURUSD

The EA computes the lot from the SL distance, so hitting the SL loses exactly this amount.

{
  "secret": "<Webhook Secret>",
  "symbol": "EURUSD",
  "action": "sell",
  "risk_money": 50,
  "sl_price": 1.0872
}

buy · SL pips · 0.01 lot · XAUUSD

close_opposite: true closes the opposite side first, so one alert reverses the position.

{
  "secret": "<Webhook Secret>",
  "symbol": "XAUUSD",
  "action": "buy",
  "volume": 0.01,
  "close_opposite": true,
  "sl_pips": 30
}

buy · SL points · 0.01 lot · BTCUSD

The EA manages the SL by itself: breakeven after be_trigger_points, then it trails trail_points behind the price.

{
  "secret": "<Webhook Secret>",
  "symbol": "BTCUSD",
  "action": "buy",
  "volume": 0.01,
  "sl_points": 50000,
  "be_trigger_points": 30000,
  "offset_points": 500,
  "trail_points": 40000,
  "trail_trigger_points": 60000,
  "trail_step_points": 1000
}

sell · TP pips · 0.1 lot · USDJPY

{
  "secret": "<Webhook Secret>",
  "symbol": "USDJPY",
  "action": "sell",
  "volume": 0.1,
  "tp_pips": 50,
  "max_spread_points": 30,
  "comment": "breakout"
}

Pending order

buy_limit · SL/TP pips · 0.01 lot · XAUUSD

The order waits at "price": buy_limit and sell_stop go below the market, sell_limit and buy_stop above.

{
  "secret": "<Webhook Secret>",
  "symbol": "XAUUSD",
  "action": "buy_limit",
  "price": 2030,
  "volume": 0.01,
  "sl_pips": 50,
  "tp_pips": 100
}

sell_limit · SL price · TP points · 0.1 lot · EURUSD

The order waits at "price": buy_limit and sell_stop go below the market, sell_limit and buy_stop above.

{
  "secret": "<Webhook Secret>",
  "symbol": "EURUSD",
  "action": "sell_limit",
  "price": 1.0875,
  "volume": 0.1,
  "sl_price": 1.0905,
  "tp_points": 300,
  "expiry_minutes": 240
}

buy_stop · SL points · 0.5% · BTCUSD

The order waits at "price": buy_limit and sell_stop go below the market, sell_limit and buy_stop above.

{
  "secret": "<Webhook Secret>",
  "symbol": "BTCUSD",
  "action": "buy_stop",
  "price": 63500,
  "risk_percent": 0.5,
  "sl_points": 40000
}

sell_stop · SL/TP pips · 0.1 lot · GBPUSD

The order waits at "price": buy_limit and sell_stop go below the market, sell_limit and buy_stop above.

{
  "secret": "<Webhook Secret>",
  "symbol": "GBPUSD",
  "action": "sell_stop",
  "price": 1.269,
  "volume": 0.1,
  "sl_pips": 25,
  "tp_pips": 50,
  "expiry_minutes": 60
}

buy_stop_limit · SL pips · 0.01 lot · XAUUSD

MetaTrader 5 only.

{
  "secret": "<Webhook Secret>",
  "symbol": "XAUUSD",
  "action": "buy_stop_limit",
  "price": 2050,
  "stoplimit_price": 2048,
  "volume": 0.01,
  "sl_pips": 40
}

sell_stop_limit · TP pips · 0.1 lot · EURUSD

MetaTrader 5 only.

{
  "secret": "<Webhook Secret>",
  "symbol": "EURUSD",
  "action": "sell_stop_limit",
  "price": 1.082,
  "stoplimit_price": 1.0825,
  "volume": 0.1,
  "tp_pips": 30
}

Close

close_all · BTCUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "BTCUSD",
  "action": "close_all"
}

close_long · XAUUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "XAUUSD",
  "action": "close_long"
}

close_short · 50% · EURUSD

close_percent closes only part of each position; the rest stays open.

{
  "secret": "<Webhook Secret>",
  "symbol": "EURUSD",
  "action": "close_short",
  "close_percent": 50
}

close_all · *

"symbol": "*" applies to every symbol traded by this EA.

{
  "secret": "<Webhook Secret>",
  "symbol": "*",
  "action": "close_all"
}

Cancel pending

cancel_pending · XAUUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "XAUUSD",
  "action": "cancel_pending"
}

cancel_pending_long · BTCUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "BTCUSD",
  "action": "cancel_pending_long"
}

cancel_pending_short · *

"symbol": "*" applies to every symbol traded by this EA.

{
  "secret": "<Webhook Secret>",
  "symbol": "*",
  "action": "cancel_pending_short"
}

Move SL / TP

modify_sl_long · SL price · XAUUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "XAUUSD",
  "action": "modify_sl_long",
  "sl_price": 2035
}

modify_sl_long · SL points · BTCUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "BTCUSD",
  "action": "modify_sl_long",
  "sl_points": 30000
}

modify_sl_short · SL pips · EURUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "EURUSD",
  "action": "modify_sl_short",
  "sl_pips": 15
}

modify_tp_long · TP price · XAUUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "XAUUSD",
  "action": "modify_tp_long",
  "tp_price": 2080
}

modify_tp_long · TP pips · USDJPY

{
  "secret": "<Webhook Secret>",
  "symbol": "USDJPY",
  "action": "modify_tp_long",
  "tp_pips": 60
}

modify_tp_short · TP points · EURUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "EURUSD",
  "action": "modify_tp_short",
  "tp_points": 400
}

Breakeven

breakeven_long · BTCUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "BTCUSD",
  "action": "breakeven_long"
}

breakeven_short · XAUUSD

{
  "secret": "<Webhook Secret>",
  "symbol": "XAUUSD",
  "action": "breakeven_short",
  "offset_points": 50
}

TradingView variables

buy · SL/TP pips · 0.01 lot

The symbol follows the chart the alert is created on.

{
  "secret": "<Webhook Secret>",
  "symbol": "{{ticker}}",
  "action": "buy",
  "volume": 0.01,
  "sl_pips": 30,
  "tp_pips": 60
}

strategy

For strategy alerts: direction and size come from the strategy. Make sure the strategy’s contracts match your broker’s lots.

{
  "secret": "<Webhook Secret>",
  "symbol": "{{ticker}}",
  "action": "{{strategy.order.action}}",
  "volume": {{strategy.order.contracts}},
  "close_opposite": true
}

modify_sl_long · SL price

For indicator alerts: the SL level comes from the first plot of your script.

{
  "secret": "<Webhook Secret>",
  "symbol": "{{ticker}}",
  "action": "modify_sl_long",
  "sl_price": {{plot_0}}
}

buy_limit · SL pips · 0.01 lot

The order waits at "price": buy_limit and sell_stop go below the market, sell_limit and buy_stop above.

{
  "secret": "<Webhook Secret>",
  "symbol": "{{ticker}}",
  "action": "buy_limit",
  "price": {{low}},
  "volume": 0.01,
  "sl_pips": 30
}

TradingView variables

TradingView replaces variables in double curly braces before sending, so one alert works on many charts:

{
  "secret": "<Webhook Secret>",
  "symbol": "{{ticker}}",
  "action": "{{strategy.order.action}}",
  "volume": 0.01
}

{{ticker}} is the chart’s symbol. For strategy alerts, {{strategy.order.action}} returns buy or sell. If TradingView’s symbol name differs from your broker’s, write the broker’s name directly instead of using {{ticker}}.

EA inputs

Set these in the Inputs tab when attaching the EA to a chart.

InputDefaultEffect
AccountId—Account ID from the dashboard (or the trial panel).
EaToken—EA Token that goes with the Account ID. With a wrong token the EA stops calling the server and reports it in the Experts tab.
ServerBaseUrlhttps://alertconnector.vercel.appServer address. No need to change it.
CheckIntervalSeconds1How many seconds between server checks (minimum 1).
DefaultLot0.01Volume used when a signal has no volume.
MagicNumber20260816The EA’s order tag. close_all and modify orders only affect positions carrying this tag.
MaxOpenPositions20Maximum open positions at once (0 = unlimited). Beyond it, new orders are rejected.
DefaultUnitPointsUnit for DefaultSl and DefaultTp.
DefaultSl / DefaultTp0Default SL / TP when a signal has none (0 = none).
RequireStopLossfalseWhen on, every opening order without an SL is rejected.
OnlyImproveStopLossfalseWhen on, SL modifications may only reduce risk.

Limits & safeguards

  • 60-second expiry: signals the EA has not picked up after 60 seconds are skipped, never traded at stale prices.
  • 5 signals / 60 seconds per account; beyond that the webhook returns 429.
  • Deduplication: identical signals within 10 seconds are accepted once (409).
  • Open-position cap: MaxOpenPositions, default 20.
  • Stop losses on the wrong side of the current price are rejected with a reason.

Security

Each account has its own Webhook Secret (for TradingView to send signals) and EA Token (for the EA to fetch them). AlertConnector never needs your broker password: the EA places orders inside your MetaTrader.

Sending signals from your own script instead of TradingView? You can omit the secret field and sign the request body with an X-Signature header = HMAC-SHA256 (hex) of the raw body, keyed with the Webhook Secret.

Never post screenshots showing your Webhook Secret or EA Token. When sending screenshots to support, cover both values.

Troubleshooting

Each signal in the history has one of these statuses:

StatusMeaning
SuccessThe EA executed the order. A broker ticket is shown.
Nothing to doValid syntax but nothing to execute — e.g. close_all with no positions left. Not an error.
ErrorThe broker or the EA rejected it. The reason is shown right under the label, with the broker code if any.
EA did not pick upThe EA did not fetch the signal within 60 seconds, so it was skipped to avoid trading at a stale price.
Waiting / ProcessingThe signal just arrived; the EA has not fetched it yet or is executing it.

Webhook response codes (TradingView shows them in the alert log):

CodeCause
200Signal received.
400Invalid JSON, missing symbol, or an action not in the list.
401Webhook Secret does not match, or the URL has the wrong Account ID.
403License expired, trial expired, or the account is paused.
409An identical signal was received in the last 10 seconds (TradingView retried or the test was clicked twice).
429More than 5 signals within 60 seconds for one account.

EA not receiving signals? Check in order: MT5 is open and logged in; Algo Trading is on; https://alertconnector.vercel.app is in the WebRequest list; Account ID and EA Token are correct; the Experts tab shows no 401 error.

Still stuck? Email hello@tradeedgelab.com with a screenshot of the Experts tab and your signal history (cover your secret keys).