Strategies we backtested OBV trend strategy

Tested by BacktestingMax

OBV trend strategy backtest

Does the OBV trend strategy make money?

Only on some markets, and the strategy lost money on most 1-hour charts. On-Balance Volume (OBV) is an indicator that adds a candle's volume when the candle closes higher than the candle before, and subtracts it when the candle closes lower. The OBV trend strategy buys when OBV crosses above its 20 EMA (a 20-candle moving average) while price is above its own 20 EMA. It sells short when OBV crosses below its EMA while price is below its EMA, and it closes a trade when OBV crosses back. We ran 30 backtests of these standard rules from 2020 to 2025, after trading costs: 10 markets, each on 1-hour, 4-hour and daily charts. 17 of the 30 tests made money. 10 of them made money in both 2020–2023 and 2024–2025, and 4 passed all four of our checks. USD/JPY and the DAX made money on all 3 charts, and EUR/USD and the S&P 500 lost money on all 3. On 1-hour charts, the average trade made 1.7% of the money it risked before trading costs, but paid 2.8% in costs. Volume helped: without it, the 1-hour trades made less than half as much before costs. Our volume comes from our price data, not from the whole market (see 'Volume' below).

30 backtests 2020–2025 Trading costs included Tested 9 November 2026

Where it worked 30 backtests
Made money
17
of 30 tests, with the standard rules
Made money in both periods
10
2020–2023 and again 2024–2025
Best backtest
+169%
DAX, 1-hour chart: account growth 2020–2025
Exit when price crosses its 20 EMA
7
tests made money in both periods, compared with 10 with the standard rules

Made money in both periods

  • GBP/USD, daily
  • USD/JPY, 1-hour
  • USD/JPY, 4-hour
  • USD/JPY, daily
  • Gold, 4-hour
  • Silver, 4-hour
  • Nasdaq 100, daily
  • DAX, 1-hour
  • DAX, 4-hour
  • DAX, daily

The results

Results on every market

Each box shows one backtest of the OBV trend strategy with the standard rules, from 2020 to 2025, after trading costs: the % result, and a small chart of the account balance. The solid line is the account balance and the dashed line is the starting balance. Green results made money; red results lost money. Under each result: whether it made money in both 2020–2023 and 2024–2025, or passed all four of our checks (see "How a test passes" further down).

