LucF

Delta Volume Columns [LucF]

1587 views
169
1587 12
Displays delta volume columns using intrabar volume information. Each volume column is divided into three sections: buying, selling and neutral volume . Volume for each section is determined from the volume and price movement of each intrabar at a user-selected lower resolution.

Features include:
- Choice of color themes for either dark or light chart backgrounds
- Delta volume columns
- Volume Balance displayed as the difference between the MAs of buying and selling volume
- Display of divergences between a bar’s volume balance and the bar’s price movement (example: buying volume > selling volume but close < open). Divergences can be shown in 2 different color schemes (including green/red showing a tentative direction), on volume columns and/or on chart bars
- Display of bar by bar volume balance with highlighting of above average volume
- Display of the usual total volume MA
- Choice of the lower resolution used to retrieve intrabar information
- Alerts configurable on any combination of the markers, with control over long/short direction
- Choice of 3 different markers:
1. Double bumps: two consecutive bars where buying or selling volume is in the same direction and where volume > volume MA
2. Divergence confirmations: direction of the price bar following a price/volume balance divergence
3. Volume balance shifts: zero level crossings of the volume balance MA delta

The chart shows the two main modes of display:
- Top pane: shows the stacked volume columns with divergences in orange and the flattened volume balance MAs delta at the bottom of the volume columns. This volume balance is the same shown in the bottom pane. The top pane also shows the instant volume balance strip above the volume columns. The strip’s colors show which of the buying or selling volume was greater, and colors are brighter if the total volume was above the total volume MA.
- Bottom pane: shows the volume balance MAs delta with markers 1 and 2. Given that this graphic has no price momentum component, I find quite eerie how it often looks like a momentum-based signal.
The default 5 minute intrabar resolution is used in combination with the weekly chart, which is excessive.


This script uses a special characteristic of the security() function’s behavior when it is sent to a resolution lower than the chart’s resolution. Details are given in the script’s comments. This method has the advantage of working under more circumstances than some of the other loop-based methods, but it also has its limits.


IMPORTANT
This is what you need to know:
- The method used does not work on the realtime bar—only on historical bars. Consequently, the volume column shown on the realtime bar is a normal volume column plotted in green or red, following price movement. The column will only show delta volume information after it closes and becomes a historical bar.
- The indicator only works on some chart resolutions: 5, 10, 15 and 30 minutes, 1, 2, 4, 6, and 12 hours, 1 day, 1 week and 1 month. The script’s code can be modified to run on other resolutions, but chart resolutions must be divisible by the lower resolution used for intrabars.
- Intrabar resolutions can be selected from 1, 5, 15, 30, 45 minutes, 1, 2, 3, 4 hours, 1 day, 1 week and 1 month. The intrabar resolution must of course be smaller than the chart’s resolution.
- Contrary to my other indicators where alerts must be configured to trigger “Once Per Bar Close” in order to avoid false triggers (or repainting), all this indicator’s alerts are designed to trigger using previous bar information since the indicator’s calculations in the realtime bar are not exact. Markers are not plotted with a negative offset; they appear at the beginning of the realtime bar following confirmation of the marker’s condition on the previous bar. Alerts for this indicator should thus be configured to trigger “Once Per Bar” so they trigger at the beginning of the realtime bar. Note that the penalty is not that great, as it is simply the instant between the close of the previous realtime bar and the opening of the next. The advantage of using this technique is that the indicator does not repaint; a marker that appears at the beginning of the realtime bar will never disappear.
- The script only plots information that is reliable in the realtime bar, i.e., total volume and markers. All other plots are set to n/a to prevent misleading traders.
- When the difference between the chart’s resolution and the lower resolution is too important, volume columns will not calculate for all bars in the dataset.

On Delta Volume
Buying or selling volume are misnomers, as every unit of volume transacted is both bought and sold by 2 different traders. There is no such thing as “buy only” or “sell only” volume , but trader lingo is riddled with original fabulations.
Without access to order book information, traders work with the assumption that when price moves up during a bar, there was more buying pressure than selling pressure. The built-in volume indicator available on TradingView uses this logic to color the volume columns green or red. While this script’s numbers are more precise because it analyses a number of intrabars to calculate its information, it uses the exact same imperfect logic to calculate its buying/selling/neutral sections.
Until Pine scripts can have access to how much volume was transacted at the bid/ask prices, our so-called buying/selling volume information will always be a mere proxy.

