Indicator · Pine Script v4 · Own pane

Fractal Dimension

by techteam92· code credited to capissimo

This indicator calculates John Ehlers' fractal dimension of recent price movement and plots it in a separate pane.

View on GitHub

GitHub stars1on the repository
Pine versionv4older, still runs
Lines of code39
Settings1inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago20 Nov 2024

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

39 lines of Pine Script v4 from scripts/113-Fractal-Dimension.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

113-Fractal-Dimension.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © capissimo

//@version=4
study('Fractal Dimension', '', false)

// John F Ehlers' Fractal Dimension

// Description:

// Fractal Dimension is a measure of how complicated a self similar 
// shape is. For instance, a line is smaller and more basic than a square.

// The lower the Fractal Dimension the closer a stock chart is to 
// a straight line and therefore the stronger the trend.  
// High readings on the other hand reveal a complex fractal; 
// the shape of a range bound market. 

// These two different market types require very different 
// strategies in order to maximize profits and minimize losses.

//-------------------- Inputs

n = input(20, 'Lag', minval=2)

//-------------------- Logic

half = n/2
HL1  = (highest(high[half], half) - lowest(low[half], half)) / half
HL2  = (highest(high,       half) - lowest(low,       half)) / half
HL   = (highest(high,       n)    - lowest(low,       n))    / n
D    = (log(HL1 + HL2) - log(HL)) / log(2)

dim  = D < 1 ? 1 : D > 2 ? 2 : D

//-------------------- Rendering

hline(1.5)
plot(dim, '', color.blue)

Overview

Fractal Dimension compares the average high-low range over two successive halves of a lookback window with the range over the full window, then converts that ratio into a dimension clamped between 1 and 2. Lower readings indicate a simpler, more directional path, while higher readings indicate a more complex, range-like path. The Lag setting changes the lookback length. A horizontal line marks 1.5. It does not generate trade entries or exits.

Details

Published by

techteam92 on GitHub

Code credit

capissimo, as written in the script's header

Type

Indicator, Pine Script v4

Draws

Separate pane below the chart

Category

Trend

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Lagint20n
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Schaff Trend Cycle

by everget
948 stars

This indicator plots the Schaff Trend Cycle in a separate pane. It subtracts a slow exponential moving average from a fast one, applies a stochastic cycle twice, and smooths each result to form a 0–100 oscillator. Line color follows the slope, or the upper and

Indicator v4 Oscillators & momentumTrend
Updated 10 days ago · GPL-3.0 GitHub repository of Schaff Trend Cycle

This indicator plots a Supertrend-based trend-following setup in a separate pane and skips conditions it treats as a sideways market. A volatility range is built from an ATR value, with RMA, SMA, EMA, or WMA smoothing, or from a fixed point distance. Optional

Indicator v5 TrendVolatility & bands
Updated 1 year ago · MPL-2.0 GitHub repository of Trend Following Setup - Sideways Market Skipper

Beep Boop

by magic8bot
409 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop

[RS]Standardized Trend Map

by ricardosantos79
261 stars

Standardized Trend Map calculates series momentum relative to active price range across 40 distinct lookback periods ranging from 2 to 80 bars on an exponential moving average source. Each standardized calculation rounds to an integer values of -1, 0, or 1 to

Indicator v4 TrendOscillators & momentum
Updated 4 years ago · None stated GitHub repository of [RS]Standardized Trend Map

ADX Histogram

by harryguiacorn
219 stars

This indicator calculates and displays the Average Directional Index (ADX) as a column histogram in a separate pane. It evaluates market trend strength by calculating directional movement metrics based on specified smoothing and DI length inputs. When the ADX

Indicator v5 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of ADX Histogram

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers