OPEN-SOURCE SCRIPT

Volume Bars [jpkxyz]

Mis à jour
snapshot

Multi-Timeframe Volume indicator by jpkxyz

This script is a Multi-Timeframe Volume Z-Score Indicator. It dynamically calculates /the Z-Score of volume over different timeframes to assess how significantly current
volume deviates from its historical average. The Z-Score is computed for each
timeframe independently and is based on a user-defined lookback period. The
script switches between timeframes automatically, adapting to the chart's current
timeframe using `timeframe.multiplier`.

The Z-Score formula used is: (current volume - mean) / standard deviation, where
mean and standard deviation are calculated over the lookback period.

The indicator highlights periods of "significant" and "massive" volume by comparing
the Z-Score to user-specified thresholds (`zScoreThreshold` for significant volume
and `massiveZScoreThreshold` for massive volume). The script flags buy or sell
conditions based on whether the current close is higher or lower than the open.

Visual cues:
- Dark Green for massive buy volume.
- Red for massive sell volume.
- Green for significant buy volume.
- Orange for significant sell volume.
- Gray for normal volume.

The script also provides customizable alert conditions for detecting significant or massive buy/sell volume events, allowing users to set real-time alerts.
Notes de version
Volume Bars [jpkxyz] - Volume Z-Score Analysis Indicator

This indicator calculates and displays volume Z-scores, measuring how current volume deviates from its historical average over a user-defined lookback period.
The Z-score formula used is: (current volume - mean) / standard deviation.

Features:
- Z-score based volume analysis
- Two threshold levels: significant and massive volume
- Optional non-repainting mode for backtesting
- Customizable bar colors and transparency

Bar colors indicate:
- Dark Green: Massive buy volume
- Red: Massive sell volume
- Green: Significant buy volume
- Orange: Significant sell volume
- Gray: Normal volume

Applications:
- Volume spike identification
- Volume trend analysis
- Backtesting with non-repainting mode
- Real-time volume monitoring with repainting mode

The indicator uses bar colors to integrate volume analysis directly with price action while maintaining chart clarity.




The previous version used barmerge.lookahead_on for various timeframe requests without an offset. This can lead to misleading historical results because it's looking ahead without the protective offset. Thank you PineCoders for making me aware of this.

Here are the key improvements:

1. Added repainting control via input parameter
2. Users can now choose between:
* allowRepaint = true: For live trading analysis (sees volume changes in real-time)
* allowRepaint = false: For backtesting and alerts (only uses confirmed volume)

Benefits of this approach:

1. For Live Trading:
  • When allowRepaint = true, you'll see volume bars change color as volume accumulates within the current bar
  • Helpful for watching potential volume setups develop
  • Good for discretionary trading decisions

2. For Backtesting:
  • When allowRepaint = false, you only get signals based on completed bars
  • More reliable for backtesting results
  • Better for automated alerts to avoid false triggers
  • Prevents misleading historical results

Usage Recommendation:

1. Use allowRepaint = true when:
  • Actively watching the market
  • Making manual trading decisions
  • Want to see potential volume setups forming in real time

2. Use allowRepaint = false when:
  • Backtesting strategies
  • Want to avoid false signals
  • Running automated systems




Please be aware that the historical bars color change depending if you have repainting on or off. When you switch between modes, it's essentially shifting the volume data by one bar, which changes the Z-score calculations and therefore the bar colors.

1. When allowRepaint = false, you're seeing data from the previous bar (volume[1]) for all calculations
2. When allowRepaint = true, you're seeing volume data from the current bar


Example:
  • In non-repainting mode, bar 5's color is based on bar 4's volume
  • In repainting mode, bar 5's color is based on bar 5's volume


This is why PineCoders recommends using volume[1] with lookahead=barmerge.lookahead_on for consistent historical data. If you want truly consistent historical bars, you should keep it in non-repainting mode.
If you want to get real-time data while live trading keep it in repainting mode.

The new logic ensures:

1. New bars start with neutral transparency
2. In repainting mode, transparency updates as volume conditions are met
3. In non-repainting mode, bars stay neutral until confirmed

Default Input Changes: 



Previous
  • Lookback for Z-Score: 100 Bars

  • Significant Volume Threshold: 0.2

  • Massive Volume Threshold: 0.4




New
  • Lookback for Z-Score: 25 Bars / to make it more responsive to recent volume 

  • Significant Volume Threshold: 0.3 / slightly higher filter 

  • Massive Volume Threshold: 0.6 / slightly higher filter 




Simpler and cleaner timeframe logic:

1. Removed all individual timeframe volume requests
2. Added single request using timeframe.period
3. Simplified Z-score calculation to use only current timeframe
4. Removed getCurrentZScore() function as it's no longer needed

If you have questions, suggestions, find errors or if your using this script to build cool things yourself, please let me know in the comments.


DISCLAIMER:

The creator of this script
- Does not guarantee accuracy or completeness of data
- Is not responsible for trading decisions or losses
- Makes no claims about future market performance
- Provides no warranty of fitness for any purpose

Use this indicator at your own risk. Past performance does not indicate future results.
Trading involves substantial risk of loss. Only trade with capital you can afford to lose.
By using this script you acknowledge and accept full responsibility for any outcomes.



barcolormultitimeframestatisticsVolume Indicatorvolumetrendanalysisvolumezscorez-score

Script open-source

Dans le plus pur esprit TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par nos Règles. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Vous voulez utiliser ce script sur un graphique ?


Aussi sur:

Clause de non-responsabilité