Market 1-hour 4-hour daily
EUR/USD −78% Lost money −21% Lost money −2% Lost money
GBP/USD −65% Lost money −27% Lost money +2% Made money in both periods
USD/JPY +136% Made money in both periods +36% Made money in both periods +6% Passed all four checks
Gold +0.6% Made money overall, lost in one period +31% Passed all four checks +12% Made money overall, lost in one period
Silver −82% Lost money +9% Made money in both periods +3% Made money overall, lost in one period
S&P 500 −13% Lost money −32% Lost money −9% Lost money
Nasdaq 100 −17% Lost money +5% Made money overall, lost in one period +5% Passed all four checks
Dow Jones +0.7% Made money overall, lost in one period −3% Lost money +4% Too few trades
DAX +169% Made money in both periods +25% Made money in both periods +11% Passed all four checks
FTSE 100 −78% Lost money +1% Made money overall, lost in one period +2% Made money overall, lost in one period
All the numbers, test by test
Market Chart Trades Win rate Profit factor Result Max drawdown 2020–2023 2024–2025 Monte Carlo drawdown Trading costs
EUR/USD 1-hour 2,922 25.6% 0.83 −77.5% −84.4% −71.4% −21.3% −83.7% $4,650
EUR/USD 4-hour 792 27.7% 0.90 −21.4% −31.5% −8.8% −13.9% −39.6% $1,052
EUR/USD daily 147 30.6% 0.94 −1.9% −8.0% −0.5% −1.4% −11.2% $70
GBP/USD 1-hour 2,909 26.5% 0.89 −65.0% −71.1% −35.2% −45.9% −77.8% $6,590
GBP/USD 4-hour 767 27.8% 0.85 −26.7% −32.3% −14.8% −13.9% −39.5% $1,030
GBP/USD daily 135 36.3% 1.09 +2.4% −3.5% +0.9% +1.5% −8.9% $74
USD/JPY 1-hour 2,799 26.2% 1.12 +136.1% −32.9% +41.7% +66.6% −45.2% $10,832
USD/JPY 4-hour 734 28.7% 1.15 +36.2% −16.0% +19.9% +13.6% −25.0% $1,119
USD/JPY daily 123 31.7% 1.22 +6.0% −8.1% +3.1% +2.8% −9.9% $58
Gold 1-hour 2,797 25.4% 1.00 +0.6% −48.4% −32.1% +48.1% −55.6% $6,804
Gold 4-hour 708 28.7% 1.18 +30.9% −19.1% +7.3% +22.0% −24.2% $898
Gold daily 124 29% 1.65 +11.7% −3.2% −1.0% +12.7% −6.1% $51
Silver 1-hour 2,394 24.1% 0.79 −81.7% −85.3% −73.7% −30.4% −86.1% $9,594
Silver 4-hour 711 27.4% 1.05 +8.9% −20.4% +4.9% +3.8% −28.0% $2,406
Silver daily 139 28.8% 1.11 +3.1% −8.1% +6.5% −3.2% −10.4% $171
S&P 500 1-hour 2,474 29.2% 0.98 −12.5% −32.0% −6.8% −6.2% −59.0% $4,303
S&P 500 4-hour 661 31.2% 0.83 −31.5% −37.8% −24.6% −9.2% −45.2% $501
S&P 500 daily 128 32.8% 0.74 −9.3% −9.4% −8.7% −0.7% −16.5% $36
Nasdaq 100 1-hour 2,871 26.1% 0.97 −17.1% −38.1% −16.4% −0.9% −59.6% $3,677
Nasdaq 100 4-hour 700 29.3% 1.02 +5.1% −15.8% +13.6% −7.4% −31.1% $496
Nasdaq 100 daily 106 34.9% 1.29 +4.9% −2.2% +3.2% +1.6% −5.6% $21
Dow Jones 1-hour 2,369 27.8% 1.00 +0.7% −24.8% −1.0% +1.7% −53.2% $2,692
Dow Jones 4-hour 622 31.5% 0.99 −2.6% −31.6% +4.8% −7.0% −32.8% $355
Dow Jones daily 66 36.4% 1.29 +3.6% −5.5% −4.2% +8.1% −6.5% $13
DAX 1-hour 2,318 28.6% 1.18 +168.9% −37.7% +49.3% +80.2% −36.7% $3,641
DAX 4-hour 604 33.9% 1.13 +24.8% −17.9% +22.4% +2.0% −23.7% $366
DAX daily 114 37.7% 1.55 +11.3% −3.4% +6.6% +4.3% −7.2% $20
FTSE 100 1-hour 2,302 25.9% 0.84 −77.9% −84.4% −54.9% −51.1% −83.6% $4,142
FTSE 100 4-hour 701 31.2% 1.01 +1.3% −22.5% −4.2% +5.7% −30.1% $888
FTSE 100 daily 128 33.6% 1.08 +1.9% −7.7% +2.3% −0.3% −10.1% $62

Profit factor is the money won divided by the money lost. Above 1 means the test made money. Max drawdown is the biggest fall from the highest balance. 2020–2023 and 2024–2025 show the result in each period on its own. Monte Carlo drawdown: we shuffled the trades into a random order 1,000 times; in 95% of those runs, the worst drawdown was this number or less. Result is the change in the account, with the risk of each trade set to 1% of the account at that time.

The account balance

The best test and the middle test

Best test DAX, 1-hour chart +168.9% from 2020 to 2025
Middle test (median): half of the 30 did better, half did worse FTSE 100, daily chart +1.9% from 2020 to 2025

What we found

