Exploring Fibonacci Trends in Trading Strategies
Written on
Chapter 1: Introduction to Fibonacci in Trading
The Fibonacci sequence has various applications in trading. This article introduces a novel indicator and strategy that serves as a complement to traditional methods.
I recently published a book titled "Contrarian Trading Strategies in Python." It contains numerous advanced contrarian indicators and strategies, along with a GitHub repository for ongoing code updates. If you're interested, you can purchase the PDF version directly for 9.99 EUR via PayPal. Please include your email in the note so that it reaches the correct address. After receiving it, ensure you download it from Google Drive.
Chapter 2: Understanding the Fibonacci Step Indicator
Leonardo Bonacci, commonly known as Fibonacci, devised one of the most captivating sequences in mathematics through simple addition while studying rabbit populations. While some evidence suggests that Indian mathematicians may have discovered this sequence earlier, we will adhere to the widely recognized fact that Fibonacci popularized it. The Fibonacci numbers are generated using the formula for n > 2, resulting in an infinite sequence like this:
1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, …
The Fibonacci Step Indicator is a moving average that utilizes Fibonacci numbers to determine the values for averaging. Unlike the previously discussed Fibonacci moving average, this concept is still in its infancy but shows promise. For a comprehensive overview of the confirmed Fibonacci moving average, refer to my earlier article, or continue reading for more insights.
The Step Fibonacci Indicator calculates averages based on historical values that correspond to Fibonacci numbers. To illustrate, here's a comparison between a standard simple moving average and the Step Fibonacci Indicator: A 5-period simple moving average computes the average of the last five closing prices, whereas a 5-period Step Fibonacci Indicator averages the closing prices from two, three, five, eight, and thirteen periods ago.
Section 2.1: Purpose of the Step Fibonacci Indicator
Many questions arise regarding this approach:
- Why skip values?
- What evidence supports the notion that this method yields a superior moving average?
- Why the Fibonacci sequence instead of skipping every five or ten values?
- What strategies can be implemented with this indicator?
To address the first question, our goal is to determine if skipping values offers a broader perspective, as non-skipped values might be closely related and repetitive. Currently, there is no definitive proof that this method provides better results than conventional moving averages—this is something we will explore in future articles.
We choose the Fibonacci sequence because of its established significance in finance. Why skip five or ten values when there’s a mathematically validated sequence available? The strategies mirror those used with moving averages, although we will introduce one unique strategy in later sections.
Section 2.2: The Step Fibonacci Indicator in Action
The following chart illustrates the Step Fibonacci Indicator applied to market highs and lows. The default version of this indicator uses the lookback periods: {2, 3, 5, 8, 13, 21, 34, 55, 89, 144} for the USDCAD pair.
Here’s the function to code this indicator:
def adder(Data, times):
for i in range(1, times + 1):
new = np.zeros((len(Data), 1), dtype=float)
Data = np.append(Data, new, axis=1)
return Data
def deleter(Data, index, times):
for i in range(1, times + 1):
Data = np.delete(Data, index, axis=1)return Data
def jump(Data, jump):
Data = Data[jump:, ]
return Data
def step_fibonacci_indicator(Data, high, low, close, where):
Data = adder(Data, 3)
for i in range(len(Data)):
Data[i, where] = (Data[i - 2, high] +
Data[i - 3, high] +
Data[i - 5, high] +
Data[i - 8, high] +
Data[i - 13, high] +
Data[i - 21, high] +
Data[i - 34, high] +
Data[i - 55, high] +
Data[i - 89, high] +
Data[i - 144, high] +
Data[i - 233, high]) / 11
for i in range(len(Data)):
Data[i, where + 1] = (Data[i - 2, low] +
Data[i - 3, low] +
Data[i - 5, low] +
Data[i - 8, low] +
Data[i - 13, low] +
Data[i - 21, low] +
Data[i - 34, low] +
Data[i - 55, low] +
Data[i - 89, low] +
Data[i - 144, low] +
Data[i - 233, low]) / 11
for i in range(len(Data)):
Data[i, where + 2] = (Data[i - 2, close] +
Data[i - 3, close] +
Data[i - 5, close] +
Data[i - 8, close] +
Data[i - 13, close] +
Data[i - 21, close] +
Data[i - 34, close] +
Data[i - 55, close] +
Data[i - 89, close] +
Data[i - 144, close] +
Data[i - 233, close]) / 11
return Data
With this function, we create a moving zone, akin to the Fibonacci moving average. Note how we calculate the indicator based on high, low, and close prices, as we will introduce a strategy using the Relative Strength Index (RSI) based on the closing values of the Step Fibonacci Indicator.
Section 2.3: Introduction to the Relative Strength Index
The RSI is a momentum indicator that ranges from 0 to 100, simplifying its interpretation. Its popularity adds to its effectiveness; the more traders reference it, the more likely market prices will react to its signals.
The RSI is computed by first determining price changes for one period—subtracting each closing price from the one preceding it. Then, we calculate the smoothed average of positive differences and divide it by the smoothed average of negative differences. This yields the Relative Strength, which is integrated into the RSI formula to produce a value between 0 and 100.
Thus, our strategy will include the following steps:
- Calculate the default Step Fibonacci Indicator focusing on close prices.
- Compute a 13-period RSI on the Step Fibonacci Indicator's close values.
- Monitor for oversold conditions at 15 (for bullish signals) and overbought conditions at 85 (for bearish signals).
Here’s the function to compute the RSI:
def rsi(Data, lookback, close, where):
Data = adder(Data, 5)
for i in range(len(Data)):
Data[i, where] = Data[i, close] - Data[i - 1, close]for i in range(len(Data)):
if Data[i, where] > 0:
Data[i, where + 1] = Data[i, where]elif Data[i, where] < 0:
Data[i, where + 2] = abs(Data[i, where])lookback = (lookback * 2) - 1
Data = ema(Data, 2, lookback, where + 1, where + 3)
Data = ema(Data, 2, lookback, where + 2, where + 4)
Data[:, where + 5] = Data[:, where + 3] / Data[:, where + 4]
Data[:, where + 6] = (100 - (100 / (1 + Data[:, where + 5])))
Data = deleter(Data, where, 6)
Data = jump(Data, lookback)
return Data
Section 2.4: Practical Application of the RSI
The RSI derived from this method will not be overly smoothed, unlike traditional applications on moving average values. Consequently, the signals generated will generally maintain the same quality as those from the standard RSI.
Focus on grasping the concepts rather than the code. The execution aspect is secondary; the underlying ideas require contemplation and refinement.
Be sure to check out my weekly market sentiment report to gain insights into current positioning and project future market directions using various models.
Chapter 3: Conclusion
In conclusion, my aim is to contribute to the realm of objective technical analysis, advocating for transparent techniques and strategies that should undergo rigorous back-testing before implementation. This approach can enhance the reputation of technical analysis, steering it away from perceptions of subjectivity and lack of scientific grounding.
Whenever you encounter a new trading technique or strategy, I recommend you follow these steps:
- Maintain a critical mindset and avoid emotional biases.
- Back-test using real-life scenarios.
- If you identify potential, optimize the strategy and conduct a forward test.
- Factor in transaction costs and slippage in your tests.
- Incorporate risk management and position sizing.
Even after thorough testing, continue to monitor the strategy, as market dynamics can change, potentially rendering it unprofitable.
This video explores how Fibonacci levels can be utilized to forecast trend changes and retracements.
This video documents a comprehensive test of the Fibonacci trading strategy conducted 100 times to uncover the truth about Fibonacci retracements.