Delta Volume Columns Pro [LucF]


This indicator displays volume​​ delta information calculated with intrabar inspection on historical bars, and feed updates when running in realtime. It is designed to run in a pane and can display either stacked buy/sell volume​ columns or a signal line which can be calculated and displayed in many different ways.

Five different models are offered to reveal different characteristics of the calculated volume​ delta information. Many options are offered to visualize the calculations, giving you much leeway in morphing the indicator's visuals to suit your needs. If you value delta volume​ information, I hope you will find the time required to master Delta Volume​ Columns Pro well worth the investment. I am confident that if you combine a proper understanding of the indicator's information with an intimate knowledge of the volume​ idiosyncrasies on the markets you trade, you can extract useful market intelligence using this tool.


1. The indicator only works on markets where volume​ information is available,
  Please validate that your symbol's feed carries volume​ information before asking me why the indicator doesn't plot values.
2. When you refresh your chart or re-execute the script on the chart, the indicator will repaint because elapsed realtime bars will then recalculate as historical bars.
3. Because the indicator uses different modes of calculation on historical and realtime bars, it's critical that you understand the differences between them. Details are provided further down.
4. Calculations using intrabar inspection on historical bars can only be done from some chart timeframes. See further down for a list of supported timeframes.
  If the chart's timeframe is not supported, no historical volume​ delta will display.


Chart bars
Three different types of bars are used in charts:
 1. Historical bars are bars that have already closed when the script executes on them.
 2. The realtime bar is the current, incomplete bar where a script is running on an open market. There is only one active realtime bar on your chart at any given time.
   The realtime bar is where alerts trigger.
 3. Elapsed realtime bars are bars that were calculated when they were realtime bars but have since closed.
   When a script re-executes on a chart because the browser tab is refreshed or some of its inputs are changed, elapsed realtime bars are recalculated as historical bars.

Why does this indicator use two modes of calculation?
Historical bars on TradingView charts contain OHLCV data only, which is insufficient to calculate volume​ delta on them with any level of precision. To mine more detailed information from those bars we look at intrabars, i.e., bars from a smaller timeframe (we call it the intrabar timeframe) that are contained in one chart bar. If your chart Is running at 1D on a 24x7 market for example, most 1D chart bars will contain 24 underlying 1H bars in their dilation. On historical bars, this indicator looks at those intrabars to amass volume​ delta information. If the intrabar is up, its volume​ goes in the Buy bin, and inversely for the Sell bin. When price does not move on an intrabar, the polarity of the last known movement is used to determine in which bin its volume​ goes.

In realtime, we have access to price and volume​ change for each update of the chart. Because a 1D chart bar can be updated tens of thousands of times during the day, volume​ delta calculations on those updates is much more precise. This precision, however, comes at a price:
 — The script must be running on the chart for it to keep calculating in realtime.
 — If you refresh your chart you will lose all accumulated realtime calculations on elapsed realtime bars, and the realtime bar.
  Elapsed realtime bars will recalculate as historical bars, i.e., using intrabar inspection, and the realtime bar's calculations will reset.
  When the script recalculates elapsed realtime bars as historical bars, the values on those bars will change, which means the script repaints in those conditions.
 — When the indicator first calculates on a chart containing an incomplete realtime bar, it will count ALL the existing volume​ on the bar as Buy or Sell volume​,
  depending on the polarity of the bar at that point. This will skew calculations for that first bar. Scripts have no access to the history of a realtime bar's previous updates,
  and intrabar inspection cannot be used on realtime bars, so this is the only to go about this.
 — Even if alerts only trigger upon confirmation of their conditions after the realtime bar closes, they are repainting alerts
  because they would perhaps not have calculated the same way using intrabar inspection.
 — On markets like stocks that often have different EOD​ and intraday feeds and volume​ information,
  the volume's scale may not be the same for the realtime bar if your chart is at 1D, for example,
  and the indicator is using an intraday timeframe to calculate on historical bars.
 — Any chart timeframe can be used in realtime mode, but plots that include moving averages in their calculations may require many elapsed realtime bars before they can calculate.
  You might prefer drastically reducing the periods of the moving averages, or using the volume​ columns mode, which displays instant values, instead of the line.

