OPEN-SOURCE SCRIPT
Updated Bar Statistics - DELTA/OI/TOTAL/BUY/SELL/LONGS/SHORTS

Bar Statistics - Advanced Volume & Open Interest Analysis
Overview
The Bar Statistics indicator is a comprehensive analytical tool designed to provide traders with detailed insights into market microstructure through advanced volume analysis, open interest tracking, and market flow detection. This indicator transforms complex market data into easily digestible visual information, displaying six key metrics in customizable colored boxes that update in real-time.
Unlike traditional volume indicators that only show basic volume data, this indicator combines multiple data sources to reveal the underlying forces driving price movement, including volume delta calculations from lower timeframes, open interest changes, and estimated market positioning.
What Makes This Indicator Unique
1. Multi-Timeframe Volume Delta Precision
The indicator utilizes lower timeframe data (default 1-second) to calculate highly accurate volume delta measurements, providing much more precise buy/sell pressure analysis than standard timeframe-based calculations. This approach captures intraday volume dynamics that are often missed by conventional indicators.
2. Real-Time Updates
Unlike many indicators that only update on bar completion, this tool provides live updates for the developing candle, allowing traders to see evolving market conditions as they happen.
3. Market Flow Analysis
The unique "L/S" (Long/Short) metric combines open interest changes with price/volume direction to estimate net market positioning, helping identify when participants are accumulating or distributing positions.
4. Adaptive Visual Intensity
The gradient color system automatically adjusts based on historical context, making it easy to identify when current values are significant relative to recent market activity.
5. Complete Customization
Every aspect of the display can be customized, from the order of metrics to individual color schemes, allowing traders to adapt the tool to their specific analysis needs.
6.All In One Solution
6 Metrics in one indicator no more using 5 different indicators.
Core Features Explained
DELTA (Volume Delta)
What it shows: Net difference between aggressive buy volume and aggressive sell volume
Calculation: Uses lower timeframe data to determine whether each trade was initiated by buyers or sellers
Interpretation:
Positive values indicate aggressive buying pressure
Negative values indicate aggressive selling pressure
Magnitude indicates the strength of directional pressure
OI Δ (Open Interest Change)
What it shows: Change in open interest from the previous bar
Data source: Fetches open interest data using the "_OI" symbol suffix
Interpretation:
Positive values indicate new positions entering the market
Negative values indicate positions being closed
Combined with price direction, reveals market participant behavior
L/S (Net Long/Short Bias)
What it shows: Estimated net change in long vs short market positions
Calculation method: Combines open interest changes with price/volume direction using configurable logic
Scenarios analyzed:
New Longs: Rising OI + Rising Price/Volume = Long position accumulation
Liquidated Longs: Falling OI + Falling Price/Volume = Long position exits
New Shorts: Rising OI + Falling Price/Volume = Short position accumulation
Covered Shorts: Falling OI + Rising Price/Volume = Short position exits
Result: Net bias toward long (positive) or short (negative) market sentiment
TOTAL (Total Volume)
What it shows: Standard volume for the current bar
Purpose: Provides context for other metrics and baseline activity measurement
Enhanced display: Uses gradient intensity based on recent volume history
BUY (Estimated Buy Volume)
What it shows: Estimated aggressive buy volume
Calculation: (Total Volume + Delta) / 2
Use case: Helps quantify the actual buying pressure in monetary/contract terms
SELL (Estimated Sell Volume)
What it shows: Estimated aggressive sell volume
Calculation: (Total Volume - Delta) / 2
Use case: Helps quantify the actual selling pressure in monetary/contract terms
Configuration Options
Timeframe Settings
Custom Timeframe Toggle: Enable/disable custom lower timeframe selection
Timeframe Selection: Choose the precision level for volume delta calculations
Auto-Selection Logic: Automatically selects optimal timeframe based on chart timeframe
Net Positions Calculation
Direction Method: Choose between Price-based or Volume Delta-based direction determination
Value Method: Select between Open Interest Change or Volume for position size calculations
Display Customization
Row Order: Completely customize which metrics appear and in what order (6 positions available)
Color Schemes: Individual color selection for positive/negative values of each metric
Gradient Intensity: Configurable lookback period (10-200 bars) for relative intensity calculations
Visual Elements
Box Format: Clean, professional box display with clear labels
Color Coding: Intuitive color schemes with customizable transparency gradients
Real-time Updates: Live updating for developing candles with historical stability
How to Use This Indicator
For Day Traders
Volume Confirmation: Use DELTA to confirm breakout validity - strong directional moves should show corresponding volume delta
Entry Timing: Watch for volume delta divergences at key levels to time entries
Exit Signals: Monitor when aggressive volume shifts against your position
For Swing Traders
Market Flow: Focus on the L/S metric to identify when participants are accumulating or distributing
Open Interest Analysis: Use OI Δ to confirm whether moves are backed by new money or position adjustments
Trend Validation: Combine multiple metrics to validate trend strength and sustainability
For Scalpers
Real-time Edge: Utilize the live updates to see developing imbalances before bar completion
Quick Decision Making: Focus on DELTA and BUY/SELL for immediate market pressure assessment
Volume Profile: Use TOTAL volume context for optimal entry/exit sizing
Setup Recommendations
Futures Markets: Enable OI tracking and use Volume Delta direction method
Crypto Markets: Focus on DELTA and volume metrics; OI may not be available
Stock Markets: Use Price direction method with volume value calculations
High-Frequency Analysis: Set lower timeframe to 1S for maximum precision
Technical Implementation
Data Accuracy
Utilizes TradingView's ta.requestVolumeDelta() function for precise buy/sell classification
Implements error checking for data availability
Handles missing data gracefully with fallback calculations
Performance Optimization
Efficient array management with configurable lookback periods
Smart box creation and deletion to prevent memory issues
Optimized real-time updates without historical data corruption
Compatibility
Works on all timeframes from seconds to daily
Compatible with futures, forex, crypto, and stock markets
Automatically adjusts calculation methods based on available data
Risk Disclaimers
This indicator is designed for educational and analytical purposes. It provides statistical analysis of market data but does not guarantee trading success. Users should:
Combine with other forms of analysis
Practice proper risk management
Understand that past performance doesn't predict future results
Be aware that volume delta and open interest data quality varies by market and data provider
Conclusion
The Bar Statistics indicator represents a significant advancement in retail trader access to professional-grade market analysis tools. By combining multiple data sources into a single, customizable display, it provides the depth of analysis needed for comprehensive market microstructure understanding while maintaining the simplicity required for effective decision-making.
Overview
The Bar Statistics indicator is a comprehensive analytical tool designed to provide traders with detailed insights into market microstructure through advanced volume analysis, open interest tracking, and market flow detection. This indicator transforms complex market data into easily digestible visual information, displaying six key metrics in customizable colored boxes that update in real-time.
Unlike traditional volume indicators that only show basic volume data, this indicator combines multiple data sources to reveal the underlying forces driving price movement, including volume delta calculations from lower timeframes, open interest changes, and estimated market positioning.
What Makes This Indicator Unique
1. Multi-Timeframe Volume Delta Precision
The indicator utilizes lower timeframe data (default 1-second) to calculate highly accurate volume delta measurements, providing much more precise buy/sell pressure analysis than standard timeframe-based calculations. This approach captures intraday volume dynamics that are often missed by conventional indicators.
2. Real-Time Updates
Unlike many indicators that only update on bar completion, this tool provides live updates for the developing candle, allowing traders to see evolving market conditions as they happen.
3. Market Flow Analysis
The unique "L/S" (Long/Short) metric combines open interest changes with price/volume direction to estimate net market positioning, helping identify when participants are accumulating or distributing positions.
4. Adaptive Visual Intensity
The gradient color system automatically adjusts based on historical context, making it easy to identify when current values are significant relative to recent market activity.
5. Complete Customization
Every aspect of the display can be customized, from the order of metrics to individual color schemes, allowing traders to adapt the tool to their specific analysis needs.
6.All In One Solution
6 Metrics in one indicator no more using 5 different indicators.
Core Features Explained
DELTA (Volume Delta)
What it shows: Net difference between aggressive buy volume and aggressive sell volume
Calculation: Uses lower timeframe data to determine whether each trade was initiated by buyers or sellers
Interpretation:
Positive values indicate aggressive buying pressure
Negative values indicate aggressive selling pressure
Magnitude indicates the strength of directional pressure
OI Δ (Open Interest Change)
What it shows: Change in open interest from the previous bar
Data source: Fetches open interest data using the "_OI" symbol suffix
Interpretation:
Positive values indicate new positions entering the market
Negative values indicate positions being closed
Combined with price direction, reveals market participant behavior
L/S (Net Long/Short Bias)
What it shows: Estimated net change in long vs short market positions
Calculation method: Combines open interest changes with price/volume direction using configurable logic
Scenarios analyzed:
New Longs: Rising OI + Rising Price/Volume = Long position accumulation
Liquidated Longs: Falling OI + Falling Price/Volume = Long position exits
New Shorts: Rising OI + Falling Price/Volume = Short position accumulation
Covered Shorts: Falling OI + Rising Price/Volume = Short position exits
Result: Net bias toward long (positive) or short (negative) market sentiment
TOTAL (Total Volume)
What it shows: Standard volume for the current bar
Purpose: Provides context for other metrics and baseline activity measurement
Enhanced display: Uses gradient intensity based on recent volume history
BUY (Estimated Buy Volume)
What it shows: Estimated aggressive buy volume
Calculation: (Total Volume + Delta) / 2
Use case: Helps quantify the actual buying pressure in monetary/contract terms
SELL (Estimated Sell Volume)
What it shows: Estimated aggressive sell volume
Calculation: (Total Volume - Delta) / 2
Use case: Helps quantify the actual selling pressure in monetary/contract terms
Configuration Options
Timeframe Settings
Custom Timeframe Toggle: Enable/disable custom lower timeframe selection
Timeframe Selection: Choose the precision level for volume delta calculations
Auto-Selection Logic: Automatically selects optimal timeframe based on chart timeframe
Net Positions Calculation
Direction Method: Choose between Price-based or Volume Delta-based direction determination
Value Method: Select between Open Interest Change or Volume for position size calculations
Display Customization
Row Order: Completely customize which metrics appear and in what order (6 positions available)
Color Schemes: Individual color selection for positive/negative values of each metric
Gradient Intensity: Configurable lookback period (10-200 bars) for relative intensity calculations
Visual Elements
Box Format: Clean, professional box display with clear labels
Color Coding: Intuitive color schemes with customizable transparency gradients
Real-time Updates: Live updating for developing candles with historical stability
How to Use This Indicator
For Day Traders
Volume Confirmation: Use DELTA to confirm breakout validity - strong directional moves should show corresponding volume delta
Entry Timing: Watch for volume delta divergences at key levels to time entries
Exit Signals: Monitor when aggressive volume shifts against your position
For Swing Traders
Market Flow: Focus on the L/S metric to identify when participants are accumulating or distributing
Open Interest Analysis: Use OI Δ to confirm whether moves are backed by new money or position adjustments
Trend Validation: Combine multiple metrics to validate trend strength and sustainability
For Scalpers
Real-time Edge: Utilize the live updates to see developing imbalances before bar completion
Quick Decision Making: Focus on DELTA and BUY/SELL for immediate market pressure assessment
Volume Profile: Use TOTAL volume context for optimal entry/exit sizing
Setup Recommendations
Futures Markets: Enable OI tracking and use Volume Delta direction method
Crypto Markets: Focus on DELTA and volume metrics; OI may not be available
Stock Markets: Use Price direction method with volume value calculations
High-Frequency Analysis: Set lower timeframe to 1S for maximum precision
Technical Implementation
Data Accuracy
Utilizes TradingView's ta.requestVolumeDelta() function for precise buy/sell classification
Implements error checking for data availability
Handles missing data gracefully with fallback calculations
Performance Optimization
Efficient array management with configurable lookback periods
Smart box creation and deletion to prevent memory issues
Optimized real-time updates without historical data corruption
Compatibility
Works on all timeframes from seconds to daily
Compatible with futures, forex, crypto, and stock markets
Automatically adjusts calculation methods based on available data
Risk Disclaimers
This indicator is designed for educational and analytical purposes. It provides statistical analysis of market data but does not guarantee trading success. Users should:
Combine with other forms of analysis
Practice proper risk management
Understand that past performance doesn't predict future results
Be aware that volume delta and open interest data quality varies by market and data provider
Conclusion
The Bar Statistics indicator represents a significant advancement in retail trader access to professional-grade market analysis tools. By combining multiple data sources into a single, customizable display, it provides the depth of analysis needed for comprehensive market microstructure understanding while maintaining the simplicity required for effective decision-making.
Release Notes
Added tooltips for net positions optionsUpdate more detailed chart
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.