Weierstrass Function (Fractal Cycles)THE WEIERSTRASS FUNCTION
f(x) = ∑(n=0)^∞ a^n * cos(b^n * π * x)
The Weierstrass Function is the sum of an infinite series of cosine functions, each with increasing frequency and decreasing amplitude. This creates powerful multi-scale oscillations within the range ⬍(-2;+2), resembling a system of self-repetitive patterns. You can zoom into any part of the output and observe similar proportions, mimicking the hidden order behind the irregularity and unpredictability of financial markets.
IT DOESN’T RELY ON ANY MARKET DATA, AS THE OUTPUT IS BASED PURELY ON A MATHEMATICAL FORMULA!
This script does not provide direct buy or sell signals and should be used as a tool for analyzing the market behavior through fractal geometry. The function is often used to model complex, chaotic systems, including natural phenomena and financial markets.
APPLICATIONS:
Timing Aspect: Identifies the phases of market cycles, helping to keep awareness of frequency of turning points
Price-Modeling features: The Amplitude, frequency, and scaling settings allow the indicator to simulate the trends and oscillations. Its nowhere-differentiable nature aligns with the market's inherent uncertainty. The fractured oscillations resemble sharp jumps, noise, and dips found in volatile markets.
SETTINGS
Amplitude Factor (a): Controls the size of each wave. A higher value makes the waves larger.
Frequency Factor (b): Determines how fast the waves oscillate. A higher value creates more frequent waves.
Ability to Invert the output: Just like any cosine function it starts its journey with a decline, which is not distinctive to the behavior of most assets. The default setting is in "inverted mode".
Scale Factor: Adjusts the speed at which the oscillations grow over time.
Number of Terms (n_terms): Increases the number of waves. More terms add complexity to the pattern.

# Chaos

WIPFunctionLyaponovLibrary "WIPFunctionLyaponov"
Lyapunov exponents are mathematical measures used to describe the behavior of a system over
time. They are named after Russian mathematician Alexei Lyapunov, who first introduced the concept in the
late 19th century. The exponent is defined as the rate at which a particular function or variable changes
over time, and can be positive, negative, or zero.
Positive exponents indicate that a system tends to grow or expand over time, while negative exponents
indicate that a system tends to shrink or decay. Zero exponents indicate that the system does not change
significantly over time. Lyapunov exponents are used in various fields of science and engineering, including
physics, economics, and biology, to study the long-term behavior of complex systems.
~ generated description from vicuna13b
---
To calculate the Lyapunov Exponent (LE) of a given Time Series, we need to follow these steps:
1. Firstly, you should have access to your data in some format like CSV or Excel file. If not, then you can collect it manually using tools such as stopwatches and measuring tapes.
2. Once the data is collected, clean it up by removing any outliers that may skew results. This step involves checking for inconsistencies within your dataset (e.g., extremely large or small values) and either discarding them entirely or replacing with more reasonable estimates based on surrounding values.
3. Next, you need to determine the dimension of your time series data. In most cases, this will be equal to the number of variables being measured in each observation period (e.g., temperature, humidity, wind speed).
4. Now that we have a clean dataset with known dimensions, we can calculate the LE for our Time Series using the following formula:
λ = log(||M^T * M - I||)/log(||v||)
where:
λ (Lyapunov Exponent) is the quantity that will be calculated.
||...|| denotes an Euclidean norm of a vector or matrix, which essentially means taking the square root of the sum of squares for each element in the vector/matrix.
M represents our Jacobian Matrix whose elements are given by:
J_ij = (∂fj / ∂xj) where fj is the jth variable and xj is the ith component of the initial condition vector x(t). In other words, each element in this matrix represents how much a small change in one variable affects another.
I denotes an identity matrix whose elements are all equal to 1 (or any constant value if you prefer). This term essentially acts as a baseline for comparison purposes since we want our Jacobian Matrix M^T * M to be close to it when the system is stable and far away from it when the system is unstable.
v represents an arbitrary vector whose Euclidean norm ||v|| will serve as a scaling factor in our calculation. The choice of this particular vector does not matter since we are only interested in its magnitude (i.e., length) for purposes of normalization. However, if you want to ensure that your results are accurate and consistent across different datasets or scenarios, it is recommended to use the same initial condition vector x(t) as used earlier when calculating our Jacobian Matrix M.
5. Finally, once we have calculated λ using the formula above, we can interpret its value in terms of stability/instability for our Time Series data:
- If λ < 0, then this indicates that the system is stable (i.e., nearby trajectories will converge towards each other over time).
- On the other hand, if λ > 0, then this implies that the system is unstable (i.e., nearby trajectories will diverge away from one another over time).
~ generated description from airoboros33b
---
Reference:
en.wikipedia.org
www.collimator.ai
blog.abhranil.net
www.researchgate.net
physics.stackexchange.com
---
This is a work in progress, it may contain errors so use with caution.
If you find flaws or suggest something new, please leave a comment bellow.
_measure_function(i)
helper function to get the name of distance function by a index (0 -> 13).\
Functions: SSD, Euclidean, Manhattan, Minkowski, Chebyshev, Correlation, Cosine, Camberra, MAE, MSE, Lorentzian, Intersection, Penrose Shape, Meehl.
Parameters:
i (int)
_test(L)
Helper function to test the output exponents state system and outputs description into a string.
Parameters:
L (float )
estimate(X, initial_distance, distance_function)
Estimate the Lyaponov Exponents for multiple series in a row matrix.
Parameters:
X (map)
initial_distance (float) : Initial distance limit.
distance_function (string) : Name of the distance function to be used, default:`ssd`.
Returns: List of Lyaponov exponents.
max(L)
Maximal Lyaponov Exponent.
Parameters:
L (float ) : List of Lyapunov exponents.
Returns: Highest exponent.

Musashi_Fractal_Dimension === Musashi-Fractal-Dimension ===
This tool is part of my research on the fractal nature of the markets and understanding the relation between fractal dimension and chaos theory.
To take full advantage of this indicator, you need to incorporate some principles and concepts:
- Traditional Technical Analysis is linear and Euclidean, which makes very difficult its modeling.
- Linear techniques cannot quantify non-linear behavior
- Is it possible to measure accurately a wave or the surface of a mountain with a simple ruler?
- Fractals quantify what Euclidean Geometry can’t, they measure chaos, as they identify order in apparent randomness.
- Remember: Chaos is order disguised as randomness.
- Chaos is the study of unstable aperiodic behavior in deterministic non-linear dynamic systems
- Order and randomness can coexist, allowing predictability.
- There is a reason why Fractal Dimension was invented, we had no way of measuring fractal-based structures.
- Benoit Mandelbrot used to explain it by asking: How do we measure the coast of Great Britain?
- An easy way of getting the need of a dimension in between is looking at the Koch snowflake.
- Market prices tend to seek natural levels of ranges of balance. These levels can be described as attractors and are determinant.
Fractal Dimension Index ('FDI')
Determines the persistence or anti-persistence of a market.
- A persistent market follows a market trend. An anti-persistent market results in substantial volatility around the trend (with a low r2), and is more vulnerable to price reversals
- An easy way to see this is to think that fractal dimension measures what is in between mainstream dimensions. These are:
- One dimension: a line
- Two dimensions: a square
- Three dimensions: a cube.
--> This will hint you that at certain moment, if the market has a Fractal Dimension of 1.25 (which is low), the market is behaving more “line-like”, while if the market has a high Fractal Dimension, it could be interpreted as “square-like”.
- 'FDI' is trend agnostic, which means that doesn't consider trend. This makes it super useful as gives you clean information about the market without trying to include trend stuff.
Question: If we have a game where you must choose between two options.
1. a horizontal line
2. a vertical line.
Each iteration a Horizontal Line or a Square will appear as continuation of a figure. If it that iteration shows a square and you bet vertical you win, same as if it is horizontal and it is a line.
- Wouldn’t be useful to know that Fractal dimension is 1.8? This will hint square. In the markets you can use 'FD' to filter mean-reversal signals like Bollinger bands, stochastics, Regular RSI divergences, etc.
- Wouldn’t be useful to know that Fractal dimension is 1.2? This will hint Line. In the markets you can use 'FD' to confirm trend following strategies like Moving averages, MACD, Hidden RSI divergences.
Calculation method:
Fractal dimension is obtained from the ‘hurst exponent’.
'FDI' = 2 - 'Hurst Exponent'
Musashi version of the Classic 'OG' Fractal Dimension Index ('FDI')
- By default, you get 3 fast 'FDI's (11,12,13) + 1 Slow 'FDI' (21), their interaction gives useful information.
- Fast 'FDI' cross will give you gray or red dots while Slow 'FDI' cross with the slowest of the fast 'FDI's will give white and orange dots. This are great to early spot trend beginnings or trend ends.
- A baseline (purple) is also provided, this is calculated using a 21 period Bollinger bands with 1.618 'SD', once calculated, you just take midpoint, this is the 'TDI's (Traders Dynamic Index) way. The indicator will print purple dots when Slow 'FDI' and baseline crosses, I see them as Short-Term cycle changes.
- Negative slope 'FDI' means trending asset.
- Positive most of the times hints correction, but if it got overextended it might hint a rocket-shot.
TDI Ranges:
- 'FDI' between 1.0≤ 'FDI' ≤1.4 will confirm trend following continuation signals.
- 'FDI' between 1.6≥ 'FDI' ≥2.0 will confirm reversal signals.
- 'FDI' == 1.5 hints a random unpredictable market.
Fractal Attractors
- As you must know, fractals tend orbit certain spots, this are named Attractors, this happens with any fractal behavior. The market of course also shows them, in form of Support & Resistance, Supply Demand, etc. It’s obvious they are there, but now we understand that they’re not linear, as the market is fractal, so simple trendline might not be the best tool to model this.
- I’ve noticed that when the Musashi version of the 'FDI' indicator start making a cluster of multicolor dots, this end up being an attractor, I tend to draw a rectangle as that area as price tend to come back (I still researching here).
Extra useful stuff
- Momentum / speed: Included by checking RSI Study in the indicator properties. This will add two RSI’s (9 and a 7 periods) plus a baseline calculated same way as explained for 'FDI'. This gives accurate short-term trends. It also includes RSI divergences (regular and hidden), deactivate with a simple check in the RSI section of the properties.
- BBWP (Bollinger Bands with Percentile): Efficient way of visualizing volatility as the percentile of Bollinger bands expansion. This line varies color from Iced blue when low volatility and magma red when high. By default, comes with the High vols deactivated for better view of 'FDI' and RSI while all studies are included. DDWP is trend agnostic, just like 'FDI', which make it very clean at providing information.
- Ultra Slow 'FDI': I noticed that while using BBWP and RSI, the indicator gets overcrowded, so there is the possibility of adding only one 'FDI' + its baseline.
Final Note: I’ve shown you few ways of using this indicator, please backtest before using in real trading. As you know trading is more about risk and trade management than the strategy used. This still a work in progress, I really hope you find value out of it. I use it combination with a tool named “Musashi_Katana” (also found in TradingView).
Best!
Musashi

Lyapunov Hodrick-Prescott Oscillator w/ DSL [Loxx]Lyapunov Hodrick-Prescott Oscillator w/ DSL is a Hodrick-Prescott Channel Filter that is modified using the Lyapunov stability algorithm to turn the filter into an oscillator. Signals are created using Discontinued Signal Lines.
What is the Lyapunov Stability?
As soon as scientists realized that the evolution of physical systems can be described in terms of mathematical equations, the stability of the various dynamical regimes was recognized as a matter of primary importance. The interest for this question was not only motivated by general curiosity, but also by the need to know, in the XIX century, to what extent the behavior of suitable mechanical devices remains unchanged, once their configuration has been perturbed. As a result, illustrious scientists such as Lagrange, Poisson, Maxwell and others deeply thought about ways of quantifying the stability both in general and specific contexts. The first exact definition of stability was given by the Russian mathematician Aleksandr Lyapunov who addressed the problem in his PhD Thesis in 1892, where he introduced two methods, the first of which is based on the linearization of the equations of motion and has originated what has later been termed Lyapunov exponents (LE). (Lyapunov 1992)
The interest in it suddenly skyrocketed during the Cold War period when the so-called "Second Method of Lyapunov" (see below) was found to be applicable to the stability of aerospace guidance systems which typically contain strong nonlinearities not treatable by other methods. A large number of publications appeared then and since in the control and systems literature. More recently the concept of the Lyapunov exponent (related to Lyapunov's First Method of discussing stability) has received wide interest in connection with chaos theory . Lyapunov stability methods have also been applied to finding equilibrium solutions in traffic assignment problems.
In practice, Lyapunov exponents can be computed by exploiting the natural tendency of an n-dimensional volume to align along the n most expanding subspace. From the expansion rate of an n-dimensional volume, one obtains the sum of the n largest Lyapunov exponents. Altogether, the procedure requires evolving n linearly independent perturbations and one is faced with the problem that all vectors tend to align along the same direction. However, as shown in the late '70s, this numerical instability can be counterbalanced by orthonormalizing the vectors with the help of the Gram-Schmidt procedure (Benettin et al. 1980, Shimada and Nagashima 1979) (or, equivalently with a QR decomposition). As a result, the LE λi, naturally ordered from the largest to the most negative one, can be computed: they are altogether referred to as the Lyapunov spectrum.
The Lyapunov exponent "λ" , is useful for distinguishing among the various types of orbits. It works for discrete as well as continuous systems.
λ < 0
The orbit attracts to a stable fixed point or stable periodic orbit. Negative Lyapunov exponents are characteristic of dissipative or non-conservative systems (the damped harmonic oscillator for instance). Such systems exhibit asymptotic stability; the more negative the exponent, the greater the stability. Superstable fixed points and superstable periodic points have a Lyapunov exponent of λ = −∞. This is something akin to a critically damped oscillator in that the system heads towards its equilibrium point as quickly as possible.
λ = 0
The orbit is a neutral fixed point (or an eventually fixed point). A Lyapunov exponent of zero indicates that the system is in some sort of steady state mode. A physical system with this exponent is conservative. Such systems exhibit Lyapunov stability. Take the case of two identical simple harmonic oscillators with different amplitudes. Because the frequency is independent of the amplitude, a phase portrait of the two oscillators would be a pair of concentric circles. The orbits in this situation would maintain a constant separation, like two flecks of dust fixed in place on a rotating record.
λ > 0
The orbit is unstable and chaotic. Nearby points, no matter how close, will diverge to any arbitrary separation. All neighborhoods in the phase space will eventually be visited. These points are said to be unstable. For a discrete system, the orbits will look like snow on a television set. This does not preclude any organization as a pattern may emerge. Thus the snow may be a bit lumpy. For a continuous system, the phase space would be a tangled sea of wavy lines like a pot of spaghetti. A physical example can be found in Brownian motion. Although the system is deterministic, there is no order to the orbit that ensues.
For our purposes here, we transform the HP by applying Lyapunov Stability as follows:
output = math.log(math.abs(HP / HP ))
You can read more about Lyapunov Stability here: Measuring Chaos
What is. the Hodrick-Prescott Filter?
The Hodrick-Prescott (HP) filter refers to a data-smoothing technique. The HP filter is commonly applied during analysis to remove short-term fluctuations associated with the business cycle. Removal of these short-term fluctuations reveals long-term trends.
The Hodrick-Prescott (HP) filter is a tool commonly used in macroeconomics. It is named after economists Robert Hodrick and Edward Prescott who first popularized this filter in economics in the 1990s. Hodrick was an economist who specialized in international finance. Prescott won the Nobel Memorial Prize, sharing it with another economist for their research in macroeconomics.
This filter determines the long-term trend of a time series by discounting the importance of short-term price fluctuations. In practice, the filter is used to smooth and detrend the Conference Board's Help Wanted Index (HWI) so it can be benchmarked against the Bureau of Labor Statistic's (BLS) JOLTS, an economic data series that may more accurately measure job vacancies in the U.S.
The HP filter is one of the most widely used tools in macroeconomic analysis. It tends to have favorable results if the noise is distributed normally, and when the analysis being conducted is historical.
What are DSL Discontinued Signal Line?
A lot of indicators are using signal lines in order to determine the trend (or some desired state of the indicator) easier. The idea of the signal line is easy : comparing the value to it's smoothed (slightly lagging) state, the idea of current momentum/state is made.
Discontinued signal line is inheriting that simple signal line idea and it is extending it : instead of having one signal line, more lines depending on the current value of the indicator.
"Signal" line is calculated the following way :
When a certain level is crossed into the desired direction, the EMA of that value is calculated for the desired signal line
When that level is crossed into the opposite direction, the previous "signal" line value is simply "inherited" and it becomes a kind of a level
This way it becomes a combination of signal lines and levels that are trying to combine both the good from both methods.
In simple terms, DSL uses the concept of a signal line and betters it by inheriting the previous signal line's value & makes it a level.
Included:
Bar coloring
Alerts
Signals
Loxx's Expanded Source Types

OWRS VolatilililityBit of a fun indicator taking into the asset names and natural processes and also the fact that the crypto markets are (definitely) not run by weird occultists and naturalists. Looks for disturbances in price of these four key assets. Read into it what you will. Sometimes the clues are just in the names.
Things you will learn from this script:
1. Using security function to compare multiple assets in one indicator.
2. Using indexing to reference historic data.
3. Setting chart outputs such as color based on interrogation of a boolean.
4. To only go back 3-4 iterations of any repeatable sequence as chaos kicks in after 3.55 (Feigenbaum)
1. By extension only the last 3 or 4 candles are of any use in indicator creation.
2. I am almost definitely a pagan.
3. You were expecting this numbered list to go 1,2,3,4,5,6,7. na mate. Chaos.

Combo Backtest 123 Reversal & Fractal Chaos Oscillator This is combo strategies for get a cumulative signal.
First strategy
This System was created from the Book "How I Tripled My Money In The
Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
The strategy buys at market, if close price is higher than the previous close
during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
The strategy sells at market, if close price is lower than the previous close price
during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
Second strategy
The value of Fractal Chaos Oscillator is calculated as the difference between
the most subtle movements of the market. In general, its value moves between
-1.000 and 1.000. The higher the value of the Fractal Chaos Oscillator, the
more one can say that it follows a certain trend – an increase in prices trend,
or a decrease in prices trend.
Being an indicator expressed in a numeric value, traders say that this is an
indicator that puts a value on the trendiness of the markets. When the FCO reaches
a high value, they initiate the “buy” operation, contrarily when the FCO reaches a
low value, they signal the “sell” action. This is an excellent indicator to use in
intra-day trading.
WARNING:
- For purpose educate only
- This script to change bars colors.

Combo Strategy 123 Reversal & Fractal Chaos OscillatorThis is combo strategies for get a cumulative signal.
First strategy
This System was created from the Book "How I Tripled My Money In The
Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
The strategy buys at market, if close price is higher than the previous close
during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
The strategy sells at market, if close price is lower than the previous close price
during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
Second strategy
The value of Fractal Chaos Oscillator is calculated as the difference between
the most subtle movements of the market. In general, its value moves between
-1.000 and 1.000. The higher the value of the Fractal Chaos Oscillator, the
more one can say that it follows a certain trend – an increase in prices trend,
or a decrease in prices trend.
Being an indicator expressed in a numeric value, traders say that this is an
indicator that puts a value on the trendiness of the markets. When the FCO reaches
a high value, they initiate the “buy” operation, contrarily when the FCO reaches a
low value, they signal the “sell” action. This is an excellent indicator to use in
intra-day trading.
WARNING:
- For purpose educate only
- This script to change bars colors.

Combo Strategy 123 Reversal & Fractal Chaos Bands This is combo strategies for get a cumulative signal.
First strategy
This System was created from the Book "How I Tripled My Money In The
Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
The strategy buys at market, if close price is higher than the previous close
during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50.
The strategy sells at market, if close price is lower than the previous close price
during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
Second strategy
Stock market moves in a highly chaotic way, but at a larger scale, the movements
follow a certain pattern that can be applied to shorter or longer periods of time
and we can use Fractal Chaos Bands Indicator to identify those patterns. Basically,
the Fractal Chaos Bands Indicator helps us to identify whether the stock market is
trending or not. When a market is trending, the bands will have a slope and if market
is not trending the bands will flatten out. As the slope of the bands decreases, it
signifies that the market is choppy, insecure and variable. As the graph becomes more
and more abrupt, be it going up or down, the significance is that the market becomes
trendy, or stable. Fractal Chaos Bands Indicator is used similarly to other bands-indicator
(Bollinger bands for instance), offering trading opportunities when price moves above or
under the fractal lines.
The FCB indicator looks back in time depending on the number of time periods trader selected
to plot the indicator. The upper fractal line is made by plotting stock price highs and the
lower fractal line is made by plotting stock price lows. Essentially, the Fractal Chaos Bands
show an overall panorama of the price movement, as they filter out the insignificant fluctuations
of the stock price.
WARNING:
- For purpose educate only
- This script to change bars colors.

Fractal Chaos Oscillator Backtest The value of Fractal Chaos Oscillator is calculated as the difference between
the most subtle movements of the market. In general, its value moves between
-1.000 and 1.000. The higher the value of the Fractal Chaos Oscillator, the
more one can say that it follows a certain trend – an increase in prices trend,
or a decrease in prices trend.
Being an indicator expressed in a numeric value, traders say that this is an
indicator that puts a value on the trendiness of the markets. When the FCO reaches
a high value, they initiate the “buy” operation, contrarily when the FCO reaches a
low value, they signal the “sell” action. This is an excellent indicator to use in
intra-day trading.
You can change long to short in the Input Settings
WARNING:
- For purpose educate only
- This script to change bars colors.

Fractal Chaos Oscillator Strategy The value of Fractal Chaos Oscillator is calculated as the difference between
the most subtle movements of the market. In general, its value moves between
-1.000 and 1.000. The higher the value of the Fractal Chaos Oscillator, the
more one can say that it follows a certain trend – an increase in prices trend,
or a decrease in prices trend.
Being an indicator expressed in a numeric value, traders say that this is an
indicator that puts a value on the trendiness of the markets. When the FCO reaches
a high value, they initiate the “buy” operation, contrarily when the FCO reaches a
low value, they signal the “sell” action. This is an excellent indicator to use in
intra-day trading.
WARNING:
- This script to change bars colors.

Fractal Chaos Oscillator The value of Fractal Chaos Oscillator is calculated as the difference between
the most subtle movements of the market. In general, its value moves between
-1.000 and 1.000. The higher the value of the Fractal Chaos Oscillator, the
more one can say that it follows a certain trend – an increase in prices trend,
or a decrease in prices trend.
Being an indicator expressed in a numeric value, traders say that this is an
indicator that puts a value on the trendiness of the markets. When the FCO reaches
a high value, they initiate the “buy” operation, contrarily when the FCO reaches a
low value, they signal the “sell” action. This is an excellent indicator to use in
intra-day trading.

Fractal Chaos Bands Backtest The FCB indicator looks back in time depending on the number of time periods trader selected
to plot the indicator. The upper fractal line is made by plotting stock price highs and the
lower fractal line is made by plotting stock price lows. Essentially, the Fractal Chaos Bands
show an overall panorama of the price movement, as they filter out the insignificant fluctuations
of the stock price.
You can change long to short in the Input Settings
WARNING:
- For purpose educate only
- This script to change bars colors.

Fractal Chaos Bands Strategy Stock market moves in a highly chaotic way, but at a larger scale, the movements
follow a certain pattern that can be applied to shorter or longer periods of time
and we can use Fractal Chaos Bands Indicator to identify those patterns. Basically,
the Fractal Chaos Bands Indicator helps us to identify whether the stock market is
trending or not. When a market is trending, the bands will have a slope and if market
is not trending the bands will flatten out. As the slope of the bands decreases, it
signifies that the market is choppy, insecure and variable. As the graph becomes more
and more abrupt, be it going up or down, the significance is that the market becomes
trendy, or stable. Fractal Chaos Bands Indicator is used similarly to other bands-indicator
(Bollinger bands for instance), offering trading opportunities when price moves above or
under the fractal lines.
The FCB indicator looks back in time depending on the number of time periods trader selected
to plot the indicator. The upper fractal line is made by plotting stock price highs and the
lower fractal line is made by plotting stock price lows. Essentially, the Fractal Chaos Bands
show an overall panorama of the price movement, as they filter out the insignificant fluctuations
of the stock price.
WARNING:
- This script to change bars colors.

Fractal Chaos Bands Stock market moves in a highly chaotic way, but at a larger scale, the movements
follow a certain pattern that can be applied to shorter or longer periods of time
and we can use Fractal Chaos Bands Indicator to identify those patterns. Basically,
the Fractal Chaos Bands Indicator helps us to identify whether the stock market is
trending or not. When a market is trending, the bands will have a slope and if market
is not trending the bands will flatten out. As the slope of the bands decreases, it
signifies that the market is choppy, insecure and variable. As the graph becomes more
and more abrupt, be it going up or down, the significance is that the market becomes
trendy, or stable. Fractal Chaos Bands Indicator is used similarly to other bands-indicator
(Bollinger bands for instance), offering trading opportunities when price moves above or
under the fractal lines.
The FCB indicator looks back in time depending on the number of time periods trader selected
to plot the indicator. The upper fractal line is made by plotting stock price highs and the
lower fractal line is made by plotting stock price lows. Essentially, the Fractal Chaos Bands
show an overall panorama of the price movement, as they filter out the insignificant fluctuations
of the stock price.

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.

Bill Williams Divergent BarsBill William Bull/Bear divergent bars
See: Book, Trading Chaos by Bill Williams
Coded by polyclick
A bullish (green) divergent bar, signals a trend switch from bear -> bull
-> The current bar has a lower low than the previous bar, but closes in the upper half of the candle.
-> This means the bulls are pushing from below and are trying to take over, potentially resulting in a trend switch to bullish.
-> We also check if this bar is below the three alligator lines to avoid false positives.
A bearish (red) divergent bar, signals a trend switch from bull -> bear
-> The current bar has a higher high than the previous bar, but closes in the lower half of the candle.
-> This means the bears are pushing the price down and are taking over, potentially resulting in a trend switch to bearish.
-> We also check if this bar is above the three alligator lines to avoid false positives.
Best used in combination with the Bill Williams Alligator indicator.

Williams Gator Oscillator 2Based on @Petros Williams Gator Oscillator script
Modifed by @PolarSolar - fix histogramm offset to original and added different colors to more understanding Gator histogramm
The Gator Oscillator histogram above zero shows the absolute difference between blue and red lines of Alligator indicator,
while histogram below zero shows the absolute difference between red and green lines.
There are green and red bars on the Gator Oscillator histograms.
A green bar appears when its value is higher than the value of the previous bar.
A red bars appears when its value is lower than the value of the previous bar.
Gator Oscillator helps to better visualize the upcoming changes in the trends: to know when Alligator sleeps, eats, fills out and is about to go to sleep.

Chaos 2.0This is pure chaos!
I just wanted 1 thing I can put on a chart to try to get a clearer picture of what is going on (and not take up all the indicator spaces a free user is allowed haha)
Many things going on from so many different users
honestly I'm sorry I cant shout out everyone whose code I have ever read and used in another project just for the sake of learning more about pinescript!
As a way of shouting everyone out! (and giving out my most useful and configurable system)
I give you... CHAOS
I originally got an Alligator, AO, and Fractal script from a user ChaosTrader, then realized I love using averages!
I added the MESA (lazybear?) and the McGinley Dynamic Range (sry idk) and a simple 233 SMA.
I also found about something called the www.prorealcode.com another user had created for Pinescript.
I really liked that script so I adapted it to do the same kind of signal printing for circles and squares (crosses and series)
Check it out tell me what you think and how I can make it better for everyone!
thanks all!
Snoop

True Williams Alligator (Timeframe Multiplier)Modified version of my original "True Williams Alligator (SMMA)" indicator that includes a multiplier to show the alligator (ie elliot wave mode) of higher timeframes. See original indicator for details.
Note: First script submission. Didn't mean to use this chart. Ugly and messy. Oops.

True Williams Alligator (Timeframe Multiplier)Modified version of the true alligator indicator (ie SMMA) that features a timeframe multiplier so that you can monitor the elliott wave of higher timeframes. (See original "True Williams Alligator" for more details.)
Note: First script submission. Didn't mean to use this chart. Also this is a duplicate post -- oops.

True Williams Alligator (SMMA)The built-in implementation of the alligator is incorrect. It uses SMA with altered input parameters to approximate the true alligator indicator.
The alligator was created with a supercomputer to model the elliott wave - it's very apart from other MA techniques. The built-in approximation (and similar techniques) and the true alligator yield very different conclusions. Hence the need for this, a true and exact implementation of "The Mighty Alligator" (Bill Williams, Trading Chaos 1, New Trading Dimensions, Trading Chaos 2).
Note: First script submission. Didn't mean to use this chart. Ugly and messy. Oops.

ZoneBarsBill Williams Zone and Squat Bars. See New Trading Dimensions by Bill Williams, PhD.
Bars are green (green zone) when the Awesome Oscillator and Accelerator/Decelerator are both positive.
Bars are red (red zone) when the Awesome Oscillator and Accelerator/Decelerator are both negative.
Bars are blue when a squat bar is formed, these indicate a battle between bulls and bears and often happen near trend continuation or trend changes.
Caution: Assumes chart is a bar chart - not a candle chart.
Caution: Squat bars are accurate only with official exchange volume data - BATS data will give false squat bars.

ZoneBarsBill Williams Zone and Squat Bars. See New Trading Dimensions by Bill Williams, PhD.
Bars are green (green zone) when the Awesome Oscillator and Accelerator/Decelerator are both positive.
Bars are red (red zone) when the Awesome Oscillator and Accelerator/Decelerator are both negative.
Bars are blue when a squat bar is formed, these indicate a battle between bulls and bears and often happen near trend continuation or trend changes.
Caution: Assumes chart is a bar chart - not a candle chart.
Caution: Squat bars are accurate only with official exchange volume data - BATS data will give false squat bars.