E9 PLRRThe E9 PLRR (Power Law Residual Ratio) is a custom-built indicator designed to evaluate the overvaluation or undervaluation of an asset, specifically by utilizing logarithmic price data and a power law-based model. It leverages a dynamic regression technique to assess the deviation of the current price from its expected value, giving insights into how much the price deviates from its long-term trend.
This indicator is primarily used to detect market extremes and cycles, often used in the analysis of long-term price movements in assets like Bitcoin, where cyclical behavior and significant price deviations are common.
This chart is back from 2019 and shows (From left to right) 2018 Bear market bottom at $3.5k (Dark Blue) , following a peak at 12k (dark red) before the Covid crash back down to EUROTLX:4K (Dark blue)
Key Components
Logarithmic Price Data:
The indicator works with logarithmic price data (ohlc4), which represents the average of open, high, low, and close prices. The logarithmic transformation is crucial in financial modeling, especially when analyzing long-term price data, as it normalizes exponential price growth patterns.
Dynamic Exponent 𝑘:
The model calculates a dynamic exponent k using regression, which defines the power law relationship between time and price. This exponent is essential in determining the expected power law price return and how far the current price deviates from that expected trend.
Power Law Price Return:
The power law price return is computed using the dynamic exponent
k over a defined period, such as 365 days (1 year). It represents the theoretical price return based on a power law relationship, which is used to compare against the actual logarithmic price data.
Risk-Free Rate:
The indicator incorporates an adjustable risk-free rate, allowing users to model the opportunity cost of holding an asset compared to risk-free alternatives. By default, the risk-free rate is set to 0%, but this can be modified depending on the user's requirements.
Volatility Adjustment:
A key feature of the PLRR is its ability to adjust for price volatility. The indicator smooths out short-term price fluctuations using a moving average, helping to detect longer-term cycles and trends.
PLRR Calculation:
The core of the indicator is the calculation of the Power Law Residual Ratio (PLRR). This is derived by subtracting the expected power law price return and risk-free rate from the logarithmic price return, then multiplying the result by a user-defined multiplier.
Color Gradient:
The PLRR values are represented visually using a color gradient. This gradient helps the user quickly identify whether the asset is in an undervalued, fair value, or overvalued state:
Dark Blue to Light Blue: Indicates undervaluation, with increasing blue tones representing a higher degree of undervaluation.
Green to Yellow: Represents fair value, where the price is aligned with the expected power law return.
Orange to Dark Red: Indicates overvaluation, with increasing red tones representing a higher degree of overvaluation.
Zero Line:
A zero line is plotted on the indicator chart, serving as a reference point. Values above the zero line suggest potential overvaluation, while values below indicate potential undervaluation.
Dots Visualization:
The PLRR is plotted using dots, with each dot color-coded based on the PLRR value. This dot-based visualization makes it easier to spot significant changes or reversals in market sentiment without overwhelming the user with continuous lines.
Bar Coloring:
The chart’s bars are colored in accordance with the PLRR value at each point in time, making it visually clear when an asset is potentially overvalued or undervalued.
Indicator Functionality
Cycle Identification : The E9 PLRR is especially useful for identifying cyclical market behavior. In assets like Bitcoin, which are known for their boom-bust cycles, the PLRR can help pinpoint when the market is likely entering a peak (overvaluation) or a trough (undervaluation).
Overvaluation and Undervaluation Detection: By comparing the current price to its expected power law return, the PLRR helps traders assess whether an asset is trading above or below its fair value. This is critical for long-term investors seeking to enter the market at undervalued levels and exit during periods of overvaluation.
Trend Following: The indicator helps users identify the broader trend by smoothing out short-term volatility. This makes it useful for both momentum traders looking to ride trends and contrarian traders seeking to capitalize on market extremes.
Customization
The E9 PLRR allows users to fine-tune several parameters based on their preferences or specific market conditions:
Lookback Period:
The user can adjust the lookback period (default: 100) to modify how the moving average and regression are calculated.
Risk-Free Rate:
Adjusting the risk-free rate allows for more realistic modeling of the opportunity cost of holding the asset.
Multiplier:
The multiplier (default: 5.688) amplifies the sensitivity of the PLRR, allowing users to adjust how aggressively the indicator responds to price movements.
This indicator was inspired by the works of Ashwin & PlanG and their work around powerLaw. Thank you. I hall be working on the calculation of this indicator moving forward to make improvements and optomisations.
Powerlaw
BenfordsLawLibrary "BenfordsLaw"
Methods to deal with Benford's law which states that a distribution of first and higher order digits
of numerical strings has a characteristic pattern.
"Benford's law is an observation about the leading digits of the numbers found in real-world data sets.
Intuitively, one might expect that the leading digits of these numbers would be uniformly distributed so that
each of the digits from 1 to 9 is equally likely to appear. In fact, it is often the case that 1 occurs more
frequently than 2, 2 more frequently than 3, and so on. This observation is a simplified version of Benford's law.
More precisely, the law gives a prediction of the frequency of leading digits using base-10 logarithms that
predicts specific frequencies which decrease as the digits increase from 1 to 9." ~(2)
---
reference:
- 1: en.wikipedia.org
- 2: brilliant.org
- 4: github.com
cumsum_difference(a, b)
Calculate the cumulative sum difference of two arrays of same size.
Parameters:
a (float ) : `array` List of values.
b (float ) : `array` List of values.
Returns: List with CumSum Difference between arrays.
fractional_int(number)
Transform a floating number including its fractional part to integer form ex:. `1.2345 -> 12345`.
Parameters:
number (float) : `float` The number to transform.
Returns: Transformed number.
split_to_digits(number, reverse)
Transforms a integer number into a list of its digits.
Parameters:
number (int) : `int` Number to transform.
reverse (bool) : `bool` `default=true`, Reverse the order of the digits, if true, last will be first.
Returns: Transformed number digits list.
digit_in(number, digit)
Digit at index.
Parameters:
number (int) : `int` Number to parse.
digit (int) : `int` `default=0`, Index of digit.
Returns: Digit found at the index.
digits_from(data, dindex)
Process a list of `int` values and get the list of digits.
Parameters:
data (int ) : `array` List of numbers.
dindex (int) : `int` `default=0`, Index of digit.
Returns: List of digits at the index.
digit_counters(digits)
Score digits.
Parameters:
digits (int ) : `array` List of digits.
Returns: List of counters per digit (1-9).
digit_distribution(counters)
Calculates the frequency distribution based on counters provided.
Parameters:
counters (int ) : `array` List of counters, must have size(9).
Returns: Distribution of the frequency of the digits.
digit_p(digit)
Expected probability for digit according to Benford.
Parameters:
digit (int) : `int` Digit number reference in range `1 -> 9`.
Returns: Probability of digit according to Benford's law.
benfords_distribution()
Calculated Expected distribution per digit according to Benford's Law.
Returns: List with the expected distribution.
benfords_distribution_aprox()
Aproximate Expected distribution per digit according to Benford's Law.
Returns: List with the expected distribution.
test_benfords(digits, calculate_benfords)
Tests Benford's Law on provided list of digits.
Parameters:
digits (int ) : `array` List of digits.
calculate_benfords (bool)
Returns: Tuple with:
- Counters: Score of each digit.
- Sample distribution: Frequency for each digit.
- Expected distribution: Expected frequency according to Benford's.
- Cumulative Sum of difference:
to_table(digits, _text_color, _border_color, _frame_color)
Parameters:
digits (int )
_text_color (color)
_border_color (color)
_frame_color (color)
Bitcoin Power Law Bands (BTC Power Law) Indicator█ OVERVIEW
The 'Bitcoin Power Law Bands' indicator is a set of three US dollar price trendlines and two price bands for bitcoin , indicating overall long-term trend, support and resistance levels as well as oversold and overbought conditions. The magnitude and growth of the middle (Center) line is determined by double logarithmic (log-log) regression on the entire USD price history of bitcoin . The upper (Resistance) and lower (Support) lines follow the same trajectory but multiplied by respective (fixed) factors. These two lines indicate levels where the price of bitcoin is expected to meet strong long-term resistance or receive strong long-term support. The two bands between the three lines are price levels where bitcoin may be considered overbought or oversold.
All parameters and visuals may be customized by the user as needed.
█ CONCEPTS
Long-term models
Long-term price models have many challenges, the most significant of which is getting the growth curve right overall. No one can predict how a certain market, asset class, or financial instrument will unfold over several decades. In the case of bitcoin , price history is very limited and extremely volatile, and this further complicates the situation. Fortunately for us, a few smart people already had some bright ideas that seem to have stood the test of time.
Power law
The so-called power law is the only long-term bitcoin price model that has a chance of survival for the years ahead. The idea behind the power law is very simple: over time, the rapid (exponential) initial growth cannot possibly be sustained (see The seduction of the exponential curve for a fun take on this). Year-on-year returns, therefore, must decrease over time, which leads us to the concept of diminishing returns and the power law. In this context, the power law translates to linear growth on a chart with both its axes scaled logarithmically. This is called the log-log chart (as opposed to the semilog chart you see above, on which only one of the axes - price - is logarithmic).
Log-log regression
When both price and time are scaled logarithmically, the power law leads to a linear relationship between them. This in turn allows us to apply linear regression techniques, which will find the best-fitting straight line to the data points in question. The result of performing this log-log regression (i.e. linear regression on a log-log scaled dataset) is two parameters: slope (m) and intercept (b). These parameters fully describe the relationship between price and time as follows: log(P) = m * log(T) + b, where P is price and T is time. Price is measured in US dollars , and Time is counted as the number of days elapsed since bitcoin 's genesis block.
DPC model
The final piece of our puzzle is the Dynamic Power Cycle (DPC) price model of bitcoin . DPC is a long-term cyclic model that uses the power law as its foundation, to which a periodic component stemming from the block subsidy halving cycle is applied dynamically. The regression parameters of this model are re-calculated daily to ensure longevity. For the 'Bitcoin Power Law Bands' indicator, the slope and intercept parameters were calculated on publication date (March 6, 2022). The slope of the Resistance Line is the same as that of the Center Line; its intercept was determined by fitting the line onto the Nov 2021 cycle peak. The slope of the Support Line is the same as that of the Center Line; its intercept was determined by fitting the line onto the Dec 2018 trough of the previous cycle. Please see the Limitations section below on the implications of a static model.
█ FEATURES
Inputs
• Parameters
• Center Intercept (b) and Slope (m): These log-log regression parameters control the behavior of the grey line in the middle
• Resistance Intercept (b) and Slope (m): These log-log regression parameters control the behavior of the red line at the top
• Support Intercept (b) and Slope (m): These log-log regression parameters control the behavior of the green line at the bottom
• Controls
• Plot Line Fill: N/A
• Plot Opportunity Label: Controls the display of current price level relative to the Center, Resistance and Support Lines
Style
• Visuals
• Center: Control, color, opacity, thickness, price line control and line style of the Center Line
• Resistance: Control, color, opacity, thickness, price line control and line style of the Resistance Line
• Support: Control, color, opacity, thickness, price line control and line style of the Support Line
• Plots Background: Control, color and opacity of the Upper Band
• Plots Background: Control, color and opacity of the Lower Band
• Labels: N/A
• Output
• Labels on price scale: Controls the display of current Center, Resistance and Support Line values on the price scale
• Values in status line: Controls the display of current Center, Resistance and Support Line values in the indicator's status line
█ HOW TO USE
The indicator includes three price lines:
• The grey Center Line in the middle shows the overall long-term bitcoin USD price trend
• The red Resistance Line at the top is an indication of where the bitcoin USD price is expected to meet strong long-term resistance
• The green Support Line at the bottom is an indication of where the bitcoin USD price is expected to receive strong long-term support
These lines envelope two price bands:
• The red Upper Band between the Center and Resistance Lines is an area where bitcoin is considered overbought (i.e. too expensive)
• The green Lower Band between the Support and Center Lines is an area where bitcoin is considered oversold (i.e. too cheap)
The power law model assumes that the price of bitcoin will fluctuate around the Center Line, by meeting resistance at the Resistance Line and finding support at the Support Line. When the current price is well below the Center Line (i.e. well into the green Lower Band), bitcoin is considered too cheap (oversold). When the current price is well above the Center Line (i.e. well into the red Upper Band), bitcoin is considered too expensive (overbought). This idea alone is not sufficient for profitable trading, but, when combined with other factors, it could guide the user's decision-making process in the right direction.
█ LIMITATIONS
The indicator is based on a static model, and for this reason it will gradually lose its usefulness. The Center Line is the most durable of the three lines since the long-term growth trend of bitcoin seems to deviate little from the power law. However, how far price extends above and below this line will change with every halving cycle (as can be seen for past cycles). Periodic updates will be needed to keep the indicator relevant. The user is invited to adjust the slope and intercept parameters manually between two updates of the indicator.
█ RAMBLINGS
The 'Bitcoin Power Law Bands' indicator is a useful tool for users wishing to place bitcoin in a macro context. As described above, the price level relative to the three lines is a rough indication of whether bitcoin is over- or undervalued. Users wishing to gain more insight into bitcoin price trends may follow the author's periodic updates of the DPC model (contact information below).
█ NOTES
The author regularly posts on Twitter using the @DeFi_initiate handle.
█ THANKS
Many thanks to the following individuals, who - one way or another - made the 'Bitcoin Power Law Bands' indicator possible:
• TradingView user 'capriole_charles', whose open-source 'Bitcoin Power Law Corridor' script was the basis for this indicator
• Harold Christopher Burger, whose Bitcoin’s natural long-term power-law corridor of growth article (2019) was the basis for the 'Bitcoin Power Law Corridor' script
• Bitcoin Forum user "Trololo", who posted the original power law model at Logarithmic (non-linear) regression - Bitcoin estimated value (2014)
BTC Power Law HistogramBased on "Bitcoin’s natural long-term power-law corridor of growth" by Harold Christopher Burger
Bitcoin Power Law CorridorOpen-source live tracker of Harold Burger's Bitcoin "Power Law Corridor".
Added optional chart fill and labels to show the percentage delta to the regression center-line, support and resistance.
Power Law S/RBerger's article on the Power Law Model for Bitcoin is a compelling read and gives the best evidence so far of the diminishing case for retracing below $3000, of a slowing market on a log-log plot, and reducing but continued volatility.
After seeing it acts as support routinely in the last 10 years, I put together a quick little script that plots his midline curve for Bitcoin. You can change the intercept and slope but will need to do your own calculations for other curves.
I hope you all like it.