What the 30 backtests show

  1. With the standard rules, 10 of the 30 tests made money in both 2020–2023 and 2024–2025, after trading costs. USD/JPY and the DAX did it on all 3 charts. On 1-hour charts, the USD/JPY account grew 136.1% in the backtest, and the DAX account grew 168.9% (see 'DAX and FTSE 100 data'). But at their lowest point, the USD/JPY account was 32.9% below its highest balance, and the DAX account was 37.7% below. So neither passed all four of our checks (see 'How a test passes'). When we shuffled their trades into a random order 1,000 times, the account fell more than 30% in more than 1 shuffle in 20. Only 4 tests passed, all on 4-hour or daily charts: USD/JPY, the Nasdaq 100 and the DAX on daily charts, and gold on 4-hour charts. EUR/USD and the S&P 500 lost money on all 3 charts. On 1-hour charts, EUR/USD, GBP/USD, silver and the FTSE 100 lost 65.0% to 81.7% of the account.

  2. Does the volume matter? Yes, most on 1-hour charts. To check, we ran all 30 tests a second time without volume: OBV added 1 for every candle that closed up and subtracted 1 for every candle that closed down. With volume, 21 of the 30 tests did better after costs: 8 of 10 on 1-hour charts, 6 of 10 on 4-hour charts and 7 of 10 on daily charts. On this page, R is the amount a trade risks: 1% of the account when the trade opens. A trade that hits its stop-loss loses about 1R, and a total such as +434.9R adds up the R of many trades. On 1-hour charts, the trades made +434.9R before costs with volume, and +183.5R without it. On daily charts, the totals were about the same: +40.8R with volume and +44.0R without. Without volume, OBV crossed its EMA more often on every 1-hour and 4-hour chart. So the 30 tests made 41,424 trades instead of 34,365, and paid trading costs more often (see 'Volume or no volume' below).

  3. OBV often crossed back through its EMA within a few candles. In our tests, after 40% to 57% of its crosses, OBV crossed back within 2 candles. At a cross, OBV and its EMA are very close, so one candle that closes in the other direction can push OBV back across. When OBV crosses back, the strategy closes the trade. With the standard rules on 1-hour charts, half of the trades lasted 3 hours or less, and only 11.0% reached the stop-loss. Of these 1-hour trades, 63.5% ended between −0.5R and +0.5R. Before trading costs, the average 1-hour trade made +0.017R, but costs took 0.028R from it, so it lost 0.011R.

  4. Waiting for a new OBV high made fewer and longer trades, and on 1-hour charts they made money after costs. This new-high entry was one of the three changes we tested (see 'Can the OBV trend strategy be improved?' below). It buys when OBV, at a candle's close, is above its highest value of the 20 candles before, while price is above its 20 EMA. Short trades need a new 20-candle low in OBV while price is below its 20 EMA. On 1-hour charts, the median trade lasted 9 hours, against 3 hours with the standard rules (half of the trades were shorter than the median, and half longer). Added up over the 10 markets, the 1-hour trades made +124.6R after costs, against −295.6R with the standard rules. On USD/JPY 1-hour charts, the account grew 522.3% in the backtest, the biggest gain on this page, with a profit in 5 of the 6 years. That test still did not pass all four of our checks. And all of this entry's profit came from 2020: from 2021 to 2025, its 30 tests lost 126.6R together. The standard rules lost even more in those years, 357.8R, and all four versions did best in 2020 and worst in 2021.

Volume or no volume

Volume helped most on 1-hour charts, and made little difference on daily charts

We ran all 30 tests twice. The first time, OBV used each candle's volume, as in the standard rules. The second time, OBV used no volume: every candle that closed up added 1, and every candle that closed down subtracted 1. Everything else stayed the same. Each R figure adds up the trades of the 10 markets on that chart, from 2020 to 2025.

Chart With volume: trades With volume: R before costs With volume: R after costs Without volume: trades Without volume: R before costs Without volume: R after costs
1-hour 26,155 +434.9R −295.6R 32,058 +183.5R −687.7R
4-hour 7,000 +121.1R +29.0R 8,089 +108.6R +1.8R
Daily 1,210 +40.8R +35.2R 1,277 +44.0R +38.3R
All 3 charts 34,365 +596.8R −231.4R 41,424 +336.1R −647.6R

We added up the R of all the trades on each chart. 'Before costs' is the result the trades would have had without trading costs. An R total is not a % result: each row adds up 10 separate accounts. Before costs, OBV with volume did better in 18 of the 30 tests. On forex, OBV with volume did better after costs in 8 of the 9 tests. On the S&P 500, OBV without volume did better on all 3 charts.

The three changes

On 1-hour charts, only the new-high entry made money after costs

The table shows all trades on the 10 markets on 1-hour charts from 2020 to 2025, with the standard rules and with each of the three changes. The changes are explained under 'Can the OBV trend strategy be improved?' below.

Version Trades Median trade length Trades closed at the stop-loss Trades that made money R before costs R after costs
Standard rules 26,155 3 hours 11.0% 26.5% +434.9R −295.6R
Exit when price crosses its 20 EMA 18,596 6 hours 13.2% 26.4% +227.9R −296.4R
Enter on a new OBV high or low 17,915 9 hours 23.5% 33.1% +619.1R +124.6R
50 EMA on OBV instead of 20 16,646 about 3 hours 15.1% 25.3% +430.4R −36.7R

R figures are added up the same way as in the table above. On 4-hour charts, the new-high entry also did best after costs: +47.1R, against +29.0R with the standard rules. On daily charts, each change made fewer than 100 trades on 9 or 10 of the 10 markets, too few to judge.

