INVITE-ONLY SCRIPT

Adaptive On Balance Volume with Trend

94
█ Introduction
The Adaptive On Balance Volume (AOBV) indicator enhances the traditional On Balance Volume (OBV) by introducing adaptability, volatility detection, and trend analysis. It helps traders identify the direction of volume flow, assess volume momentum, and spot potential reversals in the market.

Detecting market tops and bottoms is crucial for making informed trading decisions. The AOBV indicator offers a method for identifying these points by using an adaptive volatility detection function that highlights potential volume peaks or climaxes, suggesting when a price top or bottom may be forming.

█ Understanding the AOBV
Note: Details on how calculations are conducted can be found at the end of this script description.
1. The Basics of the AOBV Function:
 • Adaptive Momentum Calculation: Instead of using a fixed momentum formula, the AOBV uses the original formula for basic momentum and enhances it based on relative strength and applies an adaptive smoothing function.
 • Dynamic Smoothing:
   • Strong Momentum: When the AOBV detects significant changes (strong momentum), it reduces smoothing. This makes the indicator more responsive to major market movements.
   • Weak Momentum: When momentum is weak (small changes), it increases smoothing to filter out market noise.

This adaptability allows the AOBV to more accurately reflect volume momentum, responding promptly during significant market moves and remaining stable during quieter periods.

To determine the trend direction (bullish or bearish), the indicator calculates a signal curve and displays the difference as bars:
 • Bar Above the Middle Line: Indicates a bullish trend.
 • Bar Below the Middle Line: Indicates a bearish trend.

2. Volatility Function:
The volatility function measures how much the AOBV deviates from its average by comparing it to its smoothed version. It calculates the exponential standard deviation to estimate volatility.
 • Purpose: Identifies when volume momentum is near a climax or when a trend is nearing exhaustion.
 • How It Works:
   • Compares current volatility to previous bars.
   • Computes a percentage indicating how often the current volatility is higher than past values.
   • If this percentage exceeds a defined threshold, it signals a significant volatility event by plotting a dot above or below the bar.

This pattern typically manifests itself during strong runs on price followed by a period of consolidation. Thus, estimating volatility would be an acceptable measure of when a market is reaching or nearing an implied top or bottom.

3. The Trend Function:
The trend function combines several common indicators to gauge buildup toward a reversal or a continuation of a trend when the AOBV changes direction.
 • Components:
   • AOBV Strength Percentage: Calculates the percentage change in the AOBV to gauge its strength and direction.
   • Supertrend Indicator: Acts as the main driver for trend buildup.
   • Vertical Horizontal Filter (VHF): Measures market consolidation, adjusting the trend strength accordingly.
   • Adaptive RSI: Further refines the trend strength based on volume momentum.
 • Trend Ranking:
   • Assigns a trend rank to the AOBV that reflects both market direction and momentum.
   • Colors are used to represent different trend strengths: Strong Bullish, Bullish, Strong Bearish, and Bearish.

█ How to Use the AOBV
 • Above the Middle Line: Suggests a bullish trend.
 • Below the Middle Line: Suggests a bearish trend
 • The Volatility dots:
   • Indicate strong momentum relative to previous bars.
   • Signal that the trend may be nearing a climax or exhaustion.
   • Can imply a potential market top or bottom.

snapshot

 • Consolidation can be detected by visually comparing current bars to previous ones. This should be obvious since, and as described, the AOBV bars represent volume momentum.

snapshot

 • The trend function is used to gauge the likelihood of a reversal or a continuation of a trend; trend is represented with several colors: strong bullish trend, bullish trend, strong bearish trend, and finally simply a bearish trend.
It is important to understand that this trend function is not the typical trend function found on other technical indicators. It must be viewed within the context of the AOBV momentum. For example, if AOBV is exerting a bullish trend (bars above middle line), then a bearish trend with no major change in momentum and no volatility indication could mean a false reversal. Conversely, a large charge in AOBV could be a strong indication of a market reversal.
snapshot

█ Key Features
 • Two Display Modes: Curve and Bars:
The Adaptive OBV can be viewed in two different display modes: Curve and Bars Mode. "Curve Mode" offers the classic OBV representation (but as AOBV) with trend, while "Bars Mode" incorporates volatility detection and trend, making it the recommended mode.

 • Volatility Function:
   • Dots appear above or below the volume bars when significant volatility events are detected.
   • The sensitivity can be adjusted by changing the percentage threshold.

 • Trend Analysis:
   • Helps gauge the likelihood of a trend continuation or reversal.
   • Uses color-coded trend ranks for easy interpretation.

 • Flexible Lookback Period:
