OPEN-SOURCE SCRIPT

Market Internals (TICK, ADD, VOLD, TRIN, VIX)

已更新
OVERVIEW
This script allows you to perform data transformations on Market Internals, across exchanges, and specify signal parameters, to more easily identify sentiment extremes.

Notable transformations include:
1. Cumulative session values
2. Directional bull-bear Ratios and Percent Differences
3. Data Normalization
4. Noise Reduction

This kind of data interaction is very useful for understanding the relationship between two mutually exclusive metrics, which is the essence of Market Internals: Up vs. Down. Even so, they are not possible with symbol expressions alone. And the kind of symbol expression needed to produce baseline data that can be reliably transformed is opaque to most traders, made worse by the fact that prerequisite symbol expressions themselves are not uniform across symbols. It's very nuanced, and if this last bit was confusing … exactly.

All this to say, rather than forcing that burden onto you, I've baked the baseline symbol expressions into the indicator so: 1) the transform functions consistently ingest the baseline data in the correct format and 2) you don't have to spend time trying to figure it all out. Trading is hard. There's no need to make it harder.


INPUTS

Indicator
Allows you to specify the base Market Internal and Exchange data to use. The list of Market Internals is simplified to their fundamental representation (TICK, ADD, VOLD, TRIN, VIX, ABVD, TKCD), and the list of Exchange data is limited to the most common (NYSE, NASDAQ, All US Stocks). There are also options for basic exchange combinations (Sum or Average of NYSE & NASDAQ).

Mode
Short for "Plot Mode", this is where you specify the bars style (Candles, Bars, Line, Circles, Columns) and the source value (used for single value plots and plot color changes).

Scale
This is the first and second data transformation grouped together. The default is to show the origin data as it might appear on a chart. You can then specify if each bar should retain it's unique value (Bar Value) or be added to a running total (Cumulative). You can also specify if you would like the data to remain unaltered (Raw) or converted to a directional ratio (Ratio) or a percentage (Percent Diff). These options determine the scale of the plot.

Both Ratio and Percent Diff. convert a given symbol into a positive or negative number, where positive numbers are bullish and negative numbers are bearish.

Ratio will divide Bull values by Bear values, then further divide -1 by the quotient if it is less than 1. For example, if "0.5" was the quotient, the Ratio would be "-2".

Percent Diff. subtracts Bear values from Bull values, then divides that difference by the sum of Bull and Bear values multiplied by 100. If a Bull value was "3" and Bear value was "7", the difference would be "-4", the sum would be "10", and the Percent Diff. would be "-40", as the difference is both bearish and 40% of total.

Ratio Norm. Threshold
This is the third data transformation. While quotients can be less than 1, directional ratios are never less than 1. This can lead to barcode-like artifacts as plots transition between positive and negative values, visually suggesting the change is much larger than it actually is. Normalizing the data can resolve this artifact, but undermines the utility of ratios. If, however, only some of the data is normalized, the artifact can be resolved without jeopardizing its contextual usefulness.

The utility of ratios is how quickly they communicate proportional differences. For example, if one side is twice as big as the other, "2" communicates this efficiently. This necessarily means the numerical value of ratios is worth preserving. Also, below a certain threshold, the utility of ratios is diminished. For example, an equal distribution being represented as 0, 1, 1:1, 50/50, etc. are all equally useful. Thus, there is a threshold, above which we want values to be exact, and below which the utility of linear visual continuity is more important. This setting accounts for that threshold.

When this setting is enabled, a ratio will be normalized to 0 when 1:1, scaled linearly toward the specified threshold when greater than 1:1, and then retain its exact value when the threshold is crossed. For example, with a threshold of "2", 1:1 = 0, 1.5:1 = 1, 2:1 = 2, 3:1 = 3, etc.

With all this in mind, most traders will want to set the ratios threshold at a level where accuracy becomes more important than visual continuity. If this level is unknown, "2" is a good baseline.

Reset cumulative total with each new session
Cumulative totals can be retained indefinitely or be reset each session. When enabled, each session has its own cumulative total. When disabled, the cumulative total is maintained indefinitely.

Show Signal Ranges
Because everything in this script is designed to make identifying sentiment extremes easier, an obvious inclusion would be to not only display ranges that are considered extreme for each Market Internal, but to also change the color of the plot when it is within, or beyond, that range. That is exactly what this setting does.

Override Max & Min
While the min-max signal levels have reasonable defaults for each symbol and transformation type, the Override Max and Override Min options allow you to … (wait for it) … override the max … and min … signal levels. This may be useful should you find a different level to be more suitable for your exact configuration.

Reduce Noise
This is the fourth data transformation. While the previous Ratio Norm. Threshold linearly stretches values between a threshold and 0, this setting will exponentially squash values closer to 0 if below the lower signal level.

The purpose of this is to compress data below the signal range, then amplify it as it approaches the signal level. If we are trying to identify extremes (the signal), minimizing values that are not extreme (the noise) can help us visually focus on what matters.

Always keep both signal zones visible
Some traders like to zoom in close to the bars. Others prefer to keep a wider focus. For those that like to zoom in, if both signals were always visible, the bar values can appear squashed and difficult to discern. For those that keep a wider focus, if both signals were not always visible, it's possible to lose context if a signal zone is vertically beyond the pane. This setting allows you to decide which scenario is best for you.

