Hurst Future Lines of Demarcation StrategyJ. M. Hurst introduced a concept in technical analysis known as the Future Line of Demarcation (FLD), which serves as a forward-looking tool by incorporating a simple yet profound line into future projections on a financial chart. Specifically, the FLD is constructed by offsetting the price half a cycle ahead into the future on the time axis, relative to the Hurst Cycle of interest. For instance, in the context of a 40 Day Cycle, the FLD would be represented by shifting the current price data 20 days forward on the chart, offering an idea of future price movement anticipations.
The utility of FLDs extends into three critical areas of insight, which form the backbone of the FLD Trading Strategy:
A price crossing the FLD signifies the confirmation of either a peak or trough formation, indicating pivotal moments in price action.
Such crossings also help determine precise price targets for the upcoming peak or trough, aligned with the cycle of examination.
Additionally, the occurrence of a peak in the FLD itself signals a probable zone where the price might experience a trough, helping to anticipate of future price movements.
These insights by Hurst in his "Cycles Trading Course" during the 1970s, are instrumental for traders aiming to determine entry and exit points, and to forecast potential price movements within the market.
To use the FLD Trading Strategy, for example when focusing on the 40 Day Cycle, a trader should primarily concentrate on the interplay between three Hurst Cycles:
The 20 Day FLD (Signal) - Half the length of the Trade Cycle
The 40 Day FLD (Trade) - The Cycle you want to trade
The 80 Day FLD (Trend) - Twice the length of the Trade Cycle
Traders can gauge trend or consolidation by watching for two critical patterns:
Cascading patterns, characterized by several FLDs running parallel with a consistent separation, typically emerge during pronounced market trends, indicating strong directional momentum.
Consolidation patterns, on the other hand, occur when multiple FLDs intersect and navigate within the same price bandwidth, often reversing direction to traverse this range multiple times. This tangled scenario results in the formation of Pause Zones, areas where price momentum is likely to temporarily stall or where the emergence of a significant trend might be delayed.
This simple FLD indicator provides 3 FLDs with optional source input and smoothing, A-through-H FLD interaction background, adjustable “Close the Trade” triggers, and a simple strategy for backtesting it all.
The A-through-H FLD interactions are a framework designed to classify the different types of price movements as they intersect with or diverge from the Future Line of Demarcation (FLD). Each interaction (designated A through H by color) represents a specific phase or characteristic within the cycle, and understanding these can help traders anticipate future price movements and make informed decisions.
The adjustable “Close the Trade” triggers are for setting the crossover/under that determines the trade exits. The options include: Price, Signal FLD, Trade FLD, or Trend FLD. For example, a trader may want to exit trades only when price finally crosses the Trade FLD line.
Shoutouts & Credits for all the raw code, helpful information, ideas & collaboration, conversations together, introductions, indicator feedback, and genuine/selfless help:
🏆 @TerryPascoe
🏅 @Hpotter
👏 @parisboy
Hurst
Hurst Spectral Analysis SwamiChartHaving a hard time deciding which wavelength to use for a Hurst analysis? Try a handful at once! SwamiCharts by John Ehlers offers a comprehensive way to visualize an indicator used over a range of lookback periods. The Spectral Analysis SwamiChart shows the bullish or bearish state of a spectrum of bandpasses over a user-defined range of wavelengths. The trader simply selects a bandwidth, a base wavelength, and a step/multiple to see the Spectral Analysis SwamiChart. A vertical column of green or red tends to indicate a very bullish or bearish moment in time, meaning that all bandpasses in the analyzed spectrum are in a bullish or bearish orientation simultaneously.
🏆 Shoutout to DavidF at Sigma-L for all the helpful information, conversations together, & indicator feedback.
🏅Shoutout to @HPotter for the bandpass code, and shoutout to @TerryPascoe for sharing it with me
Dominant Cycle Detection OscillatorThis is a Dominant Cycle Detection Oscillator that searches multiple ranges of wavelengths within a spectrum. Choose one of 4 different dominant cycle detection methods (MESA MAMA cycle, Pearson Autocorrelation, Discreet Fourier Transform, and Phase Accumulation) to determine the most dominant cycles and see the historical results. Straight lines can indicate a steady dominant cycle; while Wavy lines might indicate a varying dominant cycle length. The steadier the cycle, the easier it may be to predict future events in that cycle (keep the log scale in mind when considering steadiness). The presence of evenly divisible (or harmonic) cycle lengths may also indicate stronger cycles; for example, 19, 38, and 76 dominant lengths for the 2x, 4x, and 8x cycles. Practically, a trader can use these cycle outputs as the default settings for other Hurst/cycle indicators. For example, if you see dominant cycle oscillator outputs of 38 & 76 for the 4x and 8x cycle respectively, you might want to test/use defaults of 38 & 76 for the 4x & 8x lengths in the bandpass, diamond/semi-circle notation, moving average & envelope, and FLD instead of the defaults 40 & 80 for a more fine-tuned analysis.
Muting the oscillator's historical lines and overlaying the indicator on the chart can visually cue a trader to the cycle lengths without taking up extra panes. The DFT Cycle lengths with muted historical lines have been overlayed on the chart in the photo.
The y-axis scale for this indicator's pane (just the oscillator pane, not the chart) most likely needs to be changed to logarithmic to look normal, but it depends on the search ranges in your settings. There are instructions in the settings. In the photo, the MESA MAMA scale is set to regular (not logarithmic) which demonstrates how difficult it can be to read if not changed.
In the Spectral Analysis chapter of Hurst's book Profit Magic, he recommended doing a Fourier analysis across a spectrum of frequencies. Hurst acknowledged there were many ways to do this analysis but recommended the method described by Lanczos. Currently in this indicator, the closest thing to the method described by Lanczos is the DFT Discreet Fourier Transform method.
Shoutout to @lastguru for the dominant cycle library referenced in this code. He mentioned that he may add more methods in the future.
Hurst Spectral Analysis Oscillator"It is a true fact that any given time history of any event (including the price history of a stock) can always be considered as reproducible to any desired degree of accuracy by the process of algebraically summing a particular series of sine waves. This is intuitively evident if you start with a number of sine waves of differing frequencies, amplitudes, and phases, and then sum them up to get a new and more complex waveform." (Spectral Analysis chapter of J M Hurst's book, Profit Magic )
Background: A band-pass filter or bandpass filter is a device that passes frequencies within a certain range and rejects (attenuates) frequencies outside that range. Bandpass filters are widely used in wireless transmitters and receivers. Well-designed bandpass filters (having the optimum bandwidth) maximize the number of signal transmitters that can exist in a system while minimizing the interference or competition among signals. Outside of electronics and signal processing, other examples of the use of bandpass filters include atmospheric sciences, neuroscience, astronomy, economics, and finance.
About the indicator: This indicator will accept float/decimal length inputs to display a spectrum of 11 bandpass filters. The trader can select a single bandpass for analysis that includes future high/low predictions. The trader can also select which bandpasses contribute to a composite model of expected price action.
10 Statements to describe the 5 elements of Hurst's price-motion model:
Random events account for only 2% of the price change of the overall market and of individual issues.
National and world historical events influence the market to a negligible degree.
Foreseeable fundamental events account for about 75% of all price motion. The effect is smooth and slow changing.
Unforeseeable fundamental events influence price motion. They occur relatively seldom, but the effect can be large and must be guarded against.
Approximately 23% of all price motion is cyclic in nature and semi-predictable (basis of the "cyclic model").
Cyclicality in price motion consists of the sum of a number of (non-ideal) periodic cyclic "waves" or "fluctuations" (summation principle).
Summed cyclicality is a common factor among all stocks (commonality principle).
Cyclic component magnitude and duration fluctuate slowly with the passage of time. In the course of such fluctuations, the greater the magnitude, the longer the duration and vice-versa (variation principle).
Principle of nominality: an element of commonality from which variation is expected.
The greater the nominal duration of a cyclic component, the larger the nominal magnitude (principle of proportionality).
Shoutouts & Credits for all the raw code, helpful information, ideas & collaboration, conversations together, introductions, indicator feedback, and genuine/selfless help:
🏆 @TerryPascoe
🏅 DavidF at Sigma-L, and @HPotter
👏 @Saviolis, parisboy, and @upslidedown
Hurst Diamond Notation PivotsThis is a fairly simple indicator for diamond notation of past hi/lo pivot points, a common method in Hurst analysis. The diamonds mark the troughs/peaks of each cycle. They are offset by their lookback and thus will not 'paint' until after they happen so anticipate accordingly. Practically, traders can use the average length of past pivot periods to forecast future pivot periods in time🔮. For example, if the average/dominant number of bars in an 80-bar pivot point period/cycle is 76, then a trader might forecast that the next pivot could occur 76-ish bars after the last confirmed pivot. The numbers/labels on the y-axis display the cycle length used for pivot detection. This indicator doesn't repaint, but it has a lot of lag; Please use it for forecasting instead of entry signals. This indicator scans for new pivots in the form of a rainbow line and circle; once the hi/lo has happened and the lookback has passed then the pivot will be plotted. The rainbow color per wavelength theme seems to be authentic to Hurst (or modern Hurst software) and has been included as a default.
Hurst Exponent (Dubuc's variation method)Library "Hurst"
hurst(length, samples, hi, lo)
Estimate the Hurst Exponent using Dubuc's variation method
Parameters:
length : The length of the history window to use. Large values do not cause lag.
samples : The number of scale samples to take within the window. These samples are then used for regression. The minimum value is 2 but 3+ is recommended. Large values give more accurate results but suffer from a performance penalty.
hi : The high value of the series to analyze.
lo : The low value of the series to analyze.
The Hurst Exponent is a measure of fractal dimension, and in the context of time series it may be interpreted as indicating a mean-reverting market if the value is below 0.5 or a trending market if the value is above 0.5. A value of exactly 0.5 corresponds to a random walk.
There are many definitions of fractal dimension and many methods for its estimation. Approaches relying on calculation of an area, such as the Box Counting Method, are inappropriate for time series data, because the units of the x-axis (time) do match the units of the y-axis (price). Other approaches such as Detrended Fluctuation Analysis are useful for nonstationary time series but are not exactly equivalent to the Hurst Exponent.
This library implements Dubuc's variation method for estimating the Hurst Exponent. The technique is insensitive to x-axis units and is therefore useful for time series. It will give slightly different results to DFA, and the two methods should be compared to see which estimator fits your trading objectives best.
Original Paper:
Dubuc B, Quiniou JF, Roques-Carmes C, Tricot C. Evaluating the fractal dimension of profiles. Physical Review A. 1989;39(3):1500-1512. DOI: 10.1103/PhysRevA.39.1500
Review of various Hurst Exponent estimators for time-series data, including Dubuc's method:
www.intechopen.com
HurstExponentLibrary "HurstExponent"
Library to calculate Hurst Exponent refactored from Hurst Exponent - Detrended Fluctuation Analysis
demean(src) Calculates a series subtracted from the series mean.
Parameters:
src : The series used to calculate the difference from the mean (e.g. log returns).
Returns: The series subtracted from the series mean
cumsum(src, length) Calculates a cumulated sum from the series.
Parameters:
src : The series used to calculate the cumulative sum (e.g. demeaned log returns).
length : The length used to calculate the cumulative sum (e.g. 100).
Returns: The cumulative sum of the series as an array
aproximateLogScale(scale, length) Calculates an aproximated log scale. Used to save sample size
Parameters:
scale : The scale to aproximate.
length : The length used to aproximate the expected scale.
Returns: The aproximated log scale of the value
rootMeanSum(cumulativeSum, barId, numberOfSegments) Calculates linear trend to determine error between linear trend and cumulative sum
Parameters:
cumulativeSum : The cumulative sum array to regress.
barId : The barId for the slice
numberOfSegments : The total number of segments used for the regression calculation
Returns: The error between linear trend and cumulative sum
averageRootMeanSum(cumulativeSum, barId, length) Calculates the Root Mean Sum Measured for each block (e.g the aproximated log scale)
Parameters:
cumulativeSum : The cumulative sum array to regress and determine the average of.
barId : The barId for the slice
length : The length used for finding the average
Returns: The average root mean sum error of the cumulativeSum
criticalValues(length) Calculates the critical values for a hurst exponent for a given length
Parameters:
length : The length used for finding the average
Returns: The critical value, upper critical value and lower critical value for a hurst exponent
slope(cumulativeSum, length) Calculates the hurst exponent slope measured from root mean sum, scaled to log log plot using linear regression
Parameters:
cumulativeSum : The cumulative sum array to regress and determine the average of.
length : The length used for the hurst exponent sample size
Returns: The slope of the hurst exponent
smooth(src, length) Smooths input using advanced linear regression
Parameters:
src : The series to smooth (e.g. hurst exponent slope)
length : The length used to smooth
Returns: The src smoothed according to the given length
exponent(src, hurstLength) Wrapper function to calculate the hurst exponent slope
Parameters:
src : The series used for returns calculation (e.g. close)
hurstLength : The length used to calculate the hurst exponent (should be greater than 50)
Returns: The src smoothed according to the given length
Hurst ExponentMy first try to implement Full Hurst Exponent.
The Hurst exponent is used as a measure of long-term memory of time series. It relates to the autocorrelations of the time series and the rate at which these decrease as the lag between pairs of values increases
The Hurst exponent is referred to as the "index of dependence" or "index of long-range dependence". It quantifies the relative tendency of a time series either to regress strongly to the mean or to cluster in a direction.
In short, depending on the value you can spot the trending / reversing market.
Values 0.5 to 1 - market trending
Values 0 to 0.5 - market tend to mean revert
Hurst Exponent is computed using Rescaled range (R/S) analysis.
I split the lookback period (N) in the number of shorter samples (for ex. N/2, N/4, N/8, etc.). Then I calculate rescaled range for each sample size.
The Hurst exponent is estimated by fitting the power law. Basically finding the slope of log(samples_size) to log(RS).
You can choose lookback and sample sizes yourself. Max 8 possible at the moment, if you want to use less use 0 in inputs.
It's pretty computational intensive, so I added an input so you can limit from what date you want it to be calculated. If you hit the time limit in PineScript - limit the history you're using for calculations.
####################
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 good as in historical backtesting.
This post and the script don’t provide any financial advice.
Simple Hurst Exponent [QuantNomad]This is a simplified version of the Hurst Exponent indicator.
In the meantime, I'm working on the full version. It's computationally intensive, so it's a challenge to squeeze it to PineScript limits. It will require some time to optimize it, so I decided to publish a simplified version for now.
The Hurst exponent is used as a measure of long-term memory of time series. It relates to the autocorrelations of the time series, and the rate at which these decrease as the lag between pairs of values increases
The Hurst exponent is referred to as the "index of dependence" or "index of long-range dependence". It quantifies the relative tendency of a time series either to regress strongly to the mean or to cluster in a direction.
In short depend on value you can spot trending / reversing market.
Values 0.5 to 1 - market trending
Values 0 to 0.5 - market tend to mean revert
####################
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 good as in historical backtesting.
This post and the script don’t provide any financial advice.
[blackcat] L2 Ehlers Hurst Coefficient IndicatorLevel: 2
Background
John F. Ehlers introuced Hurst Coefficient Indicator in his "Cycle Analytics for Traders" chapter 6 on 2013.
Function
The Hurst coefficient is one way to attempt to get a handle on the slope of the power density of market data. The Hurst coefficient varies between 0 and 1, and is related to the α power coefficient as H = 1 − α/2. The Hurst coefficient is more estimated than computed. Dr. Ehlers found the estimate using the fractal dimension was the most practical for shorter-term market data. The Hurst coefficient is related to the fractal dimension as H = 2 − D. Dr. Ehlers would like to make it perfectly clear that the Hurst coefficient or the fractal dimension has no direct practical application to trading not only because it is an estimate, but also because it has no predictive value. These computations only reflect the general structure of the market, and the answer you get is dependent on your assumptions. For example, the Hurst coefficient changes dramatically with the length of data used in making the estimate.
The only user input is the length of data to be used. The number can be arbitrarily large if you have sufficient data. The results are critically dependent on the input data length selected. After declaring variables, the coefficients of a 20-bar SuperSmoother filter are computed. The computations of N1, N2, and N3 are as described in the previous section. The fractal dimension is then converted to the Hurst coefficient, which is subsequently smoothed in the SuperSmoother filter.
Key Signal
SmoothHurst --> Hurst Coefficient Indicator fast line
Trigger --> Hurst Coefficient Indicator slow line
Pros and Cons
100% John F. Ehlers definition translation of original work, even variable names are the same. This help readers who would like to use pine to read his book. If you had read his works, then you will be quite familiar with my code style.
Remarks
The 40th script for Blackcat1402 John F. Ehlers Week publication.
Readme
In real life, I am a prolific inventor. I have successfully applied for more than 60 international and regional patents in the past 12 years. But in the past two years or so, I have tried to transfer my creativity to the development of trading strategies. Tradingview is the ideal platform for me. I am selecting and contributing some of the hundreds of scripts to publish in Tradingview community. Welcome everyone to interact with me to discuss these interesting pine scripts.
The scripts posted are categorized into 5 levels according to my efforts or manhours put into these works.
Level 1 : interesting script snippets or distinctive improvement from classic indicators or strategy. Level 1 scripts can usually appear in more complex indicators as a function module or element.
Level 2 : composite indicator/strategy. By selecting or combining several independent or dependent functions or sub indicators in proper way, the composite script exhibits a resonance phenomenon which can filter out noise or fake trading signal to enhance trading confidence level.
Level 3 : comprehensive indicator/strategy. They are simple trading systems based on my strategies. They are commonly containing several or all of entry signal, close signal, stop loss, take profit, re-entry, risk management, and position sizing techniques. Even some interesting fundamental and mass psychological aspects are incorporated.
Level 4 : script snippets or functions that do not disclose source code. Interesting element that can reveal market laws and work as raw material for indicators and strategies. If you find Level 1~2 scripts are helpful, Level 4 is a private version that took me far more efforts to develop.
Level 5 : indicator/strategy that do not disclose source code. private version of Level 3 script with my accumulated script processing skills or a large number of custom functions. I had a private function library built in past two years. Level 5 scripts use many of them to achieve private trading strategy.
Ehlers Hurst Coefficient [CC]The Hurst Coefficient was created by John Ehlers (Cycle Analytics For Traders pgs 67-68) and this is a very useful indicator to tell you if the stock is in a uptrend or downtrend. Feel free to change the length to experiment and to adjust to your needs. Buy when the indicator line is green and sell when it is red.
Let me know if there are other indicators you would like to see me publish or if you want something custom done!
Hurst ExponentThis is an aproximation on Tradingview of the Hurst Exponent.
Its quite computational expensive, so it has been simplify and sample size reduced.
If any has an idea on how to create the real Hurst Exponent here, Ill be happy to hear and help.
Hurst Cycle Channel Clone %BA %B of lazy bears Hurst Cycle Channel Clone
Remember to thank him for his great scripts.
With this you can easily see when the close is above,below or in the short or medium cycle channel.
HurstCycles PeaksOnly way I found to plot hurst cycles. I gave up on anything other than daily chart.
Published on request.
HurstCycles ThroughsOnly way I found to plot hurst cycles. I gave up on anything other than daily chart.
Published on request.
Hurst Exponent Market Phases [DW]This study is an experiment designed to identify market phases using changes in an approximate Hurst Exponent.
The exponent in this script is approximated using a simplified Rescaled Range method.
First, deviations are calculated for the specified period, then the specified period divided by 2, 4, 8, and 16.
Next, sums are taken of the deviations of each period, and the difference between the maximum and minimum sum gives the widest spread.
The rescaled range is calculated by dividing the widest spread by the standard deviation of price over the specified period.
The Hurst Exponent is then approximated by dividing log(rescaled range) by log(n).
The theory is that a system is persistent when the Hurst Exponent value is above 0.5, and antipersistent when the value is below 0.5.
The color scheme indicates 4 different phases I found to be significant in this formula:
- Stabilization Phase
- Destabilization Phase
- Chaos Increase Phase
- Chaos Decrease Phase
This script includes two visualization types to choose from:
- Bar Counter Mode, which displays the number of bars the exponent is consecutively in each phase.
- Hurst Approximation Mode, which displays the approximated exponent value.
Custom bar colors are included.
Please note: This is a rough estimate of the Hurst Exponent. It is not the actual exponent. Numerous approximations exist, and their results all differ slightly.
Cycle Channel Oscillator [LazyBear]Here's an oscillator derived from my previous script, Cycle Channel Clone ().
There are 2 oscillator plots - fast & slow. Fast plot shows the price location with in the medium term channel, while slow plot shows the location of short term midline of cycle channel with respect to medium term channel.
Usage of this is similar to %b oscillator. The slow plot can be considered as the signal line.
Bar colors can be enabled via options page. When short plot is above 1.0 or below 0, they are marked purple (both histo and the bar color) to highlight the extreme condition.
This makes use of the default 10/30 values of Cycle Channel, but may need tuning for your instrument.
More info:
List of my free indicators: bit.ly
List of my app-store indicators: blog.tradingview.com (More info: bit.ly)
Hurst Cycle Channel Clone [LazyBear]Cycle Channel is loosely based on Hurst's nested channels. Basic idea is to identify and highlight the shorter cycles, in the context of higher degree cycles.
This indicator plots the shorter term (red) & medium term (green) cycles as channels. Some things to note:
As you can see the red channel keeps moving with in the bounds of green channel. When green breaches red channel, it usually signifies extreme market condition.
Both red & green channels provide support/resistance levels. Also, the green channel provides S/R levels to the inner red channel.
Movement of red channel with reference to green highlights reversal points, reducing momentum et al. For ex., point "(x)" in the chart shows how red channel failed to reach the upper green channel line and highlighted the local top.
Use this just like other bands/channels. I have more indicators derived from this idea, will post them later.
Some more examples:
---------------------------------
MSFT 1M:
DXY 1M:
IWM 1M:
More info:
------------
cyclicwave.blogspot.com
List of my free indicators: bit.ly
List of my app-store indicators: blog.tradingview.com
(Support doc: bit.ly)
Indicators: Hurst Bands and Hurst OscillatorThese 2 indicators are derivative work from Jim Hurst's book - "The Magic of Stock Transaction Timing".
The bands are % bands around a median that gets calculated according to Hurst's formula. The outer bands (called ExtremeBands) signify extreme overbought/oversold conditions. Inner bands signify potential pullback points. As you can see, they also act as dynamic S/R levels.
The oscillator bands match the bands overlaid on price, so you will get an excellent indication of where the price is gonna do by using the oscillator along with the bands. Note that Hurst Oscillator can be used separately too, there is no technical dependency on Hurst Bands.
More info on Hurst Method:
www.readtheticker.com