OANDA Guide
Connect TradingView to OANDA (forex, metals, indices, commodities) using TradeAdapter’s direct API integration. This guide covers strategy alerts with the OANDA message format.
Video walkthrough #
Coming soon
A video walkthrough for OANDA + TradingView will be added here. Meanwhile, follow the steps below.
1 — Create OANDA account and get API credentials #
OANDA uses a User ID and an API Token (not a classic API key/secret pair). Create a Demo or Real account, then generate the token from your account settings.
-
Choose account type
Create a Demo account at oanda.com/apply/demo or a Real account at oanda.com/apply/. We recommend starting with Demo.
-
Get User ID and API Token
In your OANDA account, open the section where you can view your User ID and Generate (or manage) your API Token. Copy the User ID and generate/copy the token — you will use them in the alert message as
oanda_user_idandoanda_api_token.
TradeAdapter: Create OANDA account (step-by-step with screenshots)
2 — Select the OANDA symbol in TradingView #
In TradingView, search for the symbol that matches the instrument you trade on OANDA (forex pairs, metals, indices, commodities). The {{ticker}} placeholder will send this symbol to TradeAdapter. Supported symbols and minimum quantities vary by region.
OANDA — Allowed symbols (TradingView symbol names and min quantity). For stocks, check OANDA instruments specification for your region.
3 — Add your strategy #
OANDA supports strategy alerts. Load your Pine Script strategy onto the chart so it generates the trading signals.
Strategy
Use one alert with trigger “Order fills only”. TradingView fills action, size, and price via {{strategy.order.action}}, {{strategy.order.contracts}}, {{strategy.order.price}}.
Not sure if you have a strategy or an indicator? See Indicator vs Strategy.
4 — Configure order size #
Set your strategy’s position size so that {{strategy.order.contracts}} meets the symbol’s rules on OANDA (minimum quantity, precision). For Limit orders, ensure {{strategy.order.price}} respects the symbol’s precision. Check the allowed symbols table for min quantity per instrument.
5 — Create the TradingView alert #
Press Alt + A (or the alarm clock icon) to create a new alert.
Strategy → one alert
Under Condition, select your strategy and set trigger to “Order fills only”. TradingView fills action, size, and price via the strategy placeholders.
Webhook URL — Demo vs Real
In Notifications, enable Webhook URL and paste the endpoint that matches your account:
- Demo:
https://tradeadapter.com/api/oanda/demo_order - Real:
https://tradeadapter.com/api/oanda/real_order
Paste the JSON message in the Message field (see template below). Your TradeAdapter key goes inside the message as tradeadapter_key — get it from your TradeAdapter profile.
Important: Recreate the TradingView alert each time you change your Pine Script strategy parameters.
Alert message (Strategy) #
Use this template for strategy-based alerts. Replace the placeholder values with your TradeAdapter key, OANDA User ID, and OANDA API Token. Keep the TradingView placeholders as-is.
{
"tradeadapter_key": "PUT YOUR TRADEADAPTER KEY HERE",
"oanda_user_id": "PUT YOUR OANDA USER ID HERE",
"oanda_api_token": "PUT YOUR OANDA API TOKEN HERE",
"time": "{{timenow}}",
"exchange": "{{exchange}}",
"ticker": "{{ticker}}",
"position_size": "{{strategy.position_size}}",
"order_action": "{{strategy.order.action}}",
"order_contracts": "{{strategy.order.contracts}}",
"order_price": "{{strategy.order.price}}",
"order_id": "{{strategy.order.id}}",
"market_position": "{{strategy.market_position}}",
"market_position_size": "{{strategy.market_position_size}}",
"prev_market_position": "{{strategy.prev_market_position}}",
"prev_market_position_size": "{{strategy.prev_market_position_size}}"
}
TradeAdapter: Connect TradingView to OANDA (full connect steps)
Message fields explained #
| Field | Description |
|---|---|
tradeadapter_key |
Your TradeAdapter key from TradeAdapter profile. |
oanda_user_id |
Your OANDA User ID (from OANDA account settings). |
oanda_api_token |
The API Token you generated in your OANDA account. |
time |
Keep as {{timenow}}. |
exchange |
Keep as {{exchange}}. |
ticker |
Keep as {{ticker}}. |
position_size |
Keep as {{strategy.position_size}}. |
order_action, order_contracts, order_price, order_id |
Keep as {{strategy.order.action}}, {{strategy.order.contracts}}, {{strategy.order.price}}, {{strategy.order.id}}. |
market_position, market_position_size |
Keep as {{strategy.market_position}}, {{strategy.market_position_size}}. |
prev_market_position, prev_market_position_size |
Keep as {{strategy.prev_market_position}}, {{strategy.prev_market_position_size}}. |
6 — Execute & monitor #
-
Start with Demo
Use the Demo webhook URL and a demo OANDA account. Trigger a few alerts and check MyTrades to see how TradeAdapter interprets your signals.
-
Switch to Real when ready
Change the Webhook URL to
https://tradeadapter.com/api/oanda/real_orderand use your real OANDA User ID and API Token in the message. Monitor your OANDA account to confirm orders execute as expected. -
Recreate alerts after changes
If you change strategy parameters or the message, delete and recreate the TradingView alert so the new values are applied.
Important notes #
Webhook — Demo:
.../api/oanda/demo_order; Real: .../api/oanda/real_order. Your TradeAdapter key goes in the message, not in the URL.
OANDA credentials — Keep your API Token private. Use only the User ID and Token from your OANDA account settings.
Recreate alerts after changes — If you change strategy parameters or message fields, delete and recreate the TradingView alert.
All setup guides