Oanda Forex Trading - Tool Instructions
Overview
Trade forex currencies and access real-time market data through the OANDA platform. This tool supports live and practice trading environments, covering market data retrieval, account management, order placement, and position/trade management. Credentials are provided automatically when connected.
Instrument Format
Currency pairs use underscore-separated format: EUR_USD, GBP_JPY, USD_CAD, AUD_NZD, etc.
Actions
get_price
Get current bid/ask pricing for one or more currency pairs.
Required fields (at least one):
instrument (string) - Single currency pair, e.g. EUR_USD
instruments (array of strings) - Multiple currency pairs for batch pricing
Returns bid, ask, spread, timestamp, and whether the instrument is currently tradeable.
Example:
{
"action": "get_price",
"instruments": ["EUR_USD", "GBP_USD", "USD_JPY"]
}
get_candles
Get historical candlestick (OHLCV) data for a single instrument.
Required fields:
instrument (string) - Currency pair, e.g. EUR_USD
granularity (string) - Time interval per candle. Options: S5, S10, S15, S30 (seconds), M1, M2, M4, M5, M10, M15, M30 (minutes), H1, H2, H3, H4, H6, H8, H12 (hours), D (daily), W (weekly), M (monthly)
Optional fields:
count (integer) - Number of candles to retrieve. Default: 100. Range: 1-5000.
Returns open, high, low, close, volume, and timestamp for each candle.
Example:
{
"action": "get_candles",
"instrument": "EUR_USD",
"granularity": "H1",
"count": 50
}
get_account_summary
Get account overview including balance, margin, and profit/loss information.
Required fields: None (credentials are provided automatically).
Returns balance, NAV, unrealized P&L, realized P&L, margin used, margin available, open trade count, open position count, and pending order count.
Example:
{
"action": "get_account_summary"
}
get_positions
Get all currently open positions.
Required fields: None.
Returns a list of open positions with instrument, long/short units, average prices, and unrealized/realized P&L for each side.
Example:
{
"action": "get_positions"
}
get_trades
Get all currently open trades with details.
Required fields: None.
Returns trade ID, instrument, units, entry price, unrealized/realized P&L, margin used, open time, and any attached take-profit or stop-loss order IDs.
Example:
{
"action": "get_trades"
}
get_pending_orders
Get all pending (unfilled) orders.
Required fields: None.
Returns order ID, type, instrument, units, price, time-in-force, and any attached take-profit or stop-loss conditions.
Example:
{
"action": "get_pending_orders"
}
place_market_order
Execute a trade immediately at the current market price.
Required fields:
instrument (string) - Currency pair, e.g. EUR_USD
units (integer) - Number of units. Positive = buy/long, negative = sell/short. Example: 10000 to buy, -5000 to sell.
Optional fields:
take_profit_price (number) - Automatically attach a take-profit order at this price
stop_loss_price (number) - Automatically attach a stop-loss order at this price
stop_loss_distance (number) - Stop loss as a price distance instead of absolute price (cannot use both stop_loss_price and stop_loss_distance)
Example - Buy with risk management:
{
"action": "place_market_order",
"instrument": "EUR_USD",
"units": 10000,
"take_profit_price": 1.0950,
"stop_loss_price": 1.0850
}
Example - Sell (short):
{
"action": "place_market_order",
"instrument": "GBP_USD",
"units": -5000
}
place_limit_order
Place an order to execute when the price reaches a specified level or better. The order remains active until filled or cancelled.
Required fields:
instrument (string) - Currency pair
units (integer) - Positive = buy, negative = sell
price (number) - The limit price at which to execute
Optional fields:
take_profit_price (number) - Take-profit price to attach on fill
stop_loss_price (number) - Stop-loss price to attach on fill
stop_loss_distance (number) - Stop-loss distance to attach on fill
Example:
{
"action": "place_limit_order",
"instrument": "EUR_USD",
"units": 10000,
"price": 1.0800,
"take_profit_price": 1.0900,
"stop_loss_price": 1.0750
}
place_stop_order
Place an order that triggers when the price reaches a specified level. Useful for breakout strategies. The order remains active until triggered or cancelled.
Required fields:
instrument (string) - Currency pair
units (integer) - Positive = buy, negative = sell
price (number) - The trigger price
Optional fields:
take_profit_price (number) - Take-profit price to attach on fill
stop_loss_price (number) - Stop-loss price to attach on fill
stop_loss_distance (number) - Stop-loss distance to attach on fill
Example:
{
"action": "place_stop_order",
"instrument": "USD_JPY",
"units": 5000,
"price": 150.50,
"stop_loss_distance": 0.50
}
modify_order
Modify the price, units, or trailing stop distance of an existing pending order. The tool automatically detects the order type and applies the appropriate modification.
Required fields:
order_id (string) - The order ID to modify (get from get_pending_orders)
Optional fields (at least one required for limit/stop/market-if-touched orders):
price (number) - New price level
units (integer) - New unit amount
For trailing stop loss orders:
trailing_stop_distance (number) - New trailing distance (required)
For stop loss orders:
price (number) - New stop loss price, OR
stop_loss_distance (number) - New stop loss distance
Example:
{
"action": "modify_order",
"order_id": "12345",
"price": 1.0825
}
cancel_order
Cancel a pending order.
Required fields:
order_id (string) - The order ID to cancel (get from get_pending_orders)
Example:
{
"action": "cancel_order",
"order_id": "12345"
}
close_position
Close the entire position (both long and short sides) for a specific instrument.
Required fields:
instrument (string) - Currency pair to close, e.g. EUR_USD
Returns details of closed long/short sides and total profit/loss.
Example:
{
"action": "close_position",
"instrument": "EUR_USD"
}
close_trade
Close a specific individual trade by its ID.
Required fields:
trade_id (string) - The trade ID to close (get from get_trades)
Returns the closing price, units closed, and realized profit/loss.
Example:
{
"action": "close_trade",
"trade_id": "67890"
}
Common Workflows
Check prices then trade:
get_price to see current bid/ask for your target pair
place_market_order to enter at market, or place_limit_order to set a target entry
Monitor and manage positions:
get_account_summary to check overall account health
get_positions to see all open positions
get_trades to see individual trade details and IDs
close_trade or close_position to exit
Manage pending orders:
get_pending_orders to list all unfilled orders
modify_order to adjust price or size
cancel_order to remove an order
Technical analysis:
get_candles with desired granularity and count to pull historical OHLCV data
- Analyze trends, support/resistance, or other patterns
Important Notes
- Units direction: Positive units = buy/long, negative units = sell/short
- Stop loss options: Use either
stop_loss_price (absolute price) or stop_loss_distance (relative distance), never both
- Practice vs Live: The environment is configured through your connected credentials. Practice uses simulated funds; live uses real money.
- Market hours: Forex markets are open 24/5 (Sunday evening to Friday evening UTC). Prices may not be tradeable outside these hours.
- Order persistence: Limit and stop orders use Good-Til-Cancelled (GTC) by default and remain active until filled or manually cancelled.
- Price values: All prices must be positive numbers.