karasms.com

Fractals in Trading: A Comprehensive Guide to Indicators

Written on

Chapter 1: Introduction to Fractals

Fractals play a crucial role in identifying recurring patterns in trading, which can lead to predictable outcomes. Recognizing these patterns allows traders to anticipate market movements and make informed decisions. A well-known example is the double top/bottom pattern, which often indicates a potential trend reversal. However, this article will focus on a more objective pattern that aids in identifying breakouts rather than reversals. The clarity of this pattern sets it apart from traditional patterns like head and shoulders.

I have recently published a new book following the success of my prior work. This latest edition includes advanced trend-following indicators and strategies, along with a dedicated GitHub page for updated code. The book also features optimized colors for printing. If you're interested, you can check it out through the Amazon link below or reach out to me on LinkedIn for the PDF version.

Creating the Fractals

The fractal pattern consists of at least five consecutive price bars. An up fractal occurs when the middle bar is the highest among the surrounding bars, while a down fractal is characterized by the middle bar being the lowest. The ideal fractal pattern is visually represented by a V shape for down patterns and an inverted V for up patterns. It's important to note that this pattern has a time bias, as it becomes apparent only after two bars have passed. Consequently, the true completion of the pattern occurs after the fractal signal, typically seen on the middle bar.

Fractals can be highly beneficial when combined with other indicators in various trading strategies. They also serve a role in Elliot Wave analysis by indicating the onset of new waves. The diagram below illustrates this concept further.

According to Elliot Wave theory, the market moves in five impulsive waves followed by three corrective waves. Fractal patterns help signal the conclusion of a specific wave. After a down fractal indicates the end of the first wave, the market gains momentum in the third wave while awaiting confirmation from the down fractal for the decline towards the fifth wave. Here, fractals play a secondary role, as Elliot Wave analysis encompasses more than just this basic approach.

Section 1.1: Coding the Fractal Pattern

Let's explore how to code the fractal pattern using Python. This task is straightforward and involves recursive thinking. The following steps outline the process:

  1. The algorithm scans through the data, identifying highs and ensuring that the high from two periods ago is higher than the preceding two highs, forming an inverted V shape.
  2. Similarly, for down fractals, it checks for lows that adhere to the same criteria, resulting in a V shape.

Fractals detected on the EURUSD can be generated using the function below:

def fractals(Data, high, low, up, down):

# Fractal Up

for i in range(len(Data)):

if Data[i, high] < Data[i - 2, high] and Data[i - 1, high] < Data[i - 2, high] and Data[i - 2, high] > Data[i - 3, high] and Data[i - 2, high] > Data[i - 4, high]:

Data[i - 2, up] = 1

# Fractal Down

for i in range(len(Data)):

if Data[i, low] > Data[i - 2, low] and Data[i - 1, low] > Data[i - 2, low] and Data[i - 2, low] < Data[i - 3, low] and Data[i - 2, low] < Data[i - 4, low]:

Data[i - 2, down] = -1

return Data

The chart below displays the detected fractals on the hourly values of USDCHF. The upward arrows indicate down fractals, while the downward arrows represent up fractals. Numerous strategies can be developed using these signals, one of which is:

  • Buy when a down fractal is confirmed, generating a buy signal two periods after the down fractal appears.
  • Sell when an up fractal is confirmed, triggering a sell signal two periods following the up fractal.

Signal chart on the EURUSD:

def signal(Data):

# Bullish Signal

for i in range(len(Data)):

if Data[i - 2, 5] != 0:

Data[i, 6] = 1

# Bearish Signal

for i in range(len(Data)):

if Data[i - 2, 4] != 0:

Data[i, 7] = -1

return Data

The chart below summarizes the signals generated for USDCHF.

Section 1.2: Evaluating the Signals

With the signals established, we can determine when the algorithm would have executed buy and sell orders. This analysis provides a retrospective view of our decisions without hindsight bias. We must assess how the strategy would have performed given our conditions, focusing on return calculations and performance metrics. A key metric to consider is the Signal Quality.

Signal quality evaluates market reactions following a specified period after a signal, essentially measuring market timing. It assumes a fixed holding period and compares market levels at that time to the entry level.

Choosing a Holding Period for a Trend-Following Strategy:

period = 13

def signal_quality(Data, closing, buy, sell, period, where):

Data = adder(Data, 1)

for i in range(len(Data)):

try:

if Data[i, buy] == 1:

Data[i + period, where] = Data[i + period, closing] - Data[i, closing]

if Data[i, sell] == -1:

Data[i + period, where] = Data[i, closing] - Data[i + period, closing]

except IndexError:

pass

return Data

By applying the Signal Quality Function, we can gauge the effectiveness of our strategy.

Am I as disheartened by the fractal patterns as you are? Yes, yet I appreciate that while these fundamental parameters may not yield substantial results, more complex strategies could arise from them. The widespread availability of this pattern in charting software may indicate its limited value.

If you're interested in exploring more technical indicators and strategies, my book may appeal to you.

Always conduct your back-tests. It's essential to question prevailing assumptions; what works for one person may not work for another. My indicators and trading style may be effective for me, but the same may not apply to you.

I advocate for self-learning. Acquiring the idea, function, intuition, and conditions of a strategy allows for personal improvement. My decision not to provide specific back-testing results encourages readers to delve deeper into the strategy and refine it further.

Chapter 2: One Last Word

I have recently launched an NFT collection aimed at supporting various humanitarian and medical initiatives. The Society of Light is a limited collection of collectibles where a portion of each sale goes directly to the associated charity. Here’s a brief overview of the benefits of purchasing these NFTs:

  • High-potential gain: Marketing efforts are focused on maximizing their value in the secondary market, with a portion of royalties also benefiting the charity.
  • Art collection and portfolio diversification: Owning avatars that represent good causes can be immensely rewarding, combining investment with altruism.
  • Donating to preferred causes: This flexible approach allows for funding diverse charitable endeavors.
  • A free copy of my book: Every NFT purchase grants you a complimentary PDF copy of my latest book.

Click here to buy Slodon and support his cause for minority aid.

Share the page:

Twitter Facebook Reddit LinkIn

-----------------------

Recent Post:

# Inducing Hibernation: A Breakthrough for Space Travel?

Researchers have induced hibernation in rodents using ultrasound, potentially revolutionizing long-duration space missions and medical applications.

The Enigmatic Journey of Silk: From Silkworms to Luxury Fabric

Discover the captivating process of silk production, from the lifecycle of silkworms to the luxurious fabric that has adorned royalty for centuries.

The Transformation of Social Media: From Connection to Algorithm

Exploring the shift from social media's original purpose to an algorithm-driven landscape.

Harnessing Your Inner Strength: A Guide to Personal Empowerment

Discover how to break free from negative thought patterns and unlock your true potential through self-awareness and compassion.

Engaging JavaScript Project Ideas for Beginners

Discover project ideas to enhance your JavaScript skills and practical experience.

Harnessing Discipline: The Power of Accumulation and Consistency

Discover how accumulation and consistency can help you cultivate discipline and achieve your goals.

Navigating Science Fairs: Your Ultimate Guide to Success

Discover how to find and compete in the best science fairs, from local events to international competitions like ISEF.

Voyager Missions: Exploring the Final Frontier of Space

A look into the incredible journey of Voyager 1 and 2, celebrating their discoveries and Carl Sagan's legacy.