The strategy

What the OBV trend strategy is

On-Balance Volume (OBV) is an indicator that Joe Granville described in 1963. OBV is a total that changes with every candle: a candle's volume is added when the candle closes higher than the candle before, and subtracted when it closes lower. Granville believed that volume moves before price, so a rising OBV would show buyers getting stronger before price rises. OBV starts at 0 on the first candle of a chart, so its number depends on where the chart starts. Traders look at its direction instead, often with an EMA of OBV (EMA stands for exponential moving average). A common way to trade OBV is the way we tested. Buy when OBV crosses above its 20 EMA while price is above its own 20 EMA. Sell short when OBV crosses below its 20 EMA while price is below its own 20 EMA. OBV is above its 20 EMA when, over roughly the last 20 candles, the candles that closed up had more volume than the candles that closed down. The newest candles count most. So the cross does not depend on where the chart starts. The 20 EMA of price is a trend filter: the strategy buys only when price is above it, and sells short only when price is below it.

OBV
The strategy calculates OBV as Joe Granville described it, from the volume of each candle. The volume of a 1-hour, 4-hour or daily candle is the total volume of its 1-minute candles.
EMAs
The strategy uses a 20-candle EMA of OBV and a 20-candle EMA of the closing price. Each new EMA value is the last EMA value plus 2 ÷ 21 (about 9.5%) of the gap between the newest value and the last EMA value. Both EMAs start at the first candle of each test, and no trade opens in the first 20 candles.
Volume
OBV uses the volume that comes with our price data, for each 1-minute candle. This volume comes from one price source, not from an exchange: forex has no central exchange, and our prices are CFD prices (see 'Price data'). So it is not the amount traded on the whole market. On most trading platforms, the volume on forex and CFD charts also comes from one source, and it is often called tick volume.
Volume checks
Before the test, we checked the volume on all 10 markets from 2020 to 2025. On every market, it was highest in the hours after the US stock market opened. On forex, gold and the European indices, it was also high after the European markets opened. Hours with bigger price moves had more volume. On every market, 0.23% or fewer of the 1-hour candles had no volume. The amount of volume changed between years: a typical Nasdaq 100 day had about a sixth as much volume in 2024 as in 2023. This matters little for the strategy, because OBV's cross with its EMA depends mostly on the last few dozen candles.
Stop-loss
The stop-loss is 2 × ATR(14) away from the close of the candle that gave the signal. ATR (average true range) is an indicator of how far price moves in an average candle, here over the last 14 candles. The stop-loss does not move.
Exit
The strategy closes a trade when OBV crosses back through its EMA, at the next candle's open.
Take-profit
None
Risk per trade
1% of the account, which started at $10,000. The trade size is set at the close of the signal candle, but the trade opens at the next candle's open. So a trade that hit its stop-loss usually lost close to 1%, but not exactly 1%. When price jumped past the stop-loss, for example over a weekend, the loss was bigger. With the standard rules, 10 trades lost more than 1.5% of the account, and 5 of them were open over a weekend. The biggest loss, 2.84%, was a short trade on the Nasdaq 100 1-hour chart on 21 February 2024: price jumped above the stop-loss after the US stock market had closed.
Trading costs
Every trade pays the spread: the gap between the buy price and the sell price. These rules use only market orders (orders that fill at the current price) and stop-losses, so a trade pays half the spread when it opens and half when it closes. There is no commission. The spread is 0.8 pips on EUR/USD, 1.2 on GBP/USD and 0.9 on USD/JPY (a pip is 0.0001 on EUR/USD and GBP/USD, and 0.01 on USD/JPY). It is $0.30 an ounce on gold and $0.020 an ounce on silver. On the indices, it is 0.4 points on the S&P 500, 1.5 on the Nasdaq 100, 2.0 on the Dow, and 1.0 on the DAX and the FTSE 100. For silver, the Nasdaq 100, the Dow, the DAX and the FTSE 100, these are wider than our backtest engine's own spreads, to match a typical retail broker. With the standard rules, trading costs took 2.8% of the money a trade risked on 1-hour charts, on average. They took 1.3% on 4-hour charts, 0.5% on daily charts, and 7.3% on silver 1-hour charts.
Smallest trade size
Some signals were skipped. For these signals, a trade that risks 1% would have been smaller than the smallest trade size the market allows. The smallest sizes are 1,000 units of a currency pair, 1 ounce of gold, 50 ounces of silver and 0.1 of an index contract. With the standard rules, 422 signals were skipped, 1.2% of all signals. On the Dow daily chart, 70 of its 136 signals were skipped. So that test made only 66 trades, too few to judge, and we do not count it as a test that made money. On silver 1-hour charts, 280 signals were skipped, all in 2024 and 2025, after the silver account had fallen below half of its starting balance. On gold daily charts, 20 were skipped, 19 of them in 2025, when gold's daily moves had grown. No trade needed a bigger size than our backtest engine allows.
Price data
CFD prices: the prices a broker quotes for a CFD (contract for difference), the product most brokers outside the US offer for trading these markets. Our backtest leaves out two kinds of candle: tiny candles after the Friday close, and candles with no price change. These candles do not count for OBV, the EMAs or the ATR. The tiny candles come from a few minutes of prices after the weekly close at 17:00 New York time on some Fridays. From 2020 to 2025, our data has them on the S&P 500, the DAX and the FTSE 100. Candles with no price change (the high equals the low) appear, for example, on market holidays. Together, the two kinds were less than 1% of the candles in every test except the FTSE 100. On the FTSE 100, they were 1.8% of the candles on 1-hour charts, 1.2% on 4-hour charts and 3.5% on daily charts.
DAX and FTSE 100 data
Our DAX and FTSE 100 data has some wrong prices, and the results on this page include them. They appear at times with no trading, mostly between 22:00 and 23:00 German time. They are usually about 1% away from the last real price, and at most 3.7%. From 2020 to 2025, they appear on 40 days on the DAX and on 8 days on the FTSE 100. These wrong prices have no volume, so they add nothing to OBV. But a wrong price can change a candle's close, and that can change whether OBV goes up or down on that candle. A wrong price can also hit a stop-loss. So we ran these tests again without the wrong prices. On 1-hour charts, every DAX test did better without them: with the standard rules, the DAX made +199.4% instead of +168.9%. On 4-hour and daily charts, the DAX results changed by 5.2 percentage points or less (for example, +24.8% became +27.2%). Only one test went from a profit to a loss: the '50 EMA on OBV instead of 20' version on daily charts, from +0.8% to −1.2%. The FTSE 100 results changed by 3.2 percentage points or less. With or without the wrong prices, the standard rules made money on the DAX on all 3 charts, in both periods.
Overnight fees
Not included. Brokers charge a fee (a swap), or sometimes pay one, for each night a trade stays open. With the standard rules, half of the trades on daily charts were open for 4 days or more, so they would pay or earn fees for several nights. On 1-hour charts, half of the trades closed within 3 hours, and on 4-hour charts within 16 hours.

The rules we tested

  1. Calculate OBV: start at 0. When a candle closes higher than the candle before, add its volume. When it closes lower, subtract its volume. When it closes at the same price as the candle before, OBV does not change.
  2. Calculate a 20-candle EMA of OBV, and a 20-candle EMA of the closing price (the price EMA).
  3. Buy when OBV crosses above its EMA: OBV was at or below its EMA on the candle before, and it is above its EMA when this candle closes. The candle must also close above the price EMA. The trade opens at the next candle's open.
  4. Sell short when OBV crosses below its EMA and the candle closes below the price EMA.
  5. Close a buy trade when OBV crosses back below its EMA, and close a short trade when OBV crosses back above it. The trade closes at the next candle's open.
  6. Sometimes the candle that tells the strategy to close a trade also gives a signal in the other direction. Then the new trade opens one candle after the old trade closes, and only if OBV and price are still on the signal's side of their EMAs.
  7. Put the stop-loss 2 × ATR(14) away from the close of the candle that gave the signal. The stop-loss does not move.
  8. Set the trade size so that, if the stop-loss is hit, the trade loses about 1% of the account. Only one trade is open at a time.

The method

How we tested it

The test

Markets
EUR/USD, GBP/USD, USD/JPY, Gold, Silver, S&P 500, Nasdaq 100, Dow Jones, DAX and FTSE 100
Charts
1-hour, 4-hour and daily candles
Dates
January 2020 to December 2025
Account
$10,000, risking 1% of the account on each trade
Trading costs
Included. Every trade pays that market's normal trading cost: the spread, which is the gap between the buy price and the sell price.

How a test passes

We call a test passed only if it meets all four checks. A strategy can make money in one backtest and still fail one of these checks.

  • At least 100 trades. With fewer trades, a good result could be luck.
  • It made money from 2020 to 2023 and again from 2024 to 2025. This shows whether the strategy kept working in the newer years, not only in the older ones.
  • A profit factor (the money won divided by the money lost) of at least 1.2 from 2024 to 2025, after trading costs.
  • In 95% of 1,000 random shuffles of the trades, the account must not fall more than 30% from its highest point.

