Simple Volatility MomentumOverview:
The Simple Volatility Momentum indicator calculates the mean and standard deviation of the changes of price (returns) using various types of moving averages (Incremental, Rolling, and Exponential). With quantifying the dispersion of price data around the mean, statistical insights are provided on the volatility and the movements of price and returns. The indicator also ranks the mean absolute value of the changes of price over a specified time period which helps you assess the strength of the "trend" and "momentum" regardless of the direction of returns.
Simple Volatility Momentum
This indicator can be used for mean reversion strategies and "momentum" or trend based strategies.
The indicator calculates the average return as the momentum metric and then gets the moving average of the average return and standard deviations from average return average. On the options you can determine if you want to use 1 or 2 standard deviation bands or have both of them enabled.
Settings:
Source: By default it's at close.
M Length: This is the length of the "momentum".
Rank Length: This is the length of the rank calculation of absolute value of the average return
MA Type: This is the different type of calculations for the mean and standard deviation. By default its at incremental.
Smoothing factor: (Only used if you choose the exponential MA type.)
The absolute value of the average return helps you see the strength of the "momentum" and trend. If there is a low ranking of the absolute value of the average return then you can eventually expect it to increase which means that the average return is trending, leading to trending price moves. If the Mean ABS rank value is at or near the maximum value 100 and the average return is at -2 standard deviation from the mean, you can see it as the negative momentum or trend being "finished". Similarly, if the Mean ABS value is near or at the maximum value 100 and the average return is at +2 standard deviation from the mean, you can view the uptrend, as "finished" and the Mean ABS rank can't really go higher than 100.
Moving Average Calculations type:
Incremental: Incremental moving averages use an incremental approach to update the moving average by adding the newest data point and subtracting the oldest one.
Exponential: The exponential moving average gives more weight to recent data points while still considering older ones. This is achieved by applying a smooth factor to the previous EMA value and the current data point. EMA's react more quickly to recent changes in the data compared to simple moving averages, making them useful for short term trends and momentum in financial markets.
Rolling: The moving average is calculated by taking the average of a fixed number of data points within a defined window. As new data becomes available, the window moves forward and the average is recalculated. Rolling Moving Averages are useful for smoothing out short-fluctuations and identifying trends over time.
Important thing to note about indicators involving bands and "momentum" or "trend" or prices:
For the explanation we will assume that stock returns follow a normal distribution and price follows a log normal distribution. Please note that in the live market this assumption isn't always true. Many people incorrectly use standard deviations on prices and trade them as mean reversion strategies or overbought or oversold levels which is not what standard deviations are meant for. Assuming you have applied the log transformation on the standard deviation bands (if your input is raw price then you should use a log transformation to remove the skewness of price), and you have a range of 2 standard deviations from the mean, under the empirical rule with enough occurrences 95% of the values will be within the 2 standard deviation range. This doesn't mean that if price falls to the bottom of the 2 standard deviation bound, there is a 95% chance it will revert back to mean, this is incorrect and not how standard deviations or mean reversion works.
"MOMENTUM"
In finance "momentum" refers to the rate of change of a time series data point. It shows the persistence or tendency for a data series to continue moving in its current direction. In finance, "momentum" based strategies capitalize on the observed tendency of assets that have performed well (or poorly) in the recent past to continue performing well (or poorly) in the near future. This persistence is often observed in various financial instruments including stocks, currencies and commodities.
"Momentum" is commonly calculated with the average return, and relies on the assumption that assets with positive "momentum" or a positive average return will likely continue to perform well in the short to medium term, while assets with a negative average return are expected to continue underperforming. This average return or expected value is derived from historical observations and statistical analysis of previous price movements. However, real markets are subject to levels of efficiencies, market fluctuations, randomness, and may not always produce consistent returns over time involving momentum based strategies.
Mean Reversion:
In finance, the average return is an important parameter in mean reversion strategies. Using statistical methodologies, mean reversion strategies aim to exploit the deviations from the historical average return by identifying instances where current prices and their changes diverge from their expected levels based on past performance. This approach involves statistical analysis and predictive modelling techniques to check where and when the average rate of change is likely to revert towards the mean. It's important to know that mean reversion is a temporary state and will not always be present in a specific timeseries.
Using the average return over price offers several advantages in finance and trading since it is less sensitive to extreme price movements or outliers compared to raw price data. Price itself contains a distribution that is usually positively-skewed and has no upper bound. Mean reversion typically occurs in distributions where extreme values are followed by a tendency for the variable to return towards its mean over time, however the probability distribution of price has no tendency for values to revert towards any specific level. Instead, values may continue to increase without a bound. Returns themself contain more stationary behavior than price levels. Mean reversion strategies rely on the assumption that deviations from the mean will eventually revert back to the mean. Returns, being more likely to exhibit stationary, are better suited for mean reversion based strategies.
The distribution of returns are often more symmetrically distributed around their mean compared to price distributions. This symmetry makes it easier to identify deviations from the mean and assess the likelihood of mean reversion occurrence. Returns are also less sensitive to trends and long-term price movements compared to price levels. Mean reversion strategies aim to exploit deviations from mean, which can be obscured when analyzing raw price data since raw price is almost always trending. Returns can filter out the trend component of price movements, making it easier to identify opportunities.
Stationary Process: Implication that properties like mean and variance remain relatively constant over time.
Returns
MeanReversion - LogReturn/Vola ZScoreShows the z-Score of log-return (blue line) and volatility (black line). In statistics, the z-score is the number of standard deviations by which a value of a raw score is above or below the mean value.
This indicator aggregates z-score based on two indicators:
MeanReversion by Logarithmic Returns
MeanReversion by Volatility
Change the time period in bars for longer or shorter time frames. At a daily chart 252 mean on trading year, 21 mean one trading month.
Returns Model by TenozenHey there! I've been diving into the book "Paul Wilmott on Quantitative Finance," and I stumbled upon this cool model for calculating and modeling returns. Basically, it helps us figure out how much a price has changed over a set number of periods—I like to use 20 periods as a default. Once we get that rate of change value, we crunch some numbers to find the standard deviation and mean using all the historical data we have. That's the foundation of this model.
Now, let's talk about how to use it. This model shows us how returns and price behavior are connected. When returns hang out in the +1 to +2 standard deviation range, it usually means returns are about to drop, and vice versa. Often, this leads to corresponding price moves. But here's the thing: sometimes prices don't do what we expect. Why? It's because there's another hidden factor at play—I like to call it "power."
This "power" isn't something we can see directly, but it's there. Basically, when returns are within that standard deviation range, the market faces resistance when trying to move in its preferred direction, whether bullish or bearish. The strength of this "power" determines if the market will snap back to the average or go for a wild ride. It can show up as small price wiggles, big price jumps, or lightning-fast moves. By understanding this "power," we can get a better handle on what the market might do next and avoid getting blindsided. In the meantime, I couldn't explain "power" yet, but In the future, when I've learned enough, I'd love to share the model with you guys!
So... I'm planning to explore and share more models from this book as I learn, even if those pesky math formulas can be tough to crack. I hope you find this indicator as helpful as I do, and if you've got any suggestions or feedback, please feel free to share! Ciao!
Z MomentumOverview
This is a Z-Scored Momentum Indicator. It allows you to understand the volatility of a financial instrument. This indicator calculates and displays the momentum of z-score returns expected value which can be used for finding the regime or for trading inefficiencies.
Indicator Purpose:
The primary purpose of the "Z-Score Momentum" indicator is to help traders identify potential trading opportunities by assessing how far the current returns of a financial instrument deviate from their historical mean returns. This analysis can aid in recognizing overbought or oversold conditions, trend strength, and potential reversal points.
Things to note:
A Z-Score is a measure of how many standard deviations a data point is away from the mean.
EV: Expected Value, which is basically the average outcome.
When the Z-Score Momentum is above 0, there is a positive Z-Score which indicates that the current returns of the financial instrument are above their historical mean returns over the specified return lookback period, which could mean Positive, Momentum, and in a extremely high Z-Score value, like above +2 Standard deviations it could indicate extreme conditions, but keep in mind this doesn't mean price will go down, this is just the EV.
When the Z-Score Momentum is below 0, there is negative Z-Score which indicates that the current returns of the financial instrument are below their historical mean returns which means you could expect negative returns. In extreme Z-Score situations like -2 Standard deviations this could indicate extreme conditions and the negative momentum is coming to an end.
TDLR:
Interpretation:
Positive Z-Score: When the Z-score is positive and increasing, it suggests that current returns are above their historical mean, indicating potential positive momentum.
Negative Z-Score: Conversely, a negative and decreasing Z-score implies that current returns are below their historical mean, suggesting potential negative momentum.
Extremely High or Low Z-Score: Extremely high (above +2) or low (below -2) Z-scores may indicate extreme market conditions that could be followed by reversals or significant price movements.
The lines on the Indicator highlight the Standard deviations of the Z-Score. It shows the Standard deviations 1,2,3 and -1,-2,-3.
Alpha Trading - Pseudo Laplace Z ScoreAlpha Trading - Pseudo Laplace Z Score
Slowly, very slowly a lot of quant and statistical methods have diffused the world of traditional technical analysis with the world of real math - VEPS (Volatility, Entropy, Probability and Statistics).
‘Alpha Trading' is showing the world how VEPS can show the best probabilities of success with your trading journey.
We send a big thank you to tradingview platform and pine coding team, for this great platform and the possibility to show the methods to trade with quant and statistical methods.
There appears to be resistance in the industry about these methods, so it is even more important now than ever, to support this awesome platform and amazing talented team at trading view and pine coders who enable us all with this wonderful platform to produce tools based on VEPS (Volatility, Entropy, Probability and Statistics).
The newest indicator from the Alpha Trading stable is the “Pseudo Laplace Z Score” which combines the established statistical method of z score applied on asset data. Which is based on our previous indicator called the “Alpha Trading – RMS-Z score”. We have made some optimizations, to give an even better fit to the specific returns of price. Optimizations are on the observation that returns are more Laplace distributed than Normal distributed.
figure 1: pink distribution of the real signal (BTC, 2D), gray is perfect theoretical Laplace distribution.
Therefore, the data is not Normal distributed, but Laplace distributed. Our new indicator calculates the real Z-Score of an underlying asset.
As Z Score is a standardized Normal distribution, it relies upon the definition of Normal distribution. If it deviates from this, it still can give useful information, but the absolute value (distance from the mean in standard deviations) is not reliable, and therefore the use of Normal distribution has some uncertainties.
Therefore, this indicator calculates a pseudo standard deviation, based on the Laplace distribution formulas and the relating Z Score.
By looking at the resulting distribution of the indicator itself, it is close to a perfect theoretical Normal distribution. It is much closer to the theoretical curve (gray), and thus indicates that the use of this approach is correct. Now we can show absolute values (i.e. distance to mean, in standard deviations) which can thus be considered to assist in determining the probabilities with your trading.
figure 2: distribution of indicator AT - Pseudo Laplace Z Score vs a theoretical perfect Normal distribution on BTC 4h
Looking at the indicator directly, it appears that the probability of 99% is crossed very rarely, like expected. Because only 1% of all candles we would expect this probability line to be exceeded.
figure 3: BTC 8h with AT-Pseudo Laplace Z Score
Coming back to the method of a Z Score in general. What is a Z-Score?
A Z-score is a numerical measurement that describes a value's relationship to the mean of a group of values. Z-score is measured in terms of standard deviations from the mean. If a Z-score is 0, it indicates that the data point's score is identical to the mean score. A Z-score of 1.0 would indicate a value that is one standard deviation from the mean. Z-scores may be positive or negative, with a positive value indicating the score is above the mean and a negative score indicating it is below the mean.
Simply put, a z-score (also called a standard score) gives you an idea of how far from the mean a data point is.
Basic guidelines How to Use this indicator:
Consider Entering a Long Position when the indicator is low. Best moves are generally when the indicator Turns yellow(outlier)
Consider Entering a Short Position when the indicator is high. Best moves are generally when the indicator Turns yellow(outlier)
Consider the 3 confidence interval lines (gray lines) at 90%, 95%, and 99%, as possible reversal point (with related probability that it is not getting exceeded 🡪 reversal)
YoY or MoM ReturnsThis script is a technical indicator that calculates the year-over-year (YoY) or month-over-month (MoM) returns of a security.
The returns are then plotted on a chart, with positive returns colored in green and negative returns colored in red.
Monthly ReturnsDisplays monthly and yearly returns in tabular format along with maximum, minimum, average returns and standard deviations.
This uses boxes to build the table and as maximum boxes that could be used is 500, it displays up to 32 years of returns. However, for maximum, minimum, average and standard deviation calculations, it uses data from all months since inception.
This requires timeframe to be set to one month (1M). Cell widths correspond to years. For the first year, cell widths may be shorter and there could be overlap of numbers as nothing could be drawn before the first bar.
Provide sufficient space for the table to render properly. Zooming out or less space may lead to overlapping of numbers.
Performance Tablethis scrip is modified of Performance Table () of TradingView user @BeeHolder = Thank u very much.
-
@BeeHolder formula is based on daily basis,
but my calculation is based on respective day, week and month.
-
The formula of the calculation is (Current Close - Previous Close) * 100 / Previous Close, where Past value is:
1D = close 1 day before
5D = close 5 day before
1W - close 1 week before
4W = close 4 week before
1M - close 1 month before
3M - close 3 month before
6M - close 6 month before
12M - close 12 month before
52W - close 52 week before
Also table position cane be set.
thank you all
-
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.
ln(close/20 sma) adjusted for time (BTC)(This indicator was designed for the BTC index chart)
Designed for Bitcoin. Plots the log of the close/20W SMA with a linear offset m*t, where m is the gradient I've chosen and t is the candle index. Anything above 1 is a mania phase/market cycle top. If it peaks around 0.92 and rolls over, it could be a local/market cycle top.
This will obviously not work at all in the long term as Bitcoin will not continue following the trend line on the log plot (you can even see it start to deviate in the Jan-Feb 2021 peaks where the indicator went to 1.15).
It identifies the 2011, 2013 (both of them), 2017 tops as being just above 1. It also identifies the 2019 local peak and 2021 market cycle top at ~0.94.
Feel free to change the gradient or even add a function to curve the straight line eventually. I made this for fun, feel free to use it as you wish.
Yearly Percentage ReturnsAn indicator that lets you visualize the historical Yearly Percentage returns of any symbol .
Key Features:
Displays the yearly returns from start to end of each year
Displays a table showing all yearly returns for current symbol
Displays start of each year as a vertical line
Displays up to 5 custom horizontal levels
Table Settings:
Enable table - Show/Hide the table
Size - Sets the size of the table
Position - Sets the position of the table on the screen
Direction - Sets the direction of the table to display the data (Vertically or Horizontally)
Weekly Returns with BenchmarkSome time ago I published Monthly returns table. Now It's time for weekly one.
To get it work you need a pretty big screen, but I hope it will be useful for some of you.
Features of this table includes:
Display weekly returns of your strategy, benchmark, and alpha over this benchmark.
Select benchmark to be another instrument
Select the date from which you want to compute monthly returns
Show/hide benchmark and alpha
Choose colors for gradient for gain/loss values
Use it with any type of strategy
Use it with replay
Thanks to @MUQWISHI to help me coding it.
It's not about the strategy itself but the way you display returns on your chart. So pls don't critique my choice of the strategy and its performance 🙂
Disclaimer
Please remember that past performance may not be indicative of future results.
Due to various factors, including changing market conditions, the strategy may no longer perform as well as in historical backtesting.
This post and the script don’t provide any financial advice.
One Year ReturnThis is a script meant for the weekly timeframe . It shows the change between the current close and the close 52 bars ago. I find that this data can be useful for deciding how long to stay in a trade, and for deciding how far a stock is likely to move in a year based on it's historical returns. The High average takes the sum of all positive returns and averages it using the number of bars where the data was positive, the low average does the same but with all the returns below zero. When both are turned on you will see a band between these values.
conditional_returnsThis script attempts to contextualize the instrument's latest return. It asks, "when a return of the same or greater magnitude occurred in the past, in the same direction, what was the following period's return?"
By default, the latest return is used. For example, on a daily chart, that would mean "today's" return. However, you can select any return you want using the "override" input.
The output table shows:
- The latest/override return, as a percentage. This is in the top left, fuchsia cell.
The first three, blue columns, show:
- The count of up and down (or positive and negative) next period returns. This shows you the sample size.
- The percentage of up/down next period returns.
- The average next-period return return, up and down, as percentages.
The next three, green columns show these same statistics, but for all returns--every period in the active date range is used. This data serves as a basis for comparison.
Note that you can select a custom date range with the "start" and "end" inputs. The corresponding area on the chart is shaded light grey, to show which data is used in the computations.
Simple/Compounded Returns & Drawdowns TableVery excited to bring this script to the public. This is a very useful table that displays the performance of any strategy you give it in a more detailed view. It runs on all timeframes and at any position on the chart with the replay function. It also updates on tick changes. The table consists of three modes: Simple Equity, Compound Equity and Drawdown.
Simple Equity – shows the change in equity for every month and year. It is calculated by finding the difference in initial equity at the beginning of the month/year and the end of the month/year. The table will thus display strategy performance in blocks of time that are not correlated. It is an excellent way to see individual month/year performance from start to finish but it may not represent true change in equity over time. For example, let's assume that 100% of equity is used on every trade for simplicity. If a loss of 50% is made in the first month and a profit of 100% is made in the next month, the strategy will show 50% profit for the year. This aggregate value might be helpful to know for testing purposes, but in reality, the account is actually at break-even for the year (Initial Equity * 0.5 * 2 = Initial Equity).
Compound Equity – shows compounded change in equity for every month and year. It is calculated by finding the difference in starting equity when the strategy is run and equity at the end of the month/year. The table will thus display the true strategy performance – compounded equity at the end of each month/year.
Drawdown – shows max drawdown for every month and year. It is calculated by finding the difference between the highest equity achieved for the month/year and the trough in equity for the same month/year. Notice: strategy tester might have a max drawdown value higher than any of the drawdown values in the table. This is because the strategy tester calculates the difference between the highest and lowest equity for the entire strategy, whereas the table displays drawdowns for months and years only. Sometimes, the max drawdown for the year will also be the max drawdown for the entire strategy; hence the two values will be the same.
To use this table with your own strategy, simply find " PLACE YOUR STRATEGY CODE HERE " at the bottom of the script and place your strategy code there. Special thanks to QuantNomad for the inspiration. As always, please let me know if there are any bugs or if you need some help. Leave a like if you wish!
Risk adjusted returns data (volatility optimised)RAR - risk adjusted returns. This methodology could be helpful in portfolio creation and position size risk management. We can set our own preference of risk tolerance via the X variable which is the exponent of volatility in our calculations. This gives an unlimited set of example portfolios on a given time-frame that can be sorted from return oriented to volatility reduction oriented as X increases. RARs are to be compared against eachother.
Monthly Returns in Strategies with Market BenchmarkThis is a modified version of this excellent script Monthly Returns in PineScript Strategues by QuantNomad
I liked and used the script but wanted to see how strategy performed vs market on each month/year. So I am sharing back.
The modification consists in adding Market or Buy & Hold performance between parenthesis inside each cell to better see how strategy performed vs market.
Also, 3 red levels and 3 green levels have been used :
For green :
1/ Light when strategy pnl > 0 but < market
2/ medium when strategy pnl > 0 and > market
3/ Dark when strategy pnl > 0 and market < 0 or pnl > market x 2
Same logic in the opposite direction for red.
The strategy provided here is just a showcase of how to use the table in pine script.
Disclaimer
Please remember that past performance may not be indicative of future results.
Due to various factors, including changing market conditions, the strategy may no longer perform as well as in historical backtesting.
This post and the script don’t provide any financial advice.
Alpha Trading - Deviation Log Pro - Coder WolvesAlpha Trading - Deviation Log Pro
Here at Alpha Trading we love our indicators built on returns. In our view, the only way to play divergences in Trading is divergences between Returns based oscillators and Price.
The Alpha Trading Deviation Log Pro displays a mean of log returns, with returns and price both weighted using our proprietary root mean square (RMS) Z-Score.
We also show standard error and confidence intervals.
Within the indicator settings, you can apply alerts to the RMS Z Score, as well as an option to turn on triangle and square shapes to assist with showing potential buy/sell and get out of trade signals.
Things to Understand First
Standard Error
The term "standard error" is used to refer to the standard deviation of various sample statistics, such as the mean or median. For example, the "standard error of the mean" refers to the standard deviation of the distribution of sample means taken from a population. The smaller the standard error, the more representative the sample will be of the overall population.
The relationship between the standard error and the standard deviation is such that, for a given sample size, the standard error equals the standard deviation divided by the square root of the sample size. The standard error is also inversely proportional to the sample size; the larger the sample size, the smaller the standard error because the statistic will approach the actual value.
The standard error is considered part of inferential statistics. It represents the standard deviation of the mean within a dataset. This serves as a measure of variation for random variables, providing a measurement for the spread. The smaller the spread, the more accurate the dataset.
Confidence Interval
A confidence interval is a range of values where an unknown population parameter is expected to lie most of the time, if you were to repeat your study with new random samples.
With a 95% confidence level, 95% of all sample means will be expected to lie within a confidence interval of ± 1.96 standard errors of the sample mean.
Settings
• Confidence Intervals plotted with Green and Red Horizontal Lines
• Standard Error Mean - Plotted as a blue dots
• Standard Error Upper - Plotted as a grey line
• Standard Error Lower -Plotted as grey line
• RMS Z-Score Alerts shown as Red and Green Dots
• Potential Buy Signal Green Triangle Up
• Potential Sell Signal - Red Triangle Down
• Get out of Long Trade - White Square
• Get Out of Short Trade - White Square
The Chart below is showing the Divergences between Returns and Price Action over a long term trend of a time series, no matter the time frame.
Monthly Returns in PineScript StrategiesI'm not 100% satisfied with the strategy performance output I receive from TradingView. Quite often I want to see something that is not available by default. I usually export raw trades/metrics from TradingView and then do additional analysis manually.
But with tables, you can build additional metrics and tools for your strategies quite easily.
This script will just show a table with monthly/yearly performance of your script. Quite a lot of traders/investors used to look at returns like that. Also, it might help you to identify periods of time when your strategy performed good/bad than expected and try to analyze that better.
The script is very simple and I believe you can easily apply it to your own strategies.
Disclaimer
Please remember that past performance may not be indicative of future results.
Due to various factors, including changing market conditions, the strategy may no longer perform as well as in historical backtesting.
This post and the script don’t provide any financial advice.
Rolling ReturnsWhat does this indicator show?
This indicator shows the rolling return of a set lookback period.
The default indicator value is 20 which will show the rolling 20-day return because 20 trading days is 1 month.
Seasonality of ReturnsHi!
I want to share a simple script I built to analize the seasonality of Bitcoin and other assets.
So far it just displays the average return of each month, but I might add some more things later on.
The best timeframe to use it is the monthly timeframe it works on all timeframes but you need the full history for the average, and on weekly you will see issues cause weeks dont match months
On the dataview you can see the variance of each month, feel free to edit it at your own like
Mikel
[BCT] Can BTC be predicted or is it purely random?Variance Ratio**This indicator can be applied to the ticker of your choice (not just BTC)**
Markets are said to be "efficient". An efficient market is by definition unpredictable - no matter the amount of ML, computation, or indicators thrown at it. In particular, in an efficient market, TA will not be of help.
An illustration of efficient markets is the WSJ's longstanding monkey vs. human contest:Blindfolded Monkey Beats Humans With Stock Picks, granted there are several flaws to it.
BTC is a relatively new market. New markets are typically highly inefficient (easier to make money) and become more and more efficient over time (harder to make money). How much more efficient is BTC becoming?
We apply the Variance Ratio method and apply it to BTC.
BACKGROUND ON THE VARIANCE RATIO METHOD
Based on 1988 MacKinlay's seminal paper "Stock Market Prices do not Follow a Random Walk", the idea is to exploit a phenomenon called "variance scaling".
For those keen on looking into the math, the short version of it is under the assumption of iid (random walk) we have the following:
H0: Var(Sum(returns over K bars))=Sum(Var(returns over 1 bar))=k*Var(return over 1 bar)
We look to reject or not H0 depending on the observations.
In this script, we compare the variance of the (log) returns for the chart selected between:
(1) The (average) variance over k bars (call this Vk)
(2) The (average) variance over 1 bar (call this V1)
H0 simply says that Vk=k*V1 if the stock follows a random walk.
We compute the Variance Ratio VR(k)=Variance(returns over k bar)/(Sum(Var(returns over 1 bar)))-1
We then compute the associated Z-score which we chart out for a configurable k number of bars.
HOW TO INTERPRET THE CHART
The line drawn is the Z-Score for VR(k). It represents the number of standard deviations of VR(k) from 0 - the further out, the less random.
- If the line is close / hovers around 0, the ticker appears to follow a random walk (i.e. may not be predictable)
- If the line is consistently > 2 or <-2, the ticker likely does not follow a random walk (i.e. may have predictable features)
- If the line is positive, it means that the Variance on the k bars is larger than the variance on 1 bar (more variance on longer timeframes)
- If the line is negative, it means that the Variance on the k bars is smaller than the variance on 1 bar (more variance on smaller timeframes)
USE CASES
- Identify timeframes where you won't be able to make money
- Identify whether a stock cannot be predicted (forget about TA, indicators etc. -- a random walk is not predictable)
- Identify whether a stock is becoming less and less predictable (Z-score amplitude will decrease over time)
FEATURES
- select the number of K bar to compare vs. 1 bar (default = 16) - ideally a power of 2 but any other number will work. The chart is based off this selection
- select the lookback period for the analysis (500 bars by default)
- select the source to analyze (default = close, but you may select other inputs to calculate the returns from)
- results form the statistical tests on different K's in the table on the right/bottom side of the chart (H0 rejected = not random walk; H0 not rejected = it essentially looks rather random and we can't conclude that it's not a random walk)
COMMENTARY ON BTC
- It appears BTC's absolute value of the ZScore on the Variance Ratio is declining year after year - corroborating an increasingly efficient market as new participants join.
- However, we can still detect a fair amount of potential inefficiency using this simple test.
As usual, this is not investment advice. DYOR.
With love,
🐵BCT🐵
Return by day of the weekBuy on Mondays sell on Tuesdays.
Just a simple tracking of returns.
It works only on the weekly charts