Strategy Creation

What is the On-Balance Volume indicator and how to use it on Tuned?

Tuned Team

In this article, we’ll be exploring what the On-Balance Volume (OBV) indicator is, what it measures, common uses, and how it can be applied to Tuned and algorithmic trading in general.

Table of contents

  1. What is the On-Balance Volume indicator?
  2. How is the On-Balance Volume calculated?
  3. Common uses
  4. An example strategy using OBV on Tuned
  5. Conclusion

What is the On-Balance Volume indicator?

On-Balance Volume (OBV) is an indicator that measures momentum. It was created in 1932 by Joseph Granville, making its first appearance in his book Granville’s New Key to Stock Market Profits.

It measures momentum by either subtracting or adding the volume of a candle to its on-balance volume total, candles whose closing price was lower than its opening price, have their volume number subtracted from the total, and candles whose closing price was higher than its open price have their volume added to the total. If the opening and closing prices are identical, no calculations are performed.

OBV is an unbound indicator since the theoretical volume of any given candle of an asset is unlimited.

One of the main characteristics of the OBV indicator is that the absolute OBV value is more or less irrelevant for use as a signal as this value is heavily influenced by the starting point, but the direction and slope are not. Due to the nature of it being a cumulative indicator, different starting points greatly affect the quantitative OBV value.

  • A rising OBV value indicates an increase in price accompanied by volume;
  • A descending OBV value indicates a decrease in price accompanied by volume;
  • A stable OBV value indicates no fluctuations between the opening and closing prices’ volume. This suggests buyers and sellers are in balance.

How is the On-Balance Volume calculated?

The formula for calculating the OBV is the following:

Common uses

The On-Balance Volume indicator was created on a basis that volume is the main price movement catalyst. It was created to predict when the price of an asset is due for a major move, but it cannot predict the direction of those moves. As such, it’s difficult to derive primary signals from it, better serving the function of a confirmation or filter indicator. In short, OBV helps you:

  • Identify divergences between volume and price;
  • Predict periods of incoming volatility;
  • Confirm trends or reversals.

An example strategy using OBV in Tuned

The code is as follows:

Tuned Script

ObvEmaLength = intInput("OBV EMA LENGTH", 32)
OBV = obv(close, volume)
OBVEMA = ema(OBV, ObvEmaLength)
buy = crossover(OBV, OBVEMA)
sell = crossunder(OBV, OBVEMA)

plot(OBV, "On-Balance Volume", "#00FF2A", 2, PlotStyle.LINE,3, false)
plot(OBVEMA, "On-Balance Volume", "#0026FF", 2, PlotStyle.LINE,3, false)

//Signal Push
out(signalIf(buy, sell))</sup>

Pine Alpha

strategy(title="OBV Example", overlay = false)
EmaLength = input(title="OBV EMA Length", defval=32)
OBV = obv
OBVEma = ema(OBV, EmaLength)
plot(OBV, "On-Balance Volume",
plot(OBVEma, "On-Balance Volume",
buy = crossover(OBV, OBVEma)
sell = crossunder(OBV, OBVEma)
strategy.order("long", strategy.long, when=buy)
strategy.order("Short", strategy.short, when=sell)</sup>

For demonstration purposes, a strategy was coded with the following parameters:

  • OBV EMA Length = 32;
  • Long when OBV crosses over the OBV EMA;
  • Short when OBV crosses under the OBV EMA;
  • Stop Loss = 6%;
  • Take Profit = 16%.

Finding a profitable trading strategy that solely uses the OBV indicator as its primary signal is difficult and unorthodox. We opted by plotting an EMA of the OBV value and setting conditions to open trades when a crossover or crossunder between the OBV and EMA value occurs. An EMA is an excellent tool to remove noise from any data set and crosses indicate a change in the OBV direction. This strategy aims to open a trade when a new trend or reversal is detected. 

How does it behave?

  • In sideways markets, this strategy is prone to whipsaws, triggering too many signals.
  • In trending markets, this strategy can produce profitable trades by following the trend, higher timeframes produced better results in our testing due to a lower amount of market data noise.


Based on our research and the results we found during testing, the OBV indicator is a versatile indicator for multiple use cases. There’s a lack of trading strategies that take advantage of this indicator, this leads to trading opportunities by thinking outside the box and leveraging the full capabilities of the OBV indicator. There are infinite ways of doing so, such as specifying % change thresholds of the OBV’s quantitative value to derive signals. We were able to produce profitable strategies by making use of Tuned’s batch testing feature to find optimal threshold values.

Have fun scripting!

Disclaimer: The opinions expressed here are for general informational purposes only and are not intended to provide specific advice or recommendations for any specific security or investment product. You should never invest money that you cannot afford to lose. Before trading using complex financial products, please ensure to understand the risks involved. Past performance is no guarantee of future results.

All investing involves risk, including the possible loss of all the money you invest, and past performance does not guarantee future performance. Historical returns expected returns, and probability projections are provided for informational and illustrative purposes, and may not reflect actual future performance.

Tuned is not a broker-dealer, exchange, custodian, wallet provider, or counterparty. Investing is highly speculative and volatile. Tuned is only suitable for investors who fully understand the risk of loss and may experience large drawdowns. Investors should never invest more than they can afford to lose.