Plot Colors
These define the default color, within signal color, and beyond signal color for Bullish and Bearish directions.

Plot colors should be relative to zero
When enabled, the plot will inherit Bullish colors when above zero and Bearish colors when below zero. When disabled and Directional Colors are enabled (below), the plot will inherit the default Bullish color when rising, and the default Bearish color when falling. Otherwise, the plot will use the default Bullish color for all directions.

Directional colors
When the plot colors should be relative to zero (above), this changes the opacity of a bars color if moving toward zero, where "100" percent is the full value of the original color and "0" is transparent. When the plot colors are NOT relative to zero, the plot will inherit Bullish colors when rising and Bearish colors when falling.

Differentiate RTH from ETH
Market Internal data is typically only available during regular trading hours. When this setting is enabled, the background color of the indicator will change as a reminder that data is not available outside regular trading hours (RTH), if the chart is showing electronic trading hours (ETH).

Show zero line
Similar to always keeping signal zones visible (further up), some traders prefer zooming in while others prefer a wider context. This setting allows you to specify the visibility of the zero line to best suit your trading style.

Linear Regression
Polynomial regressions are great for capturing non-linear patterns in data. TradingView offers a "linear regression curve", which this script is using as a substitute. If you're unfamiliar with either term, think of this like a better moving average.

Symbol
While the Market Internal symbol will display in the status line of the indicator, the status line can be small and require more than a quick glance to read properly. Enabling this setting allows you to specify if / where / how the symbol should display on the indicator to make distinguishing between Market Internals more efficient.

Speaking of symbols, this indicator is designed for, and limited to, the following …

TICK - The TICK subtracts the total number of stocks making a downtick from the total number of stocks making an uptick.

ADD - The Advance Decline Difference subtracts the total number of stocks below yesterdays close from the total number of stocks above yesterdays close.

VOLD - The Volume Difference subtracts the total declining volume from the total advancing volume.

TRIN - The Arms Index (aka. Trading Index) divides the ratio of Advancing Stocks / Volume by the ratio of Declining Stocks / Volume. Given the inverse correlation of this index to market movement, when transforming it to a Ratio or Percent Diff., its values are inverted to preserve the bull-bear sentiment of the transformations.

VIX - The CBOE Volatility Index is derived from SPX index option prices, generating a 30-day forward projection of volatility. Given the inverse correlation of this index to market movement, when transforming it to a Ratio or Percent Diff., its values are inverted and normalized to the sessions first bar to preserve the bull-bear sentiment of the transformations. Note: If you do not have a Cboe CGIF subscription, VIX data will be delayed and plot unexpectedly.

ABVD - The Above VWAP Difference is an unofficial index measuring all stocks above VWAP as a percent difference. For the purposes of this indicator (and brevity), TradingViews PPCTABOVEVWAP.US has has been shortened to simply be ABVD.

TKCD - The Tick Cumulative Difference is an unofficial index that subtracts the total number of market downticks from the total number of market upticks. Where "the TICK" (further up) is a measurement of stocks ticking up and down, TKCD is a measurement of the ticks themselves. For the purposes of this indicator (and brevity), TradingViews UUPTKS.US and DDNTKS.US symbols have been shorted to simply be TKCD.


INSPIRATION
I recently made an indicator automatically identifying / drawing daily percentage levels, based on 4 assumptions. One of these assumptions is about trend days. While trend days do not represent the majority of days, they can have big moves worth understanding, for both capitalization and risk mitigation.

To this end, I discovered:
• Article by Linda Bradford Raschke about Capturing Trend Days.
• Video of Garrett Drinon about Trend Day Trading.
• Videos of Ryan Trost about How To Use ADD and TICK.
• Article by Jason Ruchel about Overview of Key Market Internals.
• Including links to resources outside of TradingView violates the House Rules, but they're not hard to find, if interested.

These discoveries inspired me adopt the underlying symbols in my own trading. I also found myself wanting to make using them easier, the net result being this script.

While coding everything, I also discovered a few symbols I believe warrant serious consideration. Specifically the PPCTABOVEVWAP.US symbols and the UUPTKS.US / DDNTKS.US symbols (referenced as ABVD and TKCD in this indicator, for brevity). I found transforming ABVD or TKCD into a Ratio or Percent Diff. to be an incredibly useful and worthy inclusion.

ABVD is a Market Breadth cousin to Brian Shannon's work, and TKCD is like the 3rd dimension of the TICKs geometry. Enjoy.
發布通知
• Added script URL to top comment.
發布通知
• Minor cleanup in the code comments.
發布通知
Added: BATD, an unofficial index that measures the difference between the number of trades at the bid vs. the ask.
Bug Fix: Some plots were not displaying as expected after TradingView updated their platform; now resolved.
發布通知
Updating indicator preview. No code changes.
Breadth IndicatorssentimentTrend Analysis

開源腳本

在真正的TradingView精神中,這個腳本的作者以開源的方式發佈,這樣交易員可以理解和驗證它。請向作者致敬!您可以免費使用它,但在出版物中再次使用這段程式碼將受到網站規則的約束。 您可以收藏它以在圖表上使用。

想在圖表上使用此腳本?

免責聲明