Improvements

Can the OBV trend strategy be improved?

We tested three changes that traders try with the OBV trend strategy: a different exit, a different entry, and a slower EMA on OBV. We tested each change on its own, on the same 30 tests. A change picked on the same years it is judged on will almost always look good, because it was picked for how it did in those years. So we picked the change with the most tests that made money in 2020–2023. Then we checked it on 2024–2025, the years we did not use to pick it.

Version Made money 2020–2023years used to pick the best version Made money 2024–2025years not used to pick it Made money in both periods Passed all four checks
Standard rules The rules under 'The rules we tested', with nothing changed. 14 of 30middle test −0.8% 15 of 30middle test +0.6% 10 4
Exit when price crosses its 20 EMABest on 2020–2023 Close a buy trade when a candle closes below the 20 EMA of price, and close a short trade when a candle closes above it. Do not wait for OBV to cross back through its EMA. The entry and the stop-loss stay the same. 17 of 30middle test +1.1% 14 of 30middle test −0.3% 7 1
Enter on a new OBV high or low Buy on a new OBV high instead of an OBV cross. A new high means that, at a candle's close, OBV is above its highest value of the 20 candles before. Price must also be above its 20 EMA. Sell short on a new 20-candle low in OBV while price is below its 20 EMA. Many traders read a new OBV high as a sign that price may rise next. The exit stays the same: OBV crossing back through its 20 EMA. 15 of 30middle test −0.2% 13 of 30middle test −2.2% 8 0
50 EMA on OBV instead of 20 Use a 50-candle EMA of OBV, instead of a 20-candle EMA, for the entry and the exit. The price EMA stays at 20. 12 of 30middle test −2.2% 13 of 30middle test −3.0% 5 1

Can the strategy be improved? Not clearly. We picked the exit when price crosses its 20 EMA, because it made money in the most tests on 2020–2023: 17 of 30, against 14 with the standard rules. On 2024–2025, it made money in 14 tests, and the standard rules in 15. Only 7 tests made money in both periods with this exit, against 10 with the standard rules. Its 1-hour trades lasted longer (a median of 6 hours, against 3), but on average they made less before costs: +0.012R per trade, against +0.017R. On 2024–2025, none of the three changes made money in more tests than the standard rules. The new-high entry made the most money added up over the 30 tests, but all of it came from 2020.

Passed all four checks with exit when price crosses its 20 EMA

  • Gold, 4-hour

Questions

Questions traders ask

Does the OBV trend strategy work?

Only on some markets. On-Balance Volume (OBV) adds a candle's volume when the candle closes higher than the candle before, and subtracts it when the candle closes lower. The standard rules buy when OBV crosses above its 20 EMA (a moving average) while price is above its own 20 EMA. They sell short when OBV crosses below its EMA while price is below its EMA, and they close the trade when OBV crosses back. From 2020 to 2025, after trading costs, these rules made money in 17 of 30 tests on 10 markets, and 10 of them made money in both 2020–2023 and 2024–2025. USD/JPY and the DAX made money on 1-hour, 4-hour and daily charts. EUR/USD and the S&P 500 lost money on all 3 charts. On 1-hour charts, the trades made money before trading costs, but lost money after them.

Does OBV work on forex?

In our test, only on USD/JPY. With the standard rules, USD/JPY made money on all 3 charts in the backtest: +136.1% on 1-hour, +36.2% on 4-hour and +6.0% on daily charts. EUR/USD lost money on all 3 charts, and GBP/USD made money only on daily charts (+2.4%). Forex has no central exchange, so OBV on a forex chart uses the volume of one price source, such as your broker. Our test used the volume in our price data. On the 3 forex pairs, OBV with this volume did better than OBV that counts every candle as 1 in 8 of the 9 tests, after trading costs.

What is the best timeframe for OBV?

In our test, the daily chart did best, but it made little money. With the standard rules, 7 of the 9 daily tests with enough trades made money, against 6 of 10 on 4-hour charts and 4 of 10 on 1-hour charts. But these 9 daily tests made only 106 to 147 trades each in 6 years, and the best one, gold, grew the account by 11.7% in the backtest. Overnight fees are not included, and half of the daily trades stayed open for 4 days or more, so these fees would change the daily results. On 1-hour charts, the trades made money before trading costs on 8 of the 10 markets, but after costs only 4 of the 10 made money.

