Skip to content

Send TradingView or n8n alerts to MetaTrader 5 with a REST API

Updated 2026-11-22

FiveSocket cannot receive a TradingView alert directly, because it has no inbound webhooks. Put a small relay in between. TradingView posts the alert to an n8n Webhook node, or to any service you host, and an n8n HTTP Request node then sends POST https://api.fivesocket.com/v1/accounts/{accountId}/execution/orders to FiveSocket with an API key. FiveSocket places the order on your MT5 account. You run no Expert Advisor, no Windows VPS and no MT5 terminal.

7-day free trial. Paid plans start at $9.99 a month. See pricing

How the pieces fit

FiveSocket is a hosted MT5 REST API. It answers requests that you send. It does not accept webhooks, and it has no streams or WebSocket, so it cannot be the address a TradingView alert posts to.

The relay is what turns an alert into a request. Any tool that can receive a webhook and send an HTTPS request will do. n8n is one option, because its Webhook and HTTP Request nodes cover both halves.

  1. TradingView fires the alert

    The alert sends its message as the body of a webhook request to the URL you give it. Write the message as JSON so the next step can read it.

  2. n8n receives it

    An n8n Webhook node accepts the request and holds the alert JSON.

  3. n8n checks it and calls FiveSocket

    An HTTP Request node sends a POST to the FiveSocket execution endpoint, with the order fields taken from the alert.

  4. FiveSocket places the order

    FiveSocket checks the key and the account's trading policy, then sends the order to MT5 from its hosted terminal.

What you need

  • An MT5 login, its password, and the exact server name shown in your MT5 terminal. Link it once in FiveSocket. Any broker that offers MT5 works.
  • A FiveSocket API key with the trading:execute scope. You create it in the control panel and see it once.
  • An n8n instance, or another relay that can receive a webhook and send an HTTPS request.
  • A TradingView alert that can send a webhook. Check that your TradingView plan includes webhooks.
  • A FiveSocket account. Link your MT5 account and try it free, no card: 24 hours or 100 calls, whichever comes first. Then a 7-day free trial, card required. Cancel anytime. The trial includes one connected MT5 account.

Not sure your broker's server name will link? Check the brokers FiveSocket has already verified. See supported brokers

Turn trading on for the account

Trading stays off until you send a policy with exact symbols and the largest order size for each. FiveSocket first checks that MT5 allows trading on the account. An order for a symbol outside the policy is refused before it reaches MT5.

curl -X PUT https://api.fivesocket.com/v1/accounts/acc_7Hq2Xv/execution \
  -H "Authorization: Bearer $FIVESOCKET_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: enable-1" \
  -d '{"symbols":[{"symbol":"EURUSD","maxVolume":"0.10"}]}'

Write the alert message

Make the TradingView alert message a JSON object. The field names are your own choice, because the relay maps them to the order. The token is a shared secret, explained below.

{
  "token": "a-long-random-string",
  "symbol": "EURUSD",
  "side": "buy",
  "volume": "0.10"
}

Send the order from n8n

In the HTTP Request node, set the method to POST and the URL to the execution orders endpoint for your account. Add the headers below and send a JSON body, filling the symbol, side and volume from the alert. This curl request shows what the node should send.

curl -X POST https://api.fivesocket.com/v1/accounts/acc_7Hq2Xv/execution/orders \
  -H "Authorization: Bearer $FIVESOCKET_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1" \
  -d '{"clientOrderId":"order-1","symbol":"EURUSD","side":"buy","type":"market","volume":"0.10"}'
  • Authorization: Bearer with your FiveSocket API key. Keep it in n8n credentials, not in the workflow text.
  • Idempotency-Key on every write. A retry with the same key and the same order does not send the order twice.
  • clientOrderId must be unique for the account. Build it from something unique to the alert, such as a timestamp or an alert ID.
  • Volumes and prices are decimal strings, such as "0.10".

Close a position from an alert

Closing uses the position's ID. Read the open positions first, then post to the close endpoint. Leave out volume to close the whole position.

curl -H "Authorization: Bearer $FIVESOCKET_KEY" \
  https://api.fivesocket.com/v1/accounts/acc_7Hq2Xv/positions
curl -X POST https://api.fivesocket.com/v1/accounts/acc_7Hq2Xv/execution/positions/19283746/close \
  -H "Authorization: Bearer $FIVESOCKET_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: close-1" \
  -d '{"clientOrderId":"close-1"}'

Check a secret before forwarding

A TradingView webhook URL has no sign-in, so anyone who finds the URL can post to it. We recommend that the alert message carries a long random token and that n8n compares it with a stored value before it calls FiveSocket. Drop the request if it does not match. Keep the policy's symbols and sizes narrow as well.

Trading leveraged FX and CFDs carries a high risk of losing money quickly. Try any new setup on a demo account first. FiveSocket connects software to your account, and neither FiveSocket nor an AI assistant's output is investment advice.

Limits

  • FiveSocket pushes nothing back. It has no webhooks, price stream or WebSocket, so n8n must poll with GET requests to see positions or balance.
  • Each plan has a requests-per-minute limit per API key: Starter 60, Plus 120, Scale 300. Requests over the limit get a 429 response.
  • The first request after a session has gone idle logs in to your broker and can take several seconds. A 202 response with the code account_warming means repeat the request after the delay it gives.
  • A trading response can come back as commit_unknown when the broker's reply is lost. Do not send a new order. Poll the original command until it reaches a final state.
  • FiveSocket does not run Expert Advisors, indicators or MQL5 code. The strategy logic stays in TradingView or n8n.

Frequently asked questions

Can TradingView send orders straight to MT5 through FiveSocket?
No. FiveSocket has no inbound webhooks, so it cannot receive a TradingView alert itself. Send the alert to a relay such as an n8n Webhook node, then have the relay call the FiveSocket REST API.
Do I need an Expert Advisor or a Windows VPS?
No. FiveSocket hosts the MT5 terminal. Nothing runs on your side except the relay, and it does not need Windows or MT5.
Does FiveSocket push updates back to n8n?
No. There are no webhooks, streams or WebSocket. A workflow that needs positions or balance polls the GET endpoints, within the plan's rate limit.
Is there an n8n node for FiveSocket?
No. Use the standard HTTP Request node with the method, URL, headers and JSON body shown on this page.
How do I stop strangers from triggering trades?
Add a long random token to the alert message and have the relay check it before it forwards the order. FiveSocket also refuses any order outside the symbols and sizes you allowed for the account.
Which brokers work?
Every MT5 broker. You supply the exact server name from your MT5 terminal, and the brokers FiveSocket has already checked are listed on the brokers page.
How much does it cost?
Plans start at $9.99 a month for one MT5 account. Link your MT5 account and try it free, no card: 24 hours or 100 calls, whichever comes first. Then a 7-day free trial, card required. Cancel anytime. The trial includes one connected MT5 account.

Try it on your own account.

Link your MT5 account and try it free, no card: 24 hours or 100 calls, whichever comes first. Then a 7-day free trial, card required. Cancel anytime. The trial includes one connected MT5 account. Cancel before the trial ends and you are not charged. A demo account is the safest place to start.

7-day free trial. Paid plans start at $9.99 a month. See pricing