Divergences
You may wonder how there can be divergences between buying/selling volume information and price movement. This will sometimes be due to the methodology’s shortcomings we have just discussed, 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. I do not share the overwhelming enthusiasm traders have for divergences. To your pattern-hungry brain, the orange bars this indicator shows on chart will—as divergences on other indicators do–appear to often indicate turnarounds. My opinion is that reality is generally quite sobering, as many who have tried building automated rules based on divergences will tell you. I do not have hard numbers on the lack of performance of divergences—only many failed attempts to make them perform, which a few experienced strategy modelers I know share with me. Please don’t try to read too much into them. While they look great on past data, I find they are often difficult to use in realtime to make bets with good odds.

Thanks to:
- A guy called Kuan who commented on a Backtest Rookies presentation of an intrabar delta volume indicator using a for loop. The heart of “my” indicator is code borrowed from Kuan; I just built a hopefully useful wrapper around it.
- @theheirophant, my partner in the exploration of the sometimes weird abysses of security()’s behavior at lower resolutions.
Release Notes: Updated comments and improved display on unsupported chart resolutions.
Release Notes: Disabled alerts. While plotted markers are reliable, alerts configured to trigger "Once Per Bar" are not.
Remove from Favorite Scripts Add to Favorite Scripts
"The stock market is a device for transferring money from the impatient to the patient." — Buffet
Excellent! Do you think this is a good alternative to that Mbox cumulative delta indicator?
Reply
LucF AlexMihail
@AlexMihail, Sry but I've never used it, so have no idea.
Reply
@LucF, https://mboxwave.com/mcumulativedelta-indicator

How would one get this indicator to perform more like this?
Reply
LucF AlexMihail
@AlexMihail, Yes, I know of it but never used it. From what I can tell it does, that indie is running on platforms with tick data and access to bid/ask volume, so because of the reasons I explain in the description, it can't be done the same way here, on TV. With this caveat in mind, there are a few ways to obtain some of the same info on TV. That indie's histogram is similar to the Volume Balance MA delta from this indicator. As complements in a Pane, you can look up my mod of LazyBear's Weis Wave and my Ord Volume. For on chart info, you can use VPSV, the built-in Volume Profile by Session, which doesn't work the same way the mbox does at all, but provides some of its info in an indirect way, by showing volume/price points of control. It will be much faster that some of the other Pine indies on TV trying to do the same thing.
Reply
LucF AlexMihail
@AlexMihail, I could use the same info this script calculates and render it on a chart in a way that looks like the mbox thing, but it wouldn't improve the exactness of the underlying numbers. Could be a worthwhile future project, but I already have 2 in the queue here and another for PineCoders, and I'm a very slow coder ) so don't think it will be for soon, but I will keep this in mind.
Reply
I received confirmation from TV that the use of security() in this way seems to be causing a problem with triggering of alerts. Need to wait for a fix before re-enabling alerts, so please do not use the alerts until then. I will update.
Reply
Really nice as always! I remember Kuan's code from that article's comments, it is indeed elegant! I do remember needing to do quite a bit of reformatting when I pasted it though lol.

I also share your thoughts and experience with divergence as well. After much testing I've concluded divergence isn't something I would personally rely upon. Keep up the great work!
Reply
LucF allanster
@allanster, Thx for the good words, Allanster. Really appreciate. While also reformatting Kuan's code, I remember thinking: Is it all there, looks like something is missing? So was surprised to see it work, and then it took @theheirophant and me a couple of exchanges here and there over a few months, and finally confirmation from the Pine team (thank you TV Pine gurus!), to be sure of what was going on. Now I just need to have a second look to figure out the alert thing.
Reply
awesome thing for a scalping!!! Thank U very much!
Reply
LucF mrgr888n
@mrgr888n, Happy you find it useful! Thx for taking the time to say so and gl in the markets.
Reply
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing House Rules Moderators Website & Broker Solutions Widgets Charting Solutions Help Center Feature Request Blog & News FAQ Wiki Twitter
Profile Profile Settings Account and Billing TradingView Coins My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out