Lookback periods for the main AOBV, its signal line, trend function, and volatility function can be customized.
   • Recommendations:
   • Match the main lookback period with the volatility period: Ensures consistency in momentum and volatility measurements.
   • Match the trend lookback period with the signal AOBV lookback period: Aligns trend analysis with the underlying momentum signals.

Below is a sample demonstrating the utility on a 1- minute chart.
snapshot

█ Calculation Details:
 • AOBV Calculations
The AOBV differs the traditional OBV by focusing on the differences in OBV values rather than absolute price movements. Initially, it calculates the standard OBV by accumulating volume based on whether the closing price is higher or lower than the previous close. Next, it computes the difference between the current OBV and the previous OBV to measure changes in volume momentum. It calculates the average net change and average total change of these OBV differences over a specified period using a selected averaging method (e.g., EMA, SMA). By dividing the average net change by the average total change, it obtains a change ratio that reflects the strength and direction of volume momentum.

This change ratio is then scaled to an RSI-like value between 0 and 100, which is used to derive an adaptive smoothing factor (alpha). The alpha adjusts dynamically—when the change ratio indicates strong momentum, alpha increases, making the indicator more responsive to recent changes; when momentum is weak, alpha decreases, increasing smoothing to filter out noise.

The adaptive OBV is calculated by applying this alpha to combine the current OBV and the previous adaptive OBV value. This adaptive smoothing allows the indicator to adjust its sensitivity based on market conditions, becoming more responsive during strong momentum and more stable during weak momentum.

A smoothed OBV signal line is also computed using weighted moving averages for comparison. By analyzing the difference between the adaptive OBV and this smoothed signal line, the indicator identifies bullish or bearish trends. Positive differences suggest bullish momentum (bars above the middle line), while negative differences indicate bearish momentum (bars below the middle line).

 • Volatility Calculations
The volatility function in the AOBV indicator identifies significant changes in volume momentum by estimating the variability of recent momentum shifts. It begins by calculating the difference between the AOBV and its smoothed signal line, capturing the current change in volume momentum. To assess volatility, the function employs exponential smoothing to compute adaptive averages of both the volume and the squared volume over a specified lookback period. By combining these averages, it estimates the current standard deviation of the volume momentum changes, effectively measuring how much the momentum deviates from its average level.

This estimated volatility is then compared to historical volatility values over the lookback period to determine how frequently the current volatility exceeds past levels. If the proportion of times the current volatility is higher than previous values and it surpasses a user-defined threshold, it signals a significant volatility event, indicating a potential volume climax

 • Trend Calculations
As outlined earlier in description, the trend function is composed of several components:

The Supertrend indicator calculates dynamic support and resistance levels based on price movements and volatility using the Average True Range. It assesses whether the closing price is above or below these levels to determine the primary trend direction. If the price is above the Supertrend line: The market is considered to be in an uptrend. If the price is below the Supertrend line: The market is considered to be in a downtrend.

The Vertical Horizontal Filter measures the strength of the trend by comparing the price range over a period to the sum of absolute price changes. It does this by comparing the difference between the highest and lowest prices over a given period (the "vertical" movement) to the sum of the absolute differences between consecutive prices (the "horizontal" movement). A higher VHF value indicates a stronger, more directional trend, while a lower value suggests that the market is moving sideways without a clear trend.. If the VHF detects consolidation, it downgrades the trend strength indicated by the Supertrend. This prevents the trend function from overemphasizing the Supertrend's signals when the market lacks clear direction.

The Adaptive RSI Analyzes recent changes in the AOBV to identify whether volume momentum is strengthening or weakening (based on the volume percent change) correlating price movement with volume momentum. It only upgrades or downgrades on a bar by bar basis if price movement is correlating with percent change. This acts as a corrective measure against the VHF since quiet periods (consolidation) can occur between strong moves. The alpha generated from the adaptive function is the same as the one generated with the AOBV calculations.

█ Disclaimer
This script is provided for educational and informational purposes only and should not be considered financial advice. Trading financial instruments carries a high level of risk and may not be suitable for all investors. Before using this script, please consult with a qualified financial advisor to ensure it aligns with your individual circumstances. The author does not guarantee the accuracy or completeness of the script and is not responsible for any losses or damages that may occur from its use. Use this script at your own risk.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.