Risk 1% per trade on OANDA: size the order from your stop
A percent in q= sets how much of your balance goes into the trade. It does not set how much you lose when the stop is hit. To size by risk, you work back from the stop: pick the loss you accept, divide it by the stop distance, and that is your size. On OANDA you can do this inside the alert with a formula in q=.
Every example on this page was put through Autoview's real OANDA code with d=1 and test prices. Parser checked, not run live.
The line
A long EUR/USD entry that risks 1% of the balance with a 100-pip stop:
e=oanda s=EUR_USD b=long t=market q=[equity*{{close}}*0.01/0.0100] sl=-0.0100q=[] holds a formula. Autoview works it out when the order is built. Keep it on one line.equityis your OANDA balance, converted for this pair (more on that below).{{close}}is TradingView's placeholder for the bar close. TradingView swaps in the number before the alert leaves, so Autoview sees something like1.0851. If you send alerts from another tool, put the price there yourself.0.01is the risk: 1%. Use0.005for half a percent or0.02for 2%.0.0100is the stop distance in price. It must matchsl=.sl=-0.0100puts the stop 0.0100 below the price Autoview reads for the order. On EUR/USD that is 100 pips.
What equity means here
On OANDA, equity inside the brackets is not a dollar amount. Autoview takes the balance figure from your OANDA account and converts it into units of the pair's first currency at the live price. On a USD account with 10,000 USD and EUR/USD at 1.0852, equity is about 9,215, the number of euros the balance would buy.
That is why the formula multiplies by {{close}}. It turns the figure back into the pair's second currency, and from there the division by the stop distance gives units that lose 1% of the balance at the stop. Because the conversion goes through the pair's own price, you do not need a separate exchange rate. The same shape works for every pair and every account currency OANDA can price.
Two details follow from where the number comes from:
- It is OANDA's
balance, not NAV, so profit or loss on trades that are still open is not counted. l=multiplies it. Withl=2on this line the order doubles and so does the risk. Leavel=off a risk-sized line.
The stop number for each kind of pair
The formula holds for every pair. What changes is the stop number, because a pip is not the same size everywhere. On most pairs a pip is 0.0001, so 100 pips is 0.0100. On JPY pairs a pip is 0.01, so 100 pips is 1.00.
| Pair | 1% risk, 100-pip stop, long |
|---|---|
| EUR/USD | e=oanda s=EUR_USD b=long t=market q=[equity*{{close}}*0.01/0.0100] sl=-0.0100 |
| USD/CAD | e=oanda s=USD_CAD b=long t=market q=[equity*{{close}}*0.01/0.0100] sl=-0.0100 |
| USD/JPY | e=oanda s=USD_JPY b=long t=market q=[equity*{{close}}*0.01/1.00] sl=-1.00 |
| EUR/JPY | e=oanda s=EUR_JPY b=long t=market q=[equity*{{close}}*0.01/1.00] sl=-1.00 |
Do not copy the EUR/USD line onto a JPY pair. With 0.0100 on USD/JPY, the stop sits 1 pip from the price and the size comes out 100 times larger. The loss at the stop is still about 1%, but a 1-pip stop is inside the spread, and on a 10,000 USD account at 152.41 the order is 1,524,100 units.
Short entries
sl= is added to the price, so the sign sets the side of the stop. A long needs a negative number, which puts the stop below. A short needs a positive one, which puts it above:
e=oanda s=EUR_USD b=short t=market q=[equity*{{close}}*0.01/0.0100] sl=0.0100Autoview does not flip the sign for you. A short with sl=-0.0100 gets a stop price 100 pips below the price, which is not a stop loss for a short. Keep the divisor in q= positive either way.
Worked numbers
These come from running each line through Autoview's OANDA code with d=1, on two made-up accounts and two sets of made-up prices. The bar close was set to the mid price. "Loss at stop" is the size times the distance from the entry price to the stop, in the account currency.
| Account and pair | Prices (bid / ask) | Units | Stop price | Loss at stop |
|---|---|---|---|---|
| 10,000 USD, EUR/USD long | 1.08500 / 1.08520 | 9,999 | 1.0752 | 99.99 USD (1.00%) |
| 25,000 USD, EUR/USD long | 1.16000 / 1.16020 | 24,998 | 1.1502 | 249.98 USD (1.00%) |
| 10,000 USD, USD/CAD long | 1.38000 / 1.38020 | 13,801 | 1.3702 | 100.00 USD (1.00%) |
| 25,000 USD, USD/CAD long | 1.32000 / 1.32020 | 33,003 | 1.3102 | 250.00 USD (1.00%) |
| 10,000 USD, USD/JPY long | 152.400 / 152.420 | 15,241 | 151.42 | 100.00 USD (1.00%) |
| 25,000 USD, USD/JPY long | 140.000 / 140.020 | 35,003 | 139.02 | 250.00 USD (1.00%) |
| 10,000 USD, EUR/JPY long | 165.350 / 165.380 | 15,238 | 164.38 | 99.98 USD (1.00%) |
| 25,000 USD, EUR/JPY long | 162.420 / 162.450 | 35,002 | 161.45 | 250.00 USD (1.00%) |
| 10,000 USD, EUR/USD short | 1.08500 / 1.08520 | -10,001 | 1.095 | 100.01 USD (1.00%) |
| 10,000 EUR, USD/JPY long | 152.400 / 152.420 | 16,540 | 151.42 | 100.02 EUR (1.00%) |
Why it lands near 1%, not on it
- The close and the live price differ.
{{close}}is the bar close on your chart. Autoview converts the balance at the live bid or ask when the order is built, so the two do not cancel exactly. - The stop is measured from the quote, not the fill. On a market buy,
sl=is counted from the ask Autoview reads; on a market sell, from the bid. Your fill can differ from that quote. - The size is rounded. Autoview rounds
q=to the number of decimals OANDA allows for the pair's units. - Stops can slip. A stop that triggers in a fast market can fill past its price.
Autoview does not check the size against OANDA's minimum or your margin before sending. OANDA decides whether to accept the order.
Order type
Leave t= off and Autoview sends a limit order at the bid for a buy, and counts sl= from that bid. The examples here use t=market so the order fills now and the stop sits 100 pips from the ask. The OANDA command reference covers the other order types and the & form for stops.
Test it first
Add d=1 to the line. Autoview reads your balance and the live price, builds the order and writes it to your log, then stops. Check the units and the stop price against your own sum before you take d=1 off. A dry run on OANDA needs valid credentials, because the balance and the price come from your account. An OANDA Practice account lets you try it with no real money.
e=oanda s=EUR_USD b=long t=market q=[equity*{{close}}*0.01/0.0100] sl=-0.0100 d=1
If the alert reaches Autoview with {{close}} still in it, as text, the formula cannot be read and no order is sent. That happens when the alert comes from a tool that does not fill in TradingView placeholders.
FAQ
How do I risk 1% of my OANDA balance per trade with Autoview?
Put a formula in q=: q=[equity*{{close}}*0.01/0.0100] with sl=-0.0100 on a long EUR/USD order. Autoview turns equity into units of the pair at the live price, so the order size loses about 1% of the balance if the 100-pip stop is hit.
Does the same formula work on USD/JPY or EUR/JPY?
Yes, with a different stop number. A pip on a JPY pair is 0.01, so 100 pips is 1.00: use q=[equity*{{close}}*0.01/1.00] with sl=-1.00. With 0.0100 the stop is 1 pip away and the order is 100 times larger.
Do I need to convert to my account currency?
No. On OANDA, equity inside the formula is already converted at the live price, and multiplying by {{close}} gives the right size for any pair and any account currency.
Why is the loss at the stop not exactly 1%?
{{close}} is the bar close, while Autoview converts at the live bid or ask. The size is rounded to the units OANDA allows, and the fill and the stop can slip. Expect the loss to land close to 1%, not on it.
A note on what Autoview is. Autoview is an execution tool, not a trading or investment advisor. It places the orders your own alerts tell it to. It does not generate signals, recommend trades, or make any claim about results. Trading carries risk of loss. See our disclosures.