- Choice of color themes for either dark or light chart backgrounds
- Delta columns
- Balance displayed as the difference between the MAs of buying and selling
- Display of divergences between a bar’s balance and the bar’s price movement (example: buying > selling but close < open). Divergences can be shown in 2 different color schemes (including green/red showing a tentative direction), on columns and/or on chart bars
- Display of bar by bar balance with highlighting of above average
- Display of the usual total 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 is in the same direction and where > MA
2. Divergence confirmations: direction of the price bar following a price/volume balance divergence
3. balance shifts: zero level crossings of the balance MA delta
The chart shows the two main modes of display:
- Top pane: shows the stacked columns with divergences in orange and the flattened balance MAs delta at the bottom of the columns. This balance is the same shown in the bottom pane. The top pane also shows the instant balance strip above the columns. The strip’s colors show which of the buying or selling was greater, and colors are brighter if the total was above the total MA.
- Bottom pane: shows the 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.
This is what you need to know:
- The method used does not work on the realtime bar—only on historical bars. Consequently, the column shown on the realtime bar is a normal column plotted in green or red, following price movement. The column will only show delta 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 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, columns will not calculate for all bars in the dataset.
On Delta Volume
Buying or selling are misnomers, as every unit of transacted is both bought and sold by 2 different traders. There is no such thing as “buy only” or “sell only” , 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 indicator available on TradingView uses this logic to color the 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 was transacted at the bid/ask prices, our so-called buying/selling information will always be a mere proxy.
You may wonder how there can be divergences between buying/selling 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 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.
- A guy called Kuan who commented on a Backtest Rookies presentation of an intrabar delta 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.
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!