Clear all

OBV Divergences

Co-Founder Admin

Important: Works in VAI versions 1.1 and above. OBV will have changes in version 1.1. We will update this script once we have the final function.

Learning how to spot divergences between price and indicators is an essential skill that every trader should have. Here, we explore scripting divergences between price and the OBV. Again, divergences can form over long periods of time and we suggest only acting on it on a breakout or breakdown.

Adjust the lookback sensitivity for spotting divergences. This script uses 20 days and 10 days accordingly.


//OBV Divergence

#On Balance Volume
Set OBV = OBV(Close)
set highobv = max(obv,20)
set lowobv = min(obv,20)
set highobv2 = max(obv,10)
set lowobv2 = min(obv,10)

set highprice = max(high,20)
set lowprice = min(low,20)
set highprice2 = max(high,10)
set lowprice2 = min(low,10)

set lowestprice = low = lowprice and low = lowprice2
set highestprice = high = highprice and high = highprice2

Plot(OBV, Line,red,obv)

set bullish = lowestprice and lowobv2 > lowobv
set bearish = highestprice and highobv2 < highobv


This topic was modified 2 months ago by Mike
Topic starter Posted : 24/07/2021 6:15 pm