Volume Delta Balances
This indicator uses a variety of methods to evaluate five volume​ delta balances and derive other values from those balances. The five balances are:
1 — On Bar Balance: This is the only balance using instant values; it is simply the subtraction of the Sell volume​ from the Buy volume​ on the bar.
2 — Average Balance: Calculates a distinct EMA for both the Buy and Sell volumes, and subtracts the Sell EMA from the Buy EMA .
3 — Momentum Balance: Starts by calculating, separately for both Buy and Sell volumes, the difference between the same EMAs used in "Average Balance" and
  an SMA of double the period used for the "Average Balance" EMAs. The difference for the Sell side is subtracted from the difference for the Buy side,
  and an RSI of that value is calculated and brought over the −50/+50 scale.
4 — Relative Balance: The reference values used in the calculation are the Buy and Sell EMAs used in the "Average Balance".
  From those, we calculate two intermediate values using how much the instant Buy and Sell volumes on the bar exceed their respective EMA — but with a twist.
  If the bar's Buy volume​ does not exceed the EMA of Buy volume​, a zero value is used. The same goes for the Sell volume​ with the EMA of Sell volume​.
  Once we have our two intermediate values for the Buy and Sell volumes exceeding their respective MA, we subtract them. The final "Relative Balance" value is an ALMA of that subtraction.
  The rationale behind using zero values when the bar's Buy/Sell volume​ does not exceed its EMA is to only take into account the more significant volume​.
  If both instant volume​ values exceed their MA, then the difference between the two is the signal's value.
  The signal is called "relative" because the intermediate values are the difference between the instant Buy/Sell volumes and their respective MA.
  This balance flatlines when the bar's Buy/Sell volumes do not exceed their EMAs, which makes it useful to spot areas where trader interest dwindles, such as consolidations.
  The smaller the period of the final value's ALMA , the more easily you will see the balance flatline. These flat zones should be considered no-trade zones.
5 — Percent Balance: This balance is the ALMA of the ratio of the "On Bar Balance" value, i.e., the volume​ delta balance on the bar (which can be positive or negative),
  over the total volume for that bar.

From the balances and marker conditions, two more values are calculated:
1 — Marker Bias: It sums the up/down (+1/‒1) occurrences of the markers 1 to 4 over a period you define, so it ranges from −4 to +4, times the period.
  Its calculation will depend on the modes used to calculate markers 3 and 4.
2 — Combined Balances: This is the sum of the bull/bear (+1/−1) states of each of the five balances, so it ranges from −5 to +5.


The indicator has two main modes of operation: Columns and Line.

• In Columns mode you can display stacked Buy/Sell volume​ columns.
• The buy section always appears above the centerline, the sell section below.
• The top and bottom sections can be colored independently using eight different methods.
• The EMAs of the Buy/Sell values can be displayed (these are the same EMAs used to calculate the "Average Balance").

• Displays one of seven signals: the five balances or one of two complementary values, i.e., the "Marker Bias" or the "Combined Balances".
• You can color the line and its fill using independent calculation modes to pack more information in the display.
 You can thus appraise the state of 3 different values using the line itself, its color and the color of its fill.
• A "Divergence Levels" feature will use the line to automatically draw expanding levels on divergence events.

Default settings
Using the indicator's default settings, this is the information displayed:
• The line is calculated on the "Average Balance".
• The line's color is determined by the bull/bear state of the "Percent Balance".
• The line's fill gradient is determined by the advances/declines of the "Momentum Balance".
• The orange divergence dots are calculated using discrepancies between the polarity of the "On Bar Balance" and the chart's bar.
• The divergence levels are determined using the line's level when a divergence occurs.
• The background's fill gradient is calculated on advances/declines of the "Marker Bias".
• The chart bars are colored using advances/declines of the "Relative Balance". Divergences are shown in orange.
• The intrabar timeframe is automatically determined from the chart's timeframe so that a minimum of 24 intrabars are used to calculate volume​ delta on historical bars.