Should you use a 20 or a 50 EMA on OBV?

In our test, the 20 EMA did better overall. With the 20 EMA, 10 tests made money in both 2020–2023 and 2024–2025, against 5 with the 50 EMA. With a 50 EMA, OBV crossed its EMA less often, so the 30 tests made 22,060 trades instead of 34,365 and paid trading costs less often. On 1-hour charts, the 50 EMA lost much less money after costs, and it did better than the 20 EMA on 6 of the 10 markets. But on daily charts, it made fewer than 100 trades on 9 of the 10 markets, too few to judge.

The strategy code we ran

This is the exact code from the BacktestingMax strategy engine. Paste it into the strategy editor in the app to run it on any market.

class ObvTrendStrategy(Strategy):
    """The OBV trend strategy: On-Balance Volume crossing its 20 EMA, in the direction of
    price's 20 EMA, plus three changes traders often make.
    OBV (On-Balance Volume, Joe Granville, 1963) is a running total of volume: when a candle
    closes higher than the candle before, its volume is added; when it closes lower, its
    volume is taken away; when it closes at the same price, OBV stays the same. Here it is
    worked out on the candles the strategy uses, with the volume in the price data.
    The EMAs are the usual exponential moving averages, alpha = 2 / (N + 1), started at
    the first value, as the engine's own EMA does.
    Standard (all switches off):
      Buy at the next open when OBV crosses above its 20 EMA (it was at or below the EMA on
      the candle before) and the close is above the 20 EMA of the closing prices.
      Sell short at the next open when OBV crosses below its 20 EMA and the close is below
      the price's 20 EMA.
      Exit at the next open when OBV crosses back through its EMA: below it for a buy, above
      it for a sell. If that candle is also a signal the other way, the opposite trade opens
      one candle later, once the old trade has closed, if OBV and the close are still on
      that side of their EMAs.
      Stop-loss: 2 x ATR(14) from the close of the signal candle. It does not move. ATR is
      Wilder's average true range, as the built-in ATR.
      Size: 1% of the account lost at the stop. When that is less than the smallest trade
      size the market allows, the signal is skipped. One trade at a time.
    Skipped candles: a candle that opens on a Friday at 17:00 New York time or later (some
    index and silver data has a few minutes of prices after the weekly close, which make a
    tiny extra candle), and a candle with no range (high = low, a market holiday). The
    strategy ignores them: they don't go into OBV, the EMAs or the ATR, and they give no
    signal and no exit. On a market that trades at the weekend, remove the Friday rule.
    The changes, one at a time:
      exit_price = 1   exit when the close crosses back through the price's 20 EMA (below
                       it for a buy, above it for a sell), instead of when OBV crosses back
      breakout   = 1   enter when OBV closes above its highest value of the previous 20
                       candles (below its lowest, for a sell), instead of when it crosses
                       its EMA; the close must still be on the right side of the 20 EMA,
                       and the exit is still OBV crossing back through its EMA
      obv_ema    = 50  a 50 EMA on OBV instead of the 20 EMA, for the entry and the exit
                       (the price filter stays the 20 EMA)
    The check on the volume itself:
      use_volume = 0   every candle counts as 1 instead of its volume, so OBV becomes the
                       number of candles that closed higher minus the number that closed lower
    """
    params = {"obv_ema": Param(type=int, default=20, min=2, max=500),
              "price_ema": Param(type=int, default=20, min=2, max=500),
              "atr_period": Param(type=int, default=14, min=2, max=100),
              "atr_mult": Param(type=float, default=2.0, min=0.5, max=10.0),
              "exit_price": Param(type=int, default=0, min=0, max=1),
              "breakout": Param(type=int, default=0, min=0, max=1),
              "breakout_len": Param(type=int, default=20, min=2, max=500),
              "use_volume": Param(type=int, default=1, min=0, max=1)}
    lookback = 5
    def init(self, ctx):
        self.ny = ctx.clock("America/New_York")
        self.used = 0            # candles used so far
        self.prev_close = None   # close of the previous candle used
        self.obv = 0.0
        self.obv_ema = None
        self.price_ema = None
        self.obv_last = []       # OBV of the previous candles used, newest last (breakout)
        self.first_trs = []      # the first true ranges, until the ATR can start
        self.atr = None
        self.reverse_to = None   # "long" / "short": open this once the closing trade is gone
    @staticmethod
    def ema_step(prev, x, n):
        return x if prev is None else prev + (x - prev) * 2.0 / (n + 1)
    def on_bar(self, ctx):
        p = ctx.params
        high, low, close, volume = ctx.high[0], ctx.low[0], ctx.close[0], ctx.volume[0]
        wd, hr = self.ny.weekday, self.ny.hour
        if (wd == 4 and hr >= 17) or wd == 5 or high <= low:
            return  # a tiny candle after the Friday close, or a candle with no range
        # ATR: Wilder's average of the true range, started with the simple average.
        if self.prev_close is None:
            true_range = high - low
        else:
            true_range = max(high - low, abs(high - self.prev_close), abs(low - self.prev_close))
        if self.atr is None:
            self.first_trs.append(true_range)
            if len(self.first_trs) == p.atr_period:
                self.atr = sum(self.first_trs) / p.atr_period
        else:
            self.atr += (true_range - self.atr) / p.atr_period
        # OBV: add this candle's volume if it closed higher than the candle before, take it
        # away if it closed lower. (use_volume = 0: count 1 instead of the volume.)
        step = (volume or 0.0) if p.use_volume == 1 else 1.0
        if self.prev_close is not None:
            if close > self.prev_close:
                self.obv += step
            elif close < self.prev_close:
                self.obv -= step
        self.prev_close = close
        obv_before, ema_before = (self.obv_last[-1] if self.obv_last else None), self.obv_ema
        self.obv_ema = self.ema_step(self.obv_ema, self.obv, p.obv_ema)
        self.price_ema = self.ema_step(self.price_ema, close, p.price_ema)
        window = self.obv_last[-p.breakout_len:]
        new_high = len(window) == p.breakout_len and self.obv > max(window)
        new_low = len(window) == p.breakout_len and self.obv < min(window)
        self.obv_last.append(self.obv)
        del self.obv_last[:-(p.breakout_len + 1)]
        self.used += 1
        if self.used <= max(p.obv_ema, p.price_ema) or self.atr is None or obv_before is None or ema_before is None:
            return  # warming up: the EMAs have fewer candles than their length
        obv_up = obv_before <= ema_before and self.obv > self.obv_ema      # OBV crosses above its EMA
        obv_down = obv_before >= ema_before and self.obv < self.obv_ema    # OBV crosses below its EMA
        if p.breakout == 1:
            long_signal = new_high and close > self.price_ema
            short_signal = new_low and close < self.price_ema
        else:
            long_signal = obv_up and close > self.price_ema
            short_signal = obv_down and close < self.price_ema
        pos = ctx.position
        if pos is not None:
            if p.exit_price == 1:
                exit_long, exit_short = close < self.price_ema, close > self.price_ema
            else:
                exit_long, exit_short = obv_down, obv_up
            if pos.is_long and exit_long:
                ctx.close_position()
                self.reverse_to = "short" if short_signal else None
            elif pos.is_short and exit_short:
                ctx.close_position()
                self.reverse_to = "long" if long_signal else None
            return
        # A reversal waits one candle for the close to fill. Drop it if OBV or the close came back.
        pending, self.reverse_to = self.reverse_to, None
        go_long = long_signal or (pending == "long" and self.obv > self.obv_ema and close > self.price_ema)
        go_short = short_signal or (pending == "short" and self.obv < self.obv_ema and close < self.price_ema)
        if not ctx.gate("obv_signal_with_price", go_long or go_short):
            return
        entry = close
        distance = p.atr_mult * self.atr
        stop = entry - distance if go_long else entry + distance
        size = ctx.size_by_risk_pct(0.01, stop=stop, entry=entry)
        if size <= 0:
            return  # 1% of the account is less than the smallest trade size: skip the signal
        if go_long:
            ctx.buy(size=size, sl=stop, tag="obv_long")
        else:
            ctx.sell(size=size, sl=stop, tag="obv_short")

Your turn

Test the OBV trend strategy yourself

Change the settings, the market or the stop-loss and see the result in seconds. Ask the BacktestingMax AI: Backtest the OBV trend strategy on USD/JPY, 1-hour chart: buy when On-Balance Volume crosses above its 20 EMA while price is above its 20 EMA, sell short on the opposite cross, exit when OBV crosses back, stop-loss 2 ATR(14), risk 1% per trade.

Try it free in BacktestingMax

Free account. No credit card needed.

See every strategy we tested Browse strategies shared by traders

Backtest on historical data with trading costs, run by BacktestingMax. Past results do not guarantee future results, and nothing here is financial advice. Updated 9 November 2026.