OANDA command reference
This is the full reference for writing OANDA orders from an Autoview alert. Getting started with OANDA gets your account connected; this page goes parameter by parameter and order type by order type, including two behaviors a live verification battery caught that are worth knowing about before you send a real order.
Every command on this page was resolved through the same executeCommand() path Autoview's trading engine actually runs, using a test harness that calls the OANDA integration directly. Fifteen of the resolved commands were also placed on a real OANDA Practice account and confirmed end to end (fills, resting orders, cancellations, and the two defects below), isolated to a single instrument so the results don't depend on any other open position. Nothing on this page is typed from memory or assumed by analogy with another exchange.
OANDA is a forex/CFD broker, not an order-book exchange. There is no maker/taker book to post to, no OCO order type of its own (the one-section bracket below is the OCO-shaped construct here), and leverage is an account-level OANDA setting, not something a command can dial per order. Symbols use OANDA's underscored form: EUR_USD, not EURUSD. TradingView's {{ticker}} placeholder returns the concatenated form and will not match; build the symbol as a literal in your alert instead.
How Autoview reads a command
A command is a single line of key=value tokens separated by spaces. e=OANDA s=EUR_USD b=sell t=market q=1000 is five tokens. The order you write them in does not matter.
- First occurrence wins. If a key appears twice, Autoview keeps the first and ignores the rest.
- A line starting with
//is a comment and places nothing. - You can send several commands at once separated by a new line or a pipe (
|). Each is parsed on its own. - A token that starts with a colon is ignored. TradingView sometimes inserts placeholder tokens like
:plot_0=; Autoview skips anything with a leading colon.
Three tokens matter for every OANDA order: s= (the instrument, underscored), b= (the side), and q= (the size). Leave q= off and Autoview uses 100% of the relevant balance, so set it explicitly on every order.
The parameter table
Routing and identity
| Parameter | Meaning |
|---|---|
e= | The exchange. e=OANDA for a live account, e=OANDAPRACTICE (or e=OANDA-PRACTICE) for a free practice account. Chrome extension only: on the webhook platform the exchange is already fixed to the webhook itself. |
s= | The instrument, underscored (EUR_USD, GBP_USD). Required. |
id= | A reference you choose for the order, stored in OANDA's clientExtensions.id. Also the filter key c=order id= uses to target a specific resting order for cancellation. |
Direction and size
| Parameter | Meaning |
|---|---|
b= | Side: b=buy/b=sell or b=long/b=short. Required, no default. |
q= | Quantity. A plain number is base units of the instrument (q=1000 on EUR_USD is 1,000 units). A percent (q=10%) sizes against available margin, scaled by leverage. Defaults to 100% of the relevant balance when omitted. |
u= | Sizing basis. u=currency treats q= as a notional amount in account currency instead of instrument units, converted at the current rate. Left out, q= is plain units. |
y= | Balance basis for a percent q=. y=equity sizes against the full account balance instead of the default (available margin). On a fresh account the two numbers are close; they diverge once margin is in use. |
l= | Sizing multiplier, for example l=3. This is not an OANDA API leverage field: OANDA leverage is set on the account itself, not per order. l= only multiplies how much balance a percent q= resolves against, the same shape as margin sizing elsewhere on Autoview, but it does not change what OANDA itself does with the order. |
Order type and price
| Parameter | Meaning |
|---|---|
t= | Order type: market or limit (defaults to limit, so market orders set it explicitly). t=fok and t=ioc are parsed but currently rejected by OANDA's own API; see the defects section. |
fp= / p= | Limit price. fp= is absolute; p= is an offset from price=. |
fpx= / px= | Entry-stop trigger price. Adding it to any order sets OANDA's order type to STOP and keeps your original side: a b=sell with fpx= stays a sell that arms at the trigger. |
fpb= / pb= | Price bound: the worst acceptable fill price, OANDA's own slippage cap on a market or stop order. |
dt= | Good-til-date expiry as UNIX time in seconds (UTC), not milliseconds and not a date string: dt=1798761600 is January 1, 2027, 00:00 UTC. Decimals are allowed. Autoview passes the value to OANDA unchanged, so convert a date to seconds first. It sets the order's time in force to GTD on any order type, a market order included, and replaces a t=fok or t=ioc choice. How dt= works on each exchange. |
price= | A reference price the relative parameters (p=, px=, pb=) offset from. Use price={{close}} in a TradingView alert. |
Position and risk flags
| Parameter | Meaning |
|---|---|
ro= | Reduce-only. ro=1 sets positionFill to REDUCE_ONLY, so the order can only shrink a position. |
close= | close=1 sets positionFill to REDUCE_FIRST instead of the default, a softer variant of reduce-only. ro= takes priority if both are set. |
c= | Cancel or close. c=order cancels resting orders. c=position closes the entire open position on the instrument. OANDA has no c=all; see the defects section. |
cm= / cmo= | On c=order, narrow which resting orders are cancelled: cm= is how many (a count or percent), cmo= is which ones (newest, oldest, and so on). On c=position these do not select a single trade in practice; see the defects section. |
ef= | Enter when flat. With ef=1, Autoview reads your open positions on the symbol before it sends an entry. If one is open, long or short, the entry is skipped and nothing is sent. It never holds back a close or a cancel, or an order with ro=1 or close=1. If Autoview cannot read your positions, the entry is refused with an error instead of going out unchecked. The command reference covers the side words and ef=any. Example: e=OANDA s=EUR_USD b=buy t=market q=1000 ef=1. |
d= | Dry run. d=1 resolves and reports the order without sending it. OANDA still requires valid credentials for a dry run, since it looks up your account and the instrument's live price first. |
Order types and what each resolves to
| Command | OANDA resolves |
|---|---|
e=OANDA s=EUR_USD b=sell t=market q=1000 | Market sell, 1,000 units. |
e=OANDA s=EUR_USD b=sell t=limit fp=1.5 q=1000 | Limit sell at 1.5. |
e=OANDA s=EUR_USD b=sell t=market fpx=0.9 q=1000 | A STOP order that arms at 0.9. The side stays sell, because this is an entry stop: adding fpx= to either t=market or t=limit resolves to the same STOP type either way. |
e=OANDA s=EUR_USD b=sell t=market fpb=1 q=1000 | Market sell with a price bound of 1. OANDA will not fill worse than that. |
Two things worth knowing: a stop is not its own t= value, it is fpx= added to a market or limit order, the same shape Kraken and Crypto.com use. And t=fok/t=ioc are covered separately below, because OANDA's API currently rejects both.
Stops, targets and the & separator
sl=, tp=, ts=, and gsl= attach to an OANDA order when it fills, whether you write them on a plain command or inside an & section. A plain command places one order with the protection attached. Each & section places its own order, built from that section plus the text before the first &, with that section's stop and target.
An earlier version of this page said these parameters were silently ignored without &. That was true until a connector fix in September 2026. It is no longer the case.
| Command | OANDA resolves |
|---|---|
e=OANDA s=EUR_USD b=buy t=market q=1000 & fsl=1.07 ftp=1.10 | One market buy, filled with stopLossOnFill at 1.07 and takeProfitOnFill at 1.10 attached: the correct one-order bracket. |
e=OANDA s=EUR_USD b=buy t=market q=1000 & ts=0.01 | One market buy with a trailing-stop distance attached. |
e=OANDA s=EUR_USD b=buy t=market q=1000 fsl=1.07 ftp=1.10 | The same order as the first row: one market buy with stopLossOnFill at 1.07 and takeProfitOnFill at 1.10 attached. No & is needed for a single bracket. |
Two separate & sections is a common mistake, not a bracket. & fsl=1.07 & ftp=1.10 (two sections) resolves to two full-size orders, one carrying only the stop and one carrying only the target. This is confirmed against the live connector: it doubles your position size, and does not build a bracket. The correct form keeps fsl= and ftp= in the same & section: & fsl=1.07 ftp=1.10.
fsl=/ftp=/fts=/fgsl= are the absolute-price forms of sl=/tp=/ts=/gsl=, same f-prefix convention as the entry parameters. fgsl=/gsl= request a Guaranteed Stop Loss; read the defects section before relying on it.
Absolute and relative prices
Every price parameter comes in two forms:
- With the
fprefix, the number is absolute.fp=1.5means the price 1.5. - Without the
f, the number is an offset from a reference supplied withprice=.p=-0.005means 0.005 below the reference.
e=OANDA s=EUR_USD b=sell t=limit price={{close}} p=-0.005 q=1000price={{close}} passes the candle close from a TradingView alert, and p=-0.005 rests the limit below it. The same swap applies to px=/fpx= and sl=/fsl= and their siblings.
Sizing: units, percent, and currency
- A plain number is base units.
q=1000is 1,000 units of the instrument, passed straight through. - A percent sizes against available margin, scaled by
l=if present.q=10%resolved to roughly a tenth of the available margin on a live-verified test. u=currencytreatsq=as a notional amount in your account's currency rather than instrument units, and converts it at the live rate.y=equityswitches the percent basis from available margin to full account balance.
Leave q= off and Autoview uses 100% of the relevant balance. Set the size you mean, explicitly, on every order.
Cancelling and closing
| Command | Effect |
|---|---|
e=OANDA s=EUR_USD c=order | Cancel your resting orders on the instrument (up to 500 read per call). |
e=OANDA s=EUR_USD c=order cm=2 cmo=newest | Cancel the two newest resting orders and leave the rest working. |
e=OANDA s=EUR_USD c=position | Close the entire open position on the instrument: every trade making it up, in one call. |
e=OANDA s=EUR_USD c=position q=50% | Close half of the open position. The share is taken from the whole position, not from one trade. |
e=OANDA s=EUR_USD c=position & fsl=1.0650 | Close nothing. Set the stop on each open trade on the instrument to 1.0650, or move it there if one is already resting. |
c=position works on the whole position, not on single trades. cm=/cmo= narrow c=order correctly, but on c=position the connector's per-trade selection path is gated on a flag that Autoview sets to a default value on every command, so that path is effectively unreachable. This is confirmed live: one c=position call flattened a two-trade position in a single call, regardless of cm=. To close part of the position, use q= (a percent or a unit count). To manage individual trades on an instrument you're scaling into, track and close them outside a plain c=position call.
An & turns c=position into a stop update, not a close. When the line carries an &, Autoview goes through each open trade on the instrument and sets, moves or removes its stop-loss, take-profit, trailing stop and guaranteed stop from the fields in each section. It sends no closing order, and a section with none of those fields does nothing. A value of 0 (for example sl=0) removes that order. Relative sl=, tp= and gsl= offsets are measured from the current market price, not from where the trade opened. Keep & off any alert that is meant to close. This comes from a read of the connector code, not a live run.
What OANDA does not accept, and two live-caught defects
- No
c=all. Autoview has no combined liquidate-everything command for OANDA. Sending it stops the command with the errorexchangeLiquidateAll is not supported.and nothing is cancelled or closed.b=flatmaps toc=allinternally and hits the same error. Cancel orders and close positions as two separate commands. - No order editing.
edit=is not read on OANDA. Cancel and re-send instead of amending a resting order in place. - No wallet transfers.
w=throws: OANDA is a broker account, not a multi-wallet exchange. - No trigger-price-source selector. There is no parameter to choose index vs. mark vs. last price for a trigger; OANDA's own default applies.
- One account per command. A comma-separated
a=list is refused, same as every Autoview integration.
Defect: t=fok and t=ioc are currently rejected by OANDA outright. Autoview parses both but the request it builds never sets a required order-type field, so OANDA's v20 API hard-rejects with "Missing 'order.type' parameter." This is confirmed live. No order is placed and no money moves, but do not rely on either until this is fixed. A connector fix exists to name this; it has not been built, per the standing rule that a behavior change to shared engine code needs the production owner's decision first, not just a verified bug report.
Defect: a Guaranteed Stop Loss can silently fail to attach. On an instrument where your account does not have GSL enabled, OANDA creates the guaranteed-stop order and then immediately cancels it, and Autoview's current response handling does not surface that cancellation. This is confirmed live: you see an ordinary success response, but no protective order actually exists. Confirm GSL is enabled for the specific instrument in OANDA's own account settings before depending on gsl=/fgsl=, and verify the resting order afterward rather than trusting the response alone.
Testing and going live
Append d=1 to any command and Autoview resolves it and reports what it would have done without sending it:
e=OANDA s=EUR_USD b=sell t=market q=1000 d=1A dry run still needs valid credentials: OANDA looks up your account and the instrument's live price before the halt, so d=1 proves more than a syntax check. Read the log, confirm the instrument, side, and size, then remove d=1 to send it for real. OANDA Practice is the free, zero-risk way to run through all of the above before you touch a live account. For more on reading the log, see test and debug your setup.
See a test run on video. Our OANDA Practice video connects a Practice account to Autoview, writes a market buy on EUR_USD, dry-runs it with d=1, and checks the result in webhook history. It runs about eight minutes: watch the OANDA Practice walkthrough on YouTube.