Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

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

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

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

//Plot
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))

Pine Alpha

//@version=4
strategy(title="OBV Example", overlay = false)
 
//Inputs
EmaLength = input(title="OBV EMA Length", defval=32)
 
//Indicators
OBV = obv
OBVEma = ema(OBV, EmaLength)
 
//Plots
plot(OBV, "On-Balance Volume", color.green)
plot(OBVEma, "On-Balance Volume", color.blue)
 
//conditions
buy = crossover(OBV, OBVEma)
sell = crossunder(OBV, OBVEma)
 
//Entry
strategy.order("long", strategy.long, when=buy)
strategy.order("Short", strategy.short, when=sell)

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.

Conclusion

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!


The Pitfalls of Backtesting – How to Avoid Overfitting and Disappointment

Table of Contents: What is overfitting?How do I avoid overfitting? For the investors reading this article, you can skip ahead to “What is Overfitting?” By this point you …
Read More

What is CCI and How to Use It in Tuned Script

What is the Commodity Channel Index (CCI)?Key points about the CCIHow to add the CCI to my script?How to use the CCI to generate buy …
Read More

What is the Rate of Change indicator and how to use it on Tuned?

In this article, we’ll be exploring what the Rate of Change (RoC) is, what it measures, common uses and how it can be applied to …
Read More

What is RSI and How to Use It in Tuned Script

What Is the Relative Strength Index (RSI)? The relative strength index (RSI) is a momentum indicator used in technical analysis that measures the magnitude of recent …
Read More

The post What is the On-Balance Volume indicator and how to use it on Tuned? appeared first on Tuned.



This post first appeared on Tuned ›› The Social Magazine, please read the originial post: here

Share the post

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

×

Subscribe to Tuned ›› The Social Magazine

Get updates delivered right to your inbox!

Thank you for your subscription

×