This script determines the proportion of and candles in a given sample size. It will produce an oscillator that fluctuates between 100 and -100, where values > 0 indicate more candles in the sample and values < 0 indicate more candles in the sample. Data produced by this oscillator is normalized around the 50% value, meaning that an even 50/50 split between and candles makes this oscillator produce 0; this oscillator indirectly represents the percent proportion of and candles in the sample (see HOW TO USE/INTERPRETATION OF DATA).
It has two overarching settings: 'classic' and 'range'.
This script will cover concepts related to analysis, volumetric analysis, and lower timeframes.
Candlestick Analysis - The idea behind this script is to solely look at the themselves and derive information from them in a given sample. It separates candles into two categories, (close > open) and (close < open).
If the indicator's setting is set to 'classic', the size of candles do not matter and all are assigned a value of 1 or 0.
If the indicator's setting is set to 'range', specific candle ranges modify the proportion of / values. candle values include all candles in the set from their lows to the close, plus the lower wicks of all candles. candle values include all candles in the set from their highs to the close, plus the upper wicks of all candles.
Volumetric Analysis - One of this script's features allows the user to modify the and candle proportions by its 'weight' determined by its compared to the sample set's total . Volumetric analysis for the 'range' setting are more complex than 'classic' as described below.
Lower Timeframes - For volumetric analysis to be done on candle wicks, there needed to be a way to determine how much had occurred in the wick by itself to find the weight of upper and lower wicks. To accomplish this, I employed PineScrypt's request.security_lower_tf function to grab OHLC values of lower timeframe candles (as well as ) to determine how much had occurred in the wicks of the chart resolution's candle. The default OHLC values used here are the lows for upper wicks and highs for lower wicks. These OHLC values are then compared to the chart resolution candle's close to determine if the of that lower timeframe candle should be shifted to the wick weight or stay in the current weight of that candle. The reason 'low' and 'high' are used here is to guarantee that 100% of the of a lower timeframe candle had occurred in the wick of the candle at the current resolution (see LIMITATIONS).
candles will exclude of all lower timeframe candles whose lows were greater than that candle's close. candles will exclude of all lower timeframe candles whose highs were less than that candle's close. These wick volumes are then divided by the of the sample set, and wick sizes are then multiplied by this weight before being added to their specific / sums (lower wicks to and upper wicks to ).
There are 13 inputs for the user to modify the behavior/visual representation of this script.
Sample Length - This determines how many candles are in the sample set to find the proportion of and candles.
Colors and Invert Colors - There are three colors set by the user: a color, neutral color, and color. The oscillator plots two lines, one at 0 and another that represents the proportion of or candles in the sample set (we'll call this the 'signal line'). If the oscillator is above 0, color is used, otherwise. This script generates a gradient to color a filled area between the 0 line and the signal line based on the historical values of the oscillator itself and the signal line. For values, the closer the signal line is to the max (or restricted max described below) that the oscillator has experienced, the more colored toward color the shaded area will be, using the neutral color as a starting point. The same is applied to the values using the color.
There is an additional input to invert the colors so that the color is associated with values and vise-versa.
Calculation Type - This determines the overarching behavior of the oscillator and has two settings:
- Classic - The weight of candles are either 1 if they occurred and 0 if not.
- Range - The weight of candles is determined by the size of specific sections as described in CONCEPTS - Candlestick Analysis.
Volume Weighted - This enables modifying the weights of candles as described in CONCEPTS - Volumetric Analysis and Lower Timeframes based on which Calculation Type is used.
Wick Slice Resolution - This is the lower timeframe resolution that will be used to slice the chart resolution's candle when determining the volumetric weight of wicks. Lower timeframe resolutions like '1 minute' will yield more precise results as they will give more data points to go off of (see LIMITATIONS).
Upper/Lower Wick Source - These two inputs allow the user to select which OHLC values to compare against the chart resolution's candle close when determining which lower timeframe candles will have their volumes associated with the wicks of candles being analyzed at the chart's resolution.
Restrict Min/Max Data and Restriction - This will restrict the maximum and minimum values that will be used for the signal line when comparing its value to previous oscillator values and change how the color gradient is generated for the indicator. Restriction is the number of candles back that will determine these maximum and minimum values.
Display Min/Max Guide - This will plot two lines that are colored the corresponding and colors which follow what the maximum and minimum values are currently for the oscillator.
█ HOW TO USE/INTERPRETATION OF DATA
As mentioned in the OVERVIEW section, this oscillator provides an indirect representation of the percent proportion of or candles in a given sample. If the oscillator reads 80, this does not mean that 80% of all candles in the sample were bullish. To find the percentage of candles that were or , the user needs to perform the following:
50% + ((|oscillator value| / 100) * 50)%
If the oscillator value is negative, the value from above will represent the percentage of candles in the sample. If it is positive, this value represents the percentage of candles in the sample.
Example 1 (oscillator value = 80):
50% + ((|80| / 100) * 50)%
50% + ((0.80) * 50)%
50% + 40% = 90%
90% of the candles in the sample were .
Example 2 (oscillator value = -43):
50% + ((|-43| / 100) * 50)%
50% + ((0.43) * 50)%
50% + 21.5% = 71.5%
71.5% of the candles in the sample were .
An example use of this indicator would be to put in a 'buy' order when its value shows a significant proportion of the sampled candles were , and put in a 'sell' order when a significant proportion of candles were . Potential divergences of this oscillator may also be used to plan trades accordingly such as divergence - price continues higher as the oscillator decreases in value and vise-versa.*
*Nothing in this script constitutes any form of financial advice. The user is solely responsible for their trading decisions and I will not be held liable for any losses or gains incurred with the use of this script. Please proceed with caution when using this script to assist with trading decisions.
Range Volumetric Weights:
Because of the conditions that must be met in order for to be considered part of wicks, it is possible that the default settings and their intended reasoning will not produce reliable results. If all lower timeframe candles have highs or lows that are within the body of the candle at the chart's resolution, the for the wicks will effectively be 0, which is not an accurate representation of those wicks. This is one of the reasons why I included the ability to change the source values used for these conditions as certain OHLC values may produce more reliable/intended results under these conditions.
Wick Slice Resolution:
PineScript restricts the number of intrabar references to 100,000 total. This script uses 3 separate request.security_lower_tf calls and has a default resolution of 1 minute. This means that if the user were to set the oscillator to the Range setting, enable weighted, and had the Wick Slice Resolution set to 1 minute, this script will exceed this 100,000 reference restriction within 24 days of data and will not produce any results beyond the previous 23.14 days.
Below are example uses of all the different settings of this script, these are done on the 1D chart of COINBASE:BTCUSD :
Classic - Weighted:
Range - no Weight:
Range - Weighted (1 min slices):
Range - Weighted (1 hour slices):
Display Min/Max Guide - No Restriction:
Display Min/Max Guide - Restriction:
User may now plot a line that represents the true percentage of bullish and bearish candles in the sample, instead of just the normalized value shown by the "Bull/Bear ± % Line"
The color of the line is independent of the 'Invert Color' settings and will correspond to 'Bull Color' and 'Bear Color', switching between the two to match which type of candles appeared more often.
Dans le véritable esprit de TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par le règlement. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.