The configuration of the marker conditions explained further is what determines the conditions that will trigger alerts created from this script. Note that simply selecting the display of markers does not create alerts. To create an alert on this script, you must use ALT-A from the chart. You can create multiple alerts triggering on different conditions from this same script; simply configure the markers so they define the trigger conditions for each alert before creating the alert. The configuration of the script's inputs is saved with the alert, so from then on you can change them without affecting the alert. Alert messages will mention the marker(s) that triggered the specific alert event. Keep in mind, when creating alerts on small chart timeframes, that discrepancies between alert triggers and markers displayed on your chart are to be expected. This is because the alert and your chart are running two distinct instances of the indicator on different servers and different feeds. Also keep in mind that while alerts only trigger on confirmed conditions, they are calculated using realtime calculation mode, which entails that if you refresh your chart and elapsed realtime bars recalculate as historical bars using intrabar inspection, markers will not appear in the same places they appeared in realtime. So it's important to understand that even though the alert conditions are confirmed when they trigger, these alerts will repaint.

Let's go through the sections of the script's inputs.

The size of the Buy/Sell columns always represents their respective importance on the bar, but the coloring mode for tops and bottoms is independent. The default setup uses a standard coloring mode where the Buy/Sell columns are always in the bull/bear color with a higher intensity for the winning side. Seven other coloring modes allow you to pack more information in the columns. When choosing to color the top columns using a bull/bear gradient on "Average Balance", for example, you will have bull/bear colored tops. In order for the color of the bottom columns to continue to show the instant bar balance, you can then choose the "On Bar Balance — Dual Solid Colors" coloring mode to make those bars the color of the winning side for that bar. You can display the averages of the Buy and Sell columns. If you do, its coloring is controlled through the "Line" and "Line fill" sections below.

Line and Line fill
You can select the calculation mode and the thickness of the line, and independent calculations to determine the line's color and fill.

Zero Line
The zero line can display dots when all five balances are bull/bear.

You first select the detection mode. Divergences occur whenever the up/down direction of the signal does not match the up/down polarity of the bar. Divergences are used in three components of the indicator's visuals: the orange dot, colored chart bars, and to calculate the divergence levels on the line. The divergence levels are dynamic levels that automatically build from the line's values on divergence events. On consecutive divergences, the levels will expand, creating a channel. This implementation of the divergence levels corresponds to my view that divergences indicate anomalies, hesitations, points of uncertainty if you will. It precludes any attempt to identify a directional bias to divergences. Accordingly, the levels merely take note of divergence events and mark those points in time with levels. Traders then have a reference point from which they can evaluate further movement. The bull/bear/neutral colors used to plot the levels are also congruent with this view in that they are determined by the line's position relative to the levels, which is how I think divergences can be put to the most effective use. One of the coloring modes for the line's fill uses advances/declines in the line after divergence events.

The background can show a bull/bear gradient on six different calculations. As with other gradients, you can adjust its brightness to make its importance proportional to how you use it in your analysis.

Chart bars
Chart bars can be colored using seven different methods. You have the option of emptying the body of bars where volume​ does not increase, as does my TLD indicator, and you can choose whether you want to show divergences.

Intrabar Timeframe
This is the intrabar timeframe that will be used to calculate volume​ delta using intrabar inspection on historical bars. You can choose between four modes. The three "Auto-steps" modes calculate, from the chart's timeframe, the intrabar timeframe where the said number of intrabars will make up the dilation of chart bars. Adjustments are made for non-24x7 markets. "Fixed" mode allows you to select the intrabar timeframe you want. Checking the "Show TF" box will display in the lower-right corner the intrabar timeframe used at any given moment. The proper selection of the intrabar timeframe is important. It must achieve maximal granularity to produce precise results while not unduly slowing down calculations, or worse, causing runtime errors. Note that historical depth will vary with the intrabar timeframe. The smaller the timeframe, the shallower historical plots you will be.

