This indicator calculates relative , which is the ratio of present over an average of past .
It offers two calculation modes, both using a time reference as an anchor.
The simplest way to calculate relative is by using the ratio of a bar's over a of the last n values.
This indicator uses one of two, more subtle ways to calculate both values of the relative ratio: current volume:past volume.
The two calculations modes are:
1 — Cumulate from Beginning of TF to Current Bar where:
current volume = the cumulative since the beginning of the timeframe unit, and
past volume = the mean of during that same relative period of time in the past n timeframe units.
2 — Point-to-Point Bars at Same Offset from Beginning of TF where:
current volume = the on a single chart bar, and
past volume = the mean of values from that same relative bar in time from the past n timeframe units.
Timeframe units can be defined in three different ways:
1 — Using Auto-steps, where the timeframe unit automatically adjusts to the timeframe used on the chart:
— A 1 min timeframe unit will be used on 1sec charts,
— 1H will be used for charts at 1min and less,
— 1D will be used for other intraday chart timeframes,
— 1W will be used for 1D charts,
— 1M will be used for charts at less than 1M,
— 1Y will be used for charts at greater or equal than 1M.
2 — As a fixed timeframe that you define.
3 — By time of day (for intraday chart timeframes only), which you also define. If you use non-intraday chart timeframes in this mode, the indicator will switch to Auto-steps.
A relative value of 1.0 indicates that current volume is equal to the mean of past volume, but how can we determine what constitutes a high relative value?
The traditional way is to settle for an arbitrary threshold, with 2.0 often used to indicate that relative is worthy of attention.
We wanted to provide traders with a contextual method of calculating threshold values, so in addition to the conventional fixed threshold value,
this indicator includes two methods of calculating a threshold channel on past relative values:
1 — Using the standard deviation of relative over a fixed lookback.
2 — Using the highs/lows of relative over a variable lookback.
Channels calculated on relative provide meta-relativity, if you will, as they are relative values of relative .
Controls in the "Display" section of inputs determine what is visible in the indicator's pane. The next "Settings" section is where you configure the parameters used in the calculations. The "Column Coloring Conditions" section controls the color of the columns, which you will see in three of the five display modes available. Whether columns are plotted or not, the coloring conditions also determine when markers appear, if you have chosen to show the markers in the "Display" section. The presence of markers is what triggers the alerts configured on this indicator. Finally, the "Colors" section of inputs allows you to control the color of the indicator's visual components.
Five display modes are available:
• Current Columns: shows columns of current volume, with past volume displayed as an outlined column.
• Relative Columns: shows relative as a column.
• Relative Columns With Average: shows relative as a column, with the average of relative .
• Directional Relative Average: shows a line calculated using the average of +/- values of relative .
The positive value of relative is used on up bars; its negative value on down bars.
• Relative Average: shows the average of relative .
A is used to calculate the average used in the three last display modes.
You can also control the display of:
• The value or relative , when in the first three display modes. Only the last 500 values will be shown.
• Timeframe transitions, shown in the background.
• A reminder of the active timeframe unit, which appears to the right of the indicator's last bar.
• The threshold used, which can be a fixed value or a channel, as determined in the next "Settings" section of inputs.
• Up/Down markers, which appear on transitions of the color of the columns (determined by coloring conditions), which in turn control when alerts are triggered.
• Conditions of high .
Use this section of inputs to change:
• Calculation mode: this is where you select one of this indicator's two calculation modes for current volume and past volume, as explained in the "Concepts" section.
• Past Lookback in TF units: the quantity of timeframe units used in the calculation of past volume.
• Define Timeframes Units Using: the mode used to determine what one timeframe unit is. Note that when using a fixed timeframe, it must be higher than the chart's timeframe.
Also, note that time of day timeframe units only work on intraday chart timeframes.
• Threshold Mode: Five different modes can be selected:
— Fixed Value: You can define the value using the "Fixed Threshold" field below. The default value is 2.0.
— Standard Deviation Channel From Fixed Lookback: This is a channel calculated using the of relative
(so not the used elsewhere in the indicator), plus/minus the standard deviation multiplied by a user-defined factor.
The lookback used is the value of the "Channel Lookback" field. Its default is 100.
— High/Low Channel From Beginning of TF: in this mode, the High/Low values reset at the beginning of each timeframe unit.
— High/Low Channel From Beginning of Past Lookback: in this mode, the High/Low values start from the farthest point back where we are calculating past volume,
which is determined by the combination of timeframe units and the "Past Lookback in TF units" value.
— High/Low Channel From Fixed Lookback: In this mode the lookback is fixed. You can define the value using the "Channel Lookback" field. The default value is 100.
• Period of RelVol Moving Average: the period of the used in the "Directional Relative Average" and the "Relative Average".
• High Volatility is defined using fast and slow ATR periods, so this represents the of price.
Volatility is considered to be high when the fast ATR value is greater than its slow value. can be used as a filter in the column coloring conditions.
Column Coloring Conditions
• Eight different conditions can be turned on or off to determine the color of the columns. All "ON" conditions must be met to determine a high/low state of relative ,
or, in the case of directional relative , a bull/bear state.
• A state can also be used to filter the conditions.
• When the coloring conditions and the filter do not allow for a high/low state to be determined, the neutral color is used.
• Transitions of the color of the columns determined by coloring conditions are used to plot the up/down markers, which in turn control when alerts are triggered.
• You can define your own colors for all of the oscillator's plots.
• The default colors will perform well on light or dark chart backgrounds.
• An alert can be defined for the script. The alert will trigger whenever an up/down marker appears in the indicator's display.
The particular combination of coloring conditions and the display settings for up/down markers when you create the alert will determine which conditions trigger the alert.
After alerts are created, subsequent changes to the conditions controlling the display of markers will not affect existing alerts.
• By configuring the script's inputs in different ways before you create your alerts, you can create multiple, functionally distinct alerts from this script.
When creating multiple alerts, it is useful to include in the alert's message a reminder of the particular conditions you used for each alert.
• As is usually the case, alerts triggering "Once Per Bar Close" will prevent repainting.
Error messages will appear at the end of the chart upon the following conditions:
• When the combination of the timeframe units used and the "Past Lookback in TF units" value create a lookback that is greater than 5000 bars.
The lookback will then be recalculated to a value such that a runtime error does not occur.
• If the chart's timeframe is higher than the timeframe units. This error cannot occur when using Auto-steps to calculate timeframe units.
• If relative cannot be calculated, for example, when no data is available for the chart's symbol.
• When the threshold of relative is configured to be visible but the indicator's scale does not allow it to be visible (in "Current Columns" display mode).
The chart shown here uses the following display modes: "Current Columns", "Relative Columns With Average", "Directional Relative Average" and "Relative Average". The last one also shows the threshold channel in standard deviation mode, and the TF Unit reminder to the right, in red.
, like price, is a value with a market-dependent scale. The only valid reference for being its past values, any improvement in the way past is calculated thus represents a potential opportunity to traders. Relative calculated as it is here can help traders extract useful information from markets in many circumstances, markets with cyclical such as Forex being one, obvious case. The relative nature of the values calculated by this indicator also make it a natural fit for cross-market and cross-sector analysis, or to identify behavioral changes in the different contracts of the same market. Relative can also be put to more exotic uses, such as in evaluating changes in the popularity of exchanges.
Relative alone has no directional bias. While higher relative values always indicate higher trading activity, that activity does not necessarily translate into significant price movement. In a tightly fought battle between buyers and sellers, you could theoretically have very large for many bars, with no change whatsoever in bid/ask prices. This of course, is unlikely to happen in reality, and so traders are justified in considering high relative values as indicating periods where more attention is required, because imbalances in the strength of buying/selling power during high-volume trading periods can amplify price variations, providing traders with the generally useful gift of .
Be sure to give the "Directional Relative Average" a try. Contrary to the always-positive ratio widely used in this indicator, the "Directional Relative Average" produces a value able to determine a / bias for relative .
Note that realtime bars must be complete for the relative value to be confirmed. Values calculated on historical or elapsed realtime bars will not recalculate unless historical data changes.
Finally, as with all indicators using information, keep in mind that some exchanges/brokers supply different feeds for intraday and daily data, and the data on both feeds can sometimes vary quite a bit.
Our script was written using the PineCoders Coding Conventions for Pine.
The description was formatted using the techniques explained in the How We Write and Format Script Descriptions PineCoders publication.
Bits and pieces of code were lifted from the MTF Selection Framework and the MTF Oscillator Framework, also by PineCoders.
Thanks to dgtrd for suggesting to add the channel using standard deviation.
Thanks to adolgov for helpful suggestions on calculations and visuals.
Look first. Then leap.
Made a few cosmetic changes. No functional changes.
Read more about the new tools and features we're building for you: https://www.tradingview.com/blog/en/
Nello spirito di condivisione promosso da TradingView, l'autore (al quale vanno i nostri ringraziamenti) ha deciso di pubblicare questo script in modalità open-source, così che chiunque possa comprenderlo e testarlo. Puoi utilizzarlo gratuitamente, ma il riutilizzo del codice è subordinato al rispetto del Regolamento. Per aggiungerlo al grafico, mettilo tra i preferiti.
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.