OANDA command reference

Autoview · Reference · Updated September 2, 2026

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 command-builder organism 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

ParameterMeaning
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

ParameterMeaning
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

ParameterMeaning
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, a UNIX timestamp. Sets the order's time in force to GTD with that expiry.
price=A reference price the relative parameters (p=, px=, pb=) offset from. Use price={{close}} in a TradingView alert.

Position and risk flags

ParameterMeaning
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.
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

CommandOANDA resolves
e=OANDA s=EUR_USD b=sell t=market q=1000Market sell, 1,000 units.
e=OANDA s=EUR_USD b=sell t=limit fp=1.5 q=1000Limit sell at 1.5.
e=OANDA s=EUR_USD b=sell t=market fpx=0.9 q=1000A 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=1000Market 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.

The & advanced-syntax bracket rule

Attaching a stop-loss, take-profit, or trailing stop to an OANDA order requires the & advanced-syntax separator. Sent without it, sl=, tp=, ts=, and gsl= are silently ignored. This is confirmed against the live connector, not assumed: the order fills as a fully naked position, with a normal success response and no warning that the protection never attached.

CommandOANDA resolves
e=OANDA s=EUR_USD b=buy t=market q=1000 & sl=1.2 tp=1.4One market buy, filled with stopLossOnFill at 1.2 and takeProfitOnFill at 1.4 attached: the correct one-order bracket.
e=OANDA s=EUR_USD b=buy t=market q=1000 & ts=0.01One market buy with a trailing-stop distance attached.
e=OANDA s=EUR_USD b=buy t=market q=1000 sl=1.2 tp=1.4No stop, no target. The & is missing, so sl=/tp= are never read. This resolves to a plain, unprotected market buy.

Two separate & sections is a common mistake, not a bracket. & sl=1.2 & tp=1.4 (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 sl= and tp= in the same & section: & sl=1.2 tp=1.4.

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 f prefix, the number is absolute. fp=1.5 means the price 1.5.
  • Without the f, the number is an offset from a reference supplied with price=. p=-0.005 means 0.005 below the reference.
e=OANDA s=EUR_USD b=sell t=limit price={{close}} p=-0.005 q=1000

price={{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=1000 is 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=currency treats q= as a notional amount in your account's currency rather than instrument units, and converts it at the live rate.
  • y=equity switches 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

CommandEffect
e=OANDA s=EUR_USD c=orderCancel your resting orders on the instrument (up to 500 read per call).
e=OANDA s=EUR_USD c=order cm=2 cmo=newestCancel the two newest resting orders and leave the rest working.
e=OANDA s=EUR_USD c=positionClose the entire open position on the instrument: every trade making it up, in one call.

c=position always closes the whole aggregate, not a portion. 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=. If you need to manage individual trades on an instrument you're scaling into, track and close them outside a plain c=position call.

What OANDA does not accept, and two live-caught defects

  • No c=all. OANDA never implemented a combined liquidate-everything command; it throws an explicit "has not been implemented" error instead of silently doing nothing. b=flat maps to c=all internally 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=1

A 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.

Back to getting started with OANDA