Markers appear when the required condition has been confirmed on a closed bar. The configuration of the markers when you create an alert is what determines when the alert will trigger. Five markers are available:
Balances Agreement: All five balances are either bullish​ or bearish​.
Double Bumps: A double bump is two consecutive up/down bars with +/‒ volume​​ delta, and rising Buy/Sell volume​ above its average.
Divergence confirmations: A divergence is confirmed up/down when the chosen balance is up/down on the previous bar when that bar was down/up, and this bar is up/down.
Balance Shifts: These are bull/bear transitions of the selected signal.
Marker Bias Shifts: Marker bias shifts occur when it crosses into bull/bear territory.

Allows control over the periods of the different moving averages used to calculate the balances.

Volume​ Discrepancies
Stock exchanges do not report the same volume​ for intraday and daily (or higher) resolutions. Other variations in how volume​ information is reported can also occur in other markets, namely Forex, where volume​ irregularities can even occur between different intraday timeframes. This will cause discrepancies between the total volume​ on the bar at the chart's timeframe, and the total volume​​ calculated by adding the volume​​ of the intrabars in that bar's dilation. This does not necessarily invalidate the volume​​ delta information calculated from intrabars, but it tells us that we are using partial volume​ data. A mechanism to detect chart vs intrabar timeframe volume​​ discrepancies is provided. It allows you to define a threshold percentage above which the background will indicate a difference has been detected.

Other Settings
You can control here the display of the gray dot reminder on realtime bars, and the display of error messages if you are using a chart timeframe that is not greater than the fixed intrabar timeframe, when you use that mode. Disabling the message can be useful if you only use realtime mode at chart timeframes that do not support intrabar inspection.


On Volume​ Delta
Volume​ is arguably the best complement to interpret price action, and I consider volume​ delta to be the most effective way of processing volume​ information. In periods of low-volatility price consolidations, volume​ will typically also be lower than normal, but slight imbalances in the trend of the buy/sell volume​ balance can sometimes help put early odds on the direction of the break from consolidation. Additionally, the progression of the volume​ imbalance can help determine the proximity of the breakout. I also find volume​ delta and the number of divergences very useful to evaluate the strength of trends. In trends, I am looking for "slow and steady", i.e., relatively low volatility​ and pauses where price action doesn't look like world affairs are being reassessed. In my personal mythology, this type of trend is often more resilient than high-volatility breakouts, especially when volume​ balance confirms the general agreement of traders signaled by the low-volatility usually accompanying this type of trend. The volume​ action on pauses will often help me decide between aggressively taking profits, tightening a stop or going for a longer-term movement. As for reversals, they generally occur in high-volatility areas where entering trades is more expensive and riskier. While the identification of counter-trend reversals fascinates many traders to no end, they represent poor opportunities in my view. Volume​ imbalances often precede reversals, but I prefer to use volume​ delta information to identify the areas following reversals where I can confirm them and make relatively low-cost entries with better odds.

On "Buy/Sell" Volume
Buying or selling volume​ are misnomers, as every unit of volume​ transacted is both bought and sold by two different traders. While this does not keep me from using the terms, there is no such thing as “buy only” or “sell only” volume​. Trader lingo is riddled with peculiarities.

