This is an experimental study based on Benoit Mandelbrot's fractal dimension concepts.
Fractal dimension is a ratio providing a statistical measure of complexity comparing how detail in a pattern changes with the scale at which it's measured. The concept of a fractional or fractal dimension was derived from an unconventional approach to standard geometric definitions.
We all know the standard geometric rules of dimension: D=0 is a point, D=1 is a line, D=2 is a plane, and D=3 is a volume, based on the number of axes being occupied. However, by taking a fractal geometric approach, we can define dimension like so: N = s^-D , where N is the number of measurement segments, s is the scale factor, and D is the dimension of the object being measured.
This approach typifies conventional knowledge of dimensions as well. Here are some basic examples: If we divide a line segment into 4 equal line segments, then we'd get 4 = (1/4)^-D. Solving for D, we get D=1, which is what we'd expect from a line. If we divide a square into 16 equal squares, we'd be separating each line on the square into 4 pieces, so 16 = (1/4)^-D. Solving for D, we get D=2, which is what we'd expect from a square. If we divide a cube into 64 equal cubes, we'd be separating each line on the cube into 4 pieces, so 64 = (1/4)^-D. Solving for D, we get D=3, which is what we'd expect from a cube.
The same approach can be applied to fractal objects, although admittedly it's less intuitive. Let's say you use a stick to measure a curve, then you divide the stick into 3 equal segments and re-measure the length. But rather than the re-measured curve showing a length of 3 of the smaller segments, it is actually 4 segments long. This irregularity means that detail has increased as you scaled your measurement down, so the curve is dimensionally higher than the space it resides in. In this example: 4 = (1/3)^-D. Solving for D, we get D=1.2619.
For a true fractal, this scaling of self-similar measurements would continue infinitely. However, unlike true fractals, most real world phenomena exhibit limited fractal properties, in which they can be scaled down to some limited quantity.
Many forms of time series data (seismic data, ECG data, financial data, etc.) have been theoretically shown to have limited fractal properties. Consequently, we can estimate fractal dimension from this data to get an approximate measure of how rough or convoluted the data stream is.
Financial data's fractal dimension is limited to between 1 and 2, so it can be used to roughly approximate the Hurst Exponent by the relationship H = 2 - D. When D=1.5, data statistically behaves like a random walk. D above 1.5 can be considered more rough or "mean reverting" due to the increase in complexity of the series. D below 1.5 can be considered more prone to trending due to the decrease in complexity of the series.
In this study, you are given the option to apply equalization (EQ) to the dataset before estimating dimension. This enables you to transform your data and observe how its complexity changes as well. Whether you want to give emphasis to some frequencies, isolate specific bands, or completely alter the shape of your waveform, EQ filtration makes for an interesting experience. The default EQ preset in this script removes the low shelf, then attenuates low end and high end oscillations. The dominant cyclical components (bands 3 - 5 on default settings) are passed at 100%, keeping emphasis on 8 to 64 sample per cycle oscillations.
In addition, if you're wanting a simpler filter process, or if you want a little extra, there are options included to pre and post smooth the data with 2 pole Butterworth LPFs.
The dimension estimation in this script works by measuring changes in detail using source's maximum range over a given lookback length. In essence, it recursively updates its length parameter based on changes in range compared to the maximum over the lookback period, then uses the data to solve for D. The FDI algorithm works on any length greater than 1. However, I didn't notice any particularly meaningful results with lookback lengths of 15 or less.
A custom color scheme is included in this script as well for FDI fill and bar colors. The color scheme in this script is a multicolored thermal styled gradient. The scale of gradient values is determined by the designated high and low dimension thresholds. These thresholds determine what range of values the gradient will focus on. Values at the high threshold are the coolest and darkest, and values at the low threshold are the warmest and brightest. Basically, the "trendier" the data is, the brighter and warmer the color will be.
Signals and alerts are included as well for crossovers on the high and low dimension thresholds. These signals can also be externally linked to another script. The output format is 1 for the trigger, and 0 otherwise. Basic boolean logic. To integrate these signals with your script, simply use a source input and select the signal output from this script that you wish to use from the dropdown menu.
Fractal dimension is a powerful tool that can give valuable insight about the complexity and persistence / anti-persistence of price movements. When used in conjunction with other analytical methods, it can prove to be a surprisingly beneficial tool to have in the arsenal.
General Disclaimer: Trading stocks, futures, Forex, options, ETFs, cryptocurrencies or any other financial instrument has large potential rewards, but also large potential risk. You must be aware of the risks and be willing to accept them in order to invest in stocks, futures, Forex, options, ETFs or cryptocurrencies. Don’t trade with money you can’t afford to lose. This is neither a solicitation nor an offer to Buy/Sell stocks, futures, Forex, options, ETFs, cryptocurrencies or any other financial instrument. No representation is being made that any account will or is likely to achieve profits or losses of any kind. The past performance of any trading system or methodology is not necessarily indicative of future results.
הגישה לסקריפט זה מוגבלת למשתמשים שהוסמכו על ידי הכותב ובדרך כלל דורשת תשלום. אתה יכול להוסיף אותו למועדפים שלך, אך תוכל להשתמש בו רק לאחר שתבקש אישור ותקבל אותו מהמחבר שלו. למידע נוסף, צור קשר עם DonovanWall, או עקוב אחר הוראות המחבר למטה.
TradingView לא מציעה לשלם עבור סקריפט ולהשתמש בו אלא אם כן אתה סומך ב-100% על המחבר שלו ומבין כיצד הסקריפט עובד. במקרים רבים, אתה יכול למצוא אלטרנטיבה טובה לקוד פתוח בחינם בבסקריפטים הקהילתיים שלנו.
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.