VolatilityVolatility - The amount of price deviation in the specified time interval.
The calculation is made from the opening point to the closing point, and the maximum and minimum deviation between them is also included. Any timeframes are supported.
Available information: the start date of the calculation (according to the time zone of the exchange), the current volatility from the initial opening point or from the last closing point, the total volatility for all periods.
An indicator of useful use in everyday work.
Thanks for your attention!
Statistics
AllTimeHighLowLibrary "AllTimeHighLow"
Provides functions calculating the all-time high/low of values.
hi(val)
Calculates the all-time high of a series.
Parameters:
val : Series to use (`high` is used if no argument is supplied).
Returns: The all-time high for the series.
lo(val)
Calculates the all-time low of a series.
Parameters:
val : Series to use (`low` is used if no argument is supplied).
Returns: The all-time low for the series.
(Quartile Vol.; Vol. Aggregation; Range US Bars; Gaps) [Kioseff]Hello!
This indicator is a multifaceted tool that's, hopefully, useful for price action and volume analysis.
(This script makes use of the newly introduced "text_font" parameter)
With this script you'll have access to:
Range US Chart
Volume Aggregation Chart
Gaps Chart
Volume by Quartile
Consequently, you'll have access to:
First Quartile Volume Threshold
Second Quartile Volume Threshold
Third Quartile Volume Threshold
90th Percentile Volume Threshold
Fourth Quartile Volume Threshold
Q2 - Q1 Dispersion
Q3 - Q2 Dispersion
Q4 - Q3 Dispersion
Quartile Deviation
Interquartile Range
Avg. "n" bar return following "high" volume
Avg. "n" bar positive return following "high" volume
Avg. "n" bar negative following "high" volume
# of Positive Returns Following a Gap
# of Negative Returns Following a Gap
# of Gaps
# of Up Gaps
# of Down Gaps
Average # of bars to fill Up Gaps
Average # of bars to dill Down Gaps
Average Gap Up % increase
Average Gap Down % decrease
Cumulative % increase of all Up Gaps
Cumulative % decrease of all Down Gaps
Sort gaps by distance from price
Hide gaps that price substantially deviates from (gaps will reappear when price trades near the gap)
Segment Range US bars by date
Manually configure Range US price thresholds
Identify "congestion" areas with Range US bars
Range US Levels that must be exceeded for a new Range US bar to produce
Manually configure cumulative volume threshold for Volume Aggregation bars
Segment Volume Aggregation bars by date
Largest Volume Aggregation bar increases
Largest Volume Aggregation bar decreases
Calculate log returns after "high" volume sessions
Quartile Volume
The Quartile Volume portion of the script segments price/volume intervals by quartile.
The image above shows features of the indicator.
For statistics, the following metrics are recorded:
First Quartile
Second Quartile
Third Quartile
90th Percentile
Fourth Quartile
Q2 - Q1 Dispersion
Q3 - Q2 Dispersion
Q4 - Q3 Dispersion
Quartile Deviation
Interquartile Range
Color-coordinated price bars (by volume quartiles)
The percent rank for the volume of the current bar
Avg. "n" bar return following "high" volume
Avg. "n" bar positive return following "high" volume
Avg. "n" bar negative following "high" volume
The script colors bars via gradient.
By default, bars are colored lime when volume for the interval is "high" (exceeds upper quartile thresholds). The greener the bar, the higher the volume for the interval.
Bars are colored red when volume for the interval is "low" (fails to exceed lower quartile thresholds). The redder the bar, the lower the volume for the interval.
Naturally, brownish-colored bars reflect a volume interval that concluded near the median.
The image above exemplifies the process. This feature might be useful to categorize / objectively define high-volume clusters, low-volume clusters, high-volume price moves, low-volume price moves, etc.
For greater precision, you can select to color bars by volume quartile they belong to.
The image above shows color-coordinated price bars. More details shown in the image.
Additionally, you can select to plot the quartile/percentile that a price bar belongs to on the chart.
The image above shows price bars numbered by the volume quartile they belong to.
The script will distinguish successive 90th percentile violations, superimpose a linear regression channel atop the data sequence, and record pertinent statistics.
The image above shows the process.
Lastly, the user can plot an anchored VWAP using a built-in time function.
The image above shows the anchored VWAP.
Range US Chart
A Range US chart operates irrespective of time and volume - simply - bars produce after a user-defined price move is achieved/exceeded in either direction. A range us chart produces “trend candles” and “reversal candles”. A reversal candle always moves against the most immediate bar; a trend candle always moves in favor of the most immediate bar. The user defines the dollar amount price must travel up/down for a trend candle to fulfill, and for a reversal candle to fulfill.
Note: if a “down reversal” candle (red) Is produced, it’s impossible for the next candle to also be a down reversal candle - for the downside move to continue the criteria for a down trend candle must be fulfilled. Similarly, if an “up reversal” candle (green) Is produced, it’s impossible for the next candle to also be an up reversal candle - for the upside move to continue, the criteria for an uptrend trend candle must be fulfilled. Consequently, Range US bars frequently trade at the same level for extended periods. This is intentional, as this chart type is theorized to “filter noise” (whether Range US charts fulfill this theory is to your discretion).
Lastly, if an up trend candle (green) is produced, the next candle cannot be up a reversal up candle - only a trend up candle or reversal down candle can produce - vice versa for a trend down candle (the subsequent candle cannot be a reversal down candle). In this sense, an uptrend continues on successive trend up candles; a down trend continues on successive trend down candles.
The image above exemplifies Range US chart functionality.
The lower-right stats table shows the requisite price move for a "Trend" candle to produce and for a "Reversal" candle to produce.
The default settings for this chart time automatically calculate the required "Trend" candle price move and the required "Reversal" candle price move. However, both settings are configurable.
The image above shows manually configured parameters for a trend bar and reversal bar to produce. This feature allows the user to replicate the Range US chart hosted on extrinsic charting platforms.
However, please consider that this script does not use tick data; 1-minute OHLC data is used for calculations.
Consequently, configuring the trend bar and reversal bar requirement too low may return inaccurate data. For instance, if you set trend candles to form after a $1 price move then trend candles will form if price moves up $1 from a green Range US bar or down $1 from a red Range US bar. This is sufficient for lower priced assets; however, if you were trading, for instance, Bitcoin - a $1 price move can happen numerous times in one minute. This script can’t plot bars and record data until a 1-minute bar closes and a new 1-minute bar opens. Further, if Bitcoin moves up $1 twenty times and down $1 twenty times in a 1-minute bar - your Range US chart will record such variations as one price move. This data is inaccurate and likely useless.
To counter this quandary, a warning message will appear if you configure trend bar price moves or reversal bar price moves too low.
The image above shows the concealable warning message.
The image above is a flow diagram (made with shaky hands) illustrating the Range US bar formation process.
A google search will return additional information on the Range US chart type.
Volume Aggregation Bars
TradingView user and member of the TradingView Discord server @ferreirajames informed me of the Volume Aggregation chart type. The user commented in the "Suggestions" channel for the TradingView Discord server asking for the Volume Aggregation chart type. As an interim fix, I tried my hand at recreating the process, which is available in this script.
Similar to the Range US chart type, Volume Aggregation bars aren’t bound to a time-axis; the bars form after a user-defined, cumulative amount of volume is achieved or exceeded. Consequently, once the cumulative amount of volume is achieved or exceeded - a bar is produced at the corresponding price level.
Underlying theory: The chat type is conducive to identifying price levels where traders are “trapped”. Whether the process adequately distinguishes this circumstance is to your discretion.
The image above exemplifies the Volume Aggregation chart type.
Regardless of the current price, Volume Aggregation bars for after a requisite amount of volume is achieved/exceeded. Tick data isn't used; therefore, remainder values are carry over.
By default, the script automatically calculates a proportional cumulative volume total to dictate the formation of Volume Aggregation bars. However, the cumulative threshold is configurable.
The image above shows Volume Aggregation bars forming subsequent a user-defined cumulative volume total being exceeded.
Note: This chart type uses OHLC data from the timeframe of your chart. Therefore, for instance, setting the volume threshold too low will produce inaccurate, useless data.
A warning message will appear for such occurrence.
Gaps
The indicator incorporates a "Gaps" chart type.
The image above shows accompanying features.
A list of all unfilled gaps is accessible - gaps for this list are sorted by distance from current price.
Partially filled gaps are displayed in the corresponding gap box - the percentage amount the gap was filled is also displayed.
Gap statistics show:
# of Gaps
# of Up Gaps
# of Down Gaps
Average # of bars to fill Up Gaps
Average # of bars to dill Down Gaps
Average Gap Up % increase
Average Gap Down % decrease
Cumulative % increase of all Up Gaps
Cumulative % decrease of all Down Gaps
Naturally, there may be gaps formed thousands of bars ago that aren't close to price. Showing these gaps on the chart will "scrunch" the y-axis and make prices indistinguishable.
I've added a setting that allows the user to hide gaps that are "n" % away from the current price. The gap, if unfilled, will reappear when price trades within the user-defined percentage.
The image above shows an example. There's an unfilled down gap that's "hidden" because the current price is a further % away from price than what I've specified in the settings (1%). When prices trade back within 1% of the gap - it will reappear.
The image above shows the process in action. Prices moved back within 1% (can be any %) of the gap; therefore, it reappeared on the chart.
You can also set the % distance a gap must achieve for it to be considered a gap, recorded and plotted. Additionally, you can select to "visualize" gaps. Similar to the Range US chart and the Volume Aggregation chart, this setting will bars reflecting the most recent sequence of gaps - date and percentage distance of the gap are superimposed atop the bar.
Let me know if there's anything else you'd like included!
Note: The initial compilation time for this script is.... high. However, once the script's compiled, calculation load times are quick and you can sift through assets and timeframes relatively quick.
There's also a setting to "Improve Load Times" in the user-inputs table. This setting only improves the load times for post-compilation calculations and plots. The initial compilation load time is unchanged. Simply, once the indicator has "first loaded", all subsequent loads are quick.
Thank you! (:
Sovereign Gold Hodlers Script for comparing nations and their gold, with options including:
Default Comparing the Price of Gold
Use Relative Valuations price / prior price
Measure Reserves/Price
GDP/Gold Price
GDP/Gold Reserves
Given the state of the world I thought it'd be good do see where countries stand, how much real money they hold. I think gold is going to play an increased role in trade between economies in the near future.
High low volatile
its purpose to make this script is learning how many spread on each product.
its help trader and me to estimate spread of High and low for make a better trade
Money management :
Its also useful to help trader to manage number of lot to take a risk on that trade
How it work?
I use High and low to calculate the different between on them
and I add an EMA 10 and EMA 200 to estimate spread of each product in many bar
On second picture , I use it on GOLD 1H timeframe . You can see that Gold in hour trade on my country time (thailand) It has more spread on 19.00-23.00 pm (in US time is 7.00-11.00)
It help trader to set time when to trade and when to leave
thank you
L_BetaLibrary "L_Beta"
TODO: add library description here
length()
beta()
simple_beta()
index_selector()
CalulateWinLossLibrary "CalulateWinLoss"
TODO: add library description here
colorwhitered(x)
TODO: add function description here
Parameters:
x : TODO: add parameter x description here
Returns: TODO: add what function returns
colorredwhite()
cal()
Improved Z-ScoreStandard Z-Score scripts lack customization of parameters that I personally desire when doing quantitative analysis. This is an improved Z-Score Indicator to add to your charts that lets you customize various inputs.
Below are the current features:
1) Ticker Type - which data would you like to use for the ticker input - Open, High, Low, Close, OHLC4
2) Ticker Smoothing? - sometimes if you have noisy data, it could be useful to smooth the ticker with a very fast EMA. If this is set to true, the ticker data will be smoothed with an EMA with period that you specify.
3) Ticker Smoothing Period - if Ticker Smoothing? is set to true, this will allow you to specify the smoothing period of the fast EMA - I usually use a 3-period for all of my quantitative analysis, if I am using smoothing.
4) MA Type - Z-Scores are normalized by subtracting a moving average. This allows you to select either a Simple Moving Average (SMA) or an Exponential Moving Average (EMA) - the standard is to use SMA.
5) MA Period - the previous X number of bars that you would like to use for normalization. The default is set to 21 (this is roughly 1 month of trading days data for a daily chart).
5) Standard Deviation Period - Z-Scores are normalized by dividing by the standard deviation over X previous periods. This allows you the chance to customize. Default is 252 (this is roughly 1 year of trading days data for a daily chart).
I can add more features if folks are interested, let me know! I hope you like the script.
Best regards,
-Jim Bosse-
Yasir Hameed Advance RSI IndicatorRELATIVE STRENGTH INDEX ( RSI )
This is a tool that is widely used
Especially for Overbought and Oversold systems, but I have made some changes in this indicator,
How to use it...!
I have set it as the default setting
- RSI Length: 7
- Overbought: 70
- Oversold: 30
What is unique about this tool?
we can see 3 conditions:
1) RSI Overbought / Oversold with Bullish Engulfing / Bearish Engulfing
2) RSI Overbought / Oversold with Hammer and Shooting Star
3) RSI Overbought / Oversold with 2 Bullish Bars / 2 Bearish Bars
4) RSI Overbought / Oversold with All Patterns at the same time
When the RSI reaches its Oversold line, the code will wait for Bullish Engulfing pattren, when oversold and Bullish engulfing matched, This indicator will generate a buy signal when the condition is met,
and same as for Bear market, When the RSI reaches its Overbought line, the code will wait for Bearish Engulfing pattren, This indicator will generate a sell/exit signal when the condition is met,
2nd condition is that a Hammer candle will be waited for when RSI touches the Overbought line, for Bullish Move
and Shooting Star candle will be waited for when RSI touches the Overbought line, for Bullish Move, for Bearish Move
3rd Condition is also the same as Condition 1 and Condition 2,
When the RSI reaches its Oversold line, the code will wait for 2 Bullish Bars, when oversold and 2 Bullish Bars matched then this indicator will generate a buy signal, and same as for Bear market,
When the RSI reaches its Overbought line, the code will wait for 2 Bearish Bars, when overbought and 2 Bearish Bars matched then this indicator will generate a Sell signal,
4th Condition is that we can use All Conditions at the same time,
- Bullish Engulfing / Bearish Engulfing
- Hammer and Shooting Star
- 2 Bullish Bars / 2 Bearish Bars
Session backtest toolWith this tool you can easily backtest your trading strategy. You can set the times of a day session and evening session separately. The days of the week were indicated at the bottom of the chart.
For me personally, this saves me a lot of time with back testing. Hopefully I can help you with this too
Fed Funds Rate ProjectionsThis script makes projections via drawing boxes based upon changes in the fed funds rate (FRED:EFFR).
It works by turning the change in the fed funds rate into a user defined percentage (using a multiplier, by default a 1% rate of change implies a 10% change in the chart) and then drawing a box that distance away depending on the direction of the rate of change.
The size of the multiplier should depend on the duration of the asset which this is being applied to, for example, a long duration asset such as a high beta growth stock should use a larger multiplier.
Move Up/Down in X daysShows up and down moves off Y per cent for X days.
Also shows a bar for days that has a volume over a threshold.
Default configuration is 20% move up or down for 5 days and volume threshold of 9 Million.
52 Weeks Highs-Lows S&P 500 - MugurThe script uses the MAHP and the MALP index and subtracts the second from the first. So you can see how many stocks in the S&P 500 make new highs or new lows on a 52 weeks basis and see the trend of the market.
5 Day Highs-Lows S&P 500 - MugurThe script uses the M5HP and the M5LP index and subtracts the second from the first. So you can see how many stocks in the S&P 500 make new highs or new lows on a 5 days basis and see the trend of the market.
3 Month Highs-Lows S&P 500 - MugurThe script uses the M3HP and the M3LP index and subtracts the second from the first. So you can see how many stocks in the S&P 500 make new highs or new lows on a 3 month basis and see the trend of the market.
1 Month Highs-Lows S&P 500 - MugurThe script uses the M1HP and the M1LP index and subtracts the second from the first. So you can see how many stocks in the S&P 500 make new highs or new lows on a 1 month basis and see the trend of the market.
Range Gap/Open to Close/Close to CloseThis indicator shows the percentage variation of:
gap
close to close (day including gap)
open to close (without gap)
The green bars represent the days when the variation did not reach the selected range. The red bars show the days when the variation was higher than the selected range.
Best timeframe : DAY
Annual Returns % Comparison [By MUQWISHI]Overview
The Annual Returns % Comparison indicator aimed to compare the historical annual percentage change of any two symbols. The indicator output shows a column-plot that was developed by two using a pine script table, so each period has pair columns showing the yearly percentage change for entered symbols.
Features
- Enter date range.
- Fill up with any two symbols.
- Choose the output data whether adjusted or not.
- Change the location of the table plot
- Color columns by a symbol.
- Size the height and width of columns.
- Color background, border, and text.
- The tooltip of the column value appears once the cursor sets above the specific column. As it seen below.
Let me know if you have any questions.
Thanks.
FunctionPatternFrequencyLibrary "FunctionPatternFrequency"
Counts the word or integer number pattern frequency on a array.
reference:
rosettacode.org
count(pattern)
counts the number a pattern is repeated.
Parameters:
pattern : : array : array with patterns to be counted.
Returns:
array : list of unique patterns.
array : list of counters per pattern.
usage:
count(array.from('a','b','c','a','b','a'))
count(pattern)
counts the number a pattern is repeated.
Parameters:
pattern : : array : array with patterns to be counted.
Returns:
array : list of unique patterns.
array : list of counters per pattern.
usage:
count(array.from(1,2,3,1,2,1))
Rolling QuartilesThis script will continuously draw a boxplot to represent quartiles associated with data points in the current rolling window.
Description :
A quartile is a statistical term that refers to the division of a dataset based on percentiles.
Q1 : Quartile 1 - 25th percentile
Q2 : Quartile 2 - 50th percentile, as known as the median
Q3 : Quartile 3 - 75th percentile
Other points to note:
Q0: the minimum
Q4: the maximum
Other properties :
- Q1 to Q3: a range is known as the interquartile range ( IQR ). It describes where 50% of data approximately lie.
- Line segments connecting IQR to min and max (Q0→Q1, and Q3→Q4) are known as whiskers . Data lying outside the whiskers are considered as outliers. However, such extreme values will not be found in a rolling window because whenever new datapoints are introduced to the dataset, the oldest values will get dropped out, leaving Q0 and Q4 to always point to the observable min and max values.
Applications :
This script has a feature that allows moving percentiles (moving values of Q1, Q2, and Q3) to be shown. This can be applied for trading in ways such as:
- Q2: as alternative to a SMA that uses the same lookback period. We know that the Mean (SMA) is highly sensitive to extreme values. On the other hand, Median (Q2) is less affected by skewness. Putting it together, if the SMA is significantly lower than Q2, then price is regarded as negatively skewed; prices of a few candles are likely exceptionally lower. Vice versa when price is positively skewed.
- Q1 and Q3: as lower and upper bands. As mentioned above, the IQR covers approximately 50% of data within the rolling window. If price is normally distributed, then Q1 and Q3 bands will overlap a bollinger band configured with +/- 0.67x standard deviations (modifying default: 2) above and below the mean.
- The boxplot, combined with TradingView's builtin bar replay feature, makes a great tool for studies purposes. This helps visualization of price at a chosen instance of time. Speaking of which, it can also be used in conjunction with a fixed volume profile to compare and contrast the effects (in terms of price range) with and without consideration of weights by volume.
Parameters :
- Lookback: The size of the rolling window.
- Offset: Location of boxplot, right hand side relative to recent bar.
- Source data: Data points for observation, default is closing price
- Other options such as color, and whether to show/hide various lines.
SuperVos Trade calculatorHave all your trade data in one small overview.
- TP amount in USD and %
- RR of the trade
- Cost if stoploss is hit
- Total profit in USD
- Account growth in percentage
- Sets automatic alerts on SL, entry en TP's if enabled
Enjoy!
Candle DifferenceA simple script to show the price different between the previous candle and all the points of the current open candle. (including: high, low, open)
They are color labeled. (You check what each color means in the settings of the script)