The divergence detection method used here relies on a difference between the direction of a signal and the polarity (up/down) of a chart bar. When using the default "On Bar Balance" to detect divergences, however, only the bar's volume​ delta is used. You may wonder how there can be divergences between buying/selling volume​ information and price movement on one bar. This will sometimes be due to the calculation's shortcomings, but divergences may also occur in instances where because of order book structure, it takes less volume​ to increase the price of an asset than it takes to decrease it. As usual, divergences are points of interest because they reveal imbalances, which may or may not become turning points. To your pattern-hungry brain, the divergences displayed by this indicator will — as they do on other indicators — appear to often indicate turnarounds. My opinion is that reality is generally quite sobering and I have no reliable information that would tend to prove otherwise. Exercise caution when using them. Consequently, I do not share the overwhelming enthusiasm of traders in identifying bullish​/bearish​ divergences. For me, the best course of action when a divergence occurs is to wait and see what happens from there. That is the rationale underlying how my divergence levels work; they take note of a signal's level when a divergence occurs, and it's the signal's behavior from that point on that determines if the post-divergence action is bullish​/bearish​.

In "The Bed of Procrustes", Nassim Nicholas Taleb writes: To bankrupt a fool, give him information. This indicator can display lots of information. While learning to use a new indicator inevitably requires an adaptation period where we put it through its paces and try out all its options, once you have become used to it and decide to adopt it, rigorously eliminate the components you don't use and configure the remaining ones so their visual prominence reflects their relative importance in your analysis. I tried to provide flexible options for traders to control this indicator's visuals for that exact reason — not for window dressing.


• This script uses a special characteristic of the `security()` function allowing the inspection of intrabars — which is not officially supported by TradingView.
 It has the advantage of permitting a more robust calculation of volume​ delta than other methods on historical bars, but also has its limits.
• Intrabar inspection only works on some chart timeframes: 3, 5, 10, 15 and 30 minutes, 1, 2, 3, 4, 6, and 12 hours, 1 day, 1 week and 1 month.
 The script’s code can be modified to run on other resolutions.
• When the difference between the chart’s timeframe and the intrabar timeframe is too great, runtime errors will occur. The Auto-Steps selection mechanisms should avoid this.
• All volume​ is not created equally. Its source, components, quality and reliability will vary considerably with sectors and instruments.
 The higher the quality, the more reliably volume​ delta information can be used to guide your decisions.
 You should make it your responsibility to understand the volume​ information provided in the data feeds you use. It will help you make the most of volume​ delta.


For traders
• The Data Window shows key values for the indicator.
• While this indicator displays some of the same information calculated in my Delta Volume Columns,
 I have elected to make it a separate publication so that traders continue to have a simpler alternative available to them. Both code bases will continue to evolve separately.
• All gradients used in this indicator determine their brightness intensities using advances/declines in the signal—not their relative position in a pre-determined scale.
• Volume​ delta being relative, by nature, it is particularly well-suited to Forex markets, as it filters out quite elegantly the cyclical volume​ data characterizing the sector.

If you are interested in volume​ delta, consider having a look at my other "Delta Volume" indicators:
Delta Volume Realtime Action displays realtime volume​ delta and tick information on the chart.
Delta Volume Candles builds volume​​ delta candles on the chart.
Delta Volume Columns is a simpler version of this indicator.

For coders
• I use the `f_c_gradientRelativePro()` from the PineCoders Color Gradient Framework to build my gradients.
 This function has the advantage of allowing begin/end colors for both the bull and bear colors. It also allows us to define the number of steps allowed for each gradient.
 I use this to modulate the gradients so they perform optimally on the combination of the signal used to calculate advances/declines,
 but also the nature of the visual component the gradient applies to. I use fewer steps for choppy signals and when the gradient is used on discrete visual components
 such as volume​ columns or chart bars.
• I use the PineCoders Coding Conventions for Pine to write my scripts.
• I used functions modified from the PineCoders MTF Selection Framework for the selection of timeframes.


— The devs from TradingView's Pine and other teams, and the PineCoders who collaborate with them. They are doing amazing work,
 and much of what this indicator does could not be done without their recent improvements to Pine.
— A guy called Kuan who commented on a Backtest Rookies presentation of their Volume Profile indicator using a `for` loop.
 This indicator started from the intrabar inspection technique illustrated in Kuan's snippet.
theheirophant, my partner in the exploration of the sometimes weird abysses of `security()`’s behavior at intrabar timeframes.
midtownsk8rguy, my brilliant companion in mining the depths of Pine graphics.
Versionshinweise: v1.1: Updated comments.
Versionshinweise: v1.2: Cosmetic fixes and streamlining of comments.
Versionshinweise: v1.3:
— I improved the Auto-Steps intrabar resolution logic. The 2 Auto-Steps modes now calculate the intrabar resolution to guarantee a minimum of 12 or 24 intrabars. The default is 24. Additionally, the logic takes into account whether your chart is running on conventional or 24/7 markets, modulating the intrabar resolution as needed so the minimum required quantity of intrabars is used.
— I brought down the default period for the Volume Balance Averages from 100 to 50.
— Fixed a minor oversight that caused divergence lines to plot in the realtime bar.

This indicator has become a mainstay on my charts. I like to use it with my Bar Balance, as that indicator only looks at price.

Always manage risk first. If you are learning, do not let the inevitable costs of learning ruin you. Make the smallest bets your broker/exchange will allow, so you can lose on hundreds or thousands of trades over a few years and still be able to trade and quietly focus on learning. Record EVERYTHING: your numbers, your thoughts, your experiences and your feelings. As Lionel Shriver writes: "Be leery of orthodoxy. Hold back from shared cultural enthusiasms." Be your own trader. Read others if you want, but figure out things for yourself. When working, sit straight and relaxed. Breathe! Be both ruthless and gentle with yourself. Go slow. Know your tools inside and out. Relentlessly keep your sights on the big picture. Have fun.
Versionshinweise: v5.0
This update uses the new color functions in Pine to calculate the gradients one can configure on many components of the indicator.
The script runs faster, but the intrabar inspection still requires some time to calculate.
This also resolves the recent issue where the indicator no longer worked because it exceeded the maximum number of plots allowed.
Another upcoming revision will allow the script to calculate volume​ delta and trigger alerts in realtime.
In the meantime, my Tape indicator can be used to calculate volume​ delta in realtime.
Versionshinweise: v6
This is a significant release:
• Added realtime volume​ delta calculation.
• Alerts can now be used with the script.
• The number of intrabars found at the intrabar TF under each historical chart bar is displayed in the Data Window.
 When using realtime mode, the number of realtime updates for the bar is displayed instead.
• Eliminated the notion of neutral volume​, so volume​ goes in either Buy or Sell slots now. When there is no price movement,
 the direction of the last move is used to determine the polarity of delta volume​, whether in intrabar inspection or realtime mode.
• Overhauled the script's inputs.
• Refactored the color code so brightness control was restored in inputs for all the colored components in the script's visuals.
• Refactored the intrabar inspection mechanism so it runs faster.
• Added support for the 3H chart timeframe.
• Added a third, more precise Auto-Steps calculation mode for the intrabar timeframe which uses approximately 50 intrabars.
• Added a new color calculation mode for the line fill. It uses the advances/declines of the line from the average between the current hi/lo divergence levels.
• Added a "Balance Relative" calculation, which is now used as the default color calculation mode for chart bars.
• Added a "Balance Percent" calculation.
• When coloring chart bars, divergences can be displayed, which is the default setting.
• The calculation of divergences has changed: a divergence now occurs when the direction of the selected signal on a bar diverges from that bar's polarity.
• The script's description was updated. Please be sure to read about the details there.
Open-source Skript

Ganz im Sinne von TradingView hat der Autor dieses Skripts es als Open-Source veröffentlicht, damit Trader es verstehen und überprüfen können. Ein Hoch auf den Autor! Sie können es kostenlos verwenden, aber die Wiederverwendung dieses Codes in einer Publikation unterliegt den Hausregeln. Sie können das Skript den Favoriten hinzufügen, um es auf dem Chart zu verwenden.

Möchten Sie dieses Skript auf einem Chart verwenden?
"The stock market is a device for transferring money from the impatient to the patient."
— Buffet

Tools and ideas for all Pine coders: