Auto Fibonacci and Gann Fan/Retracements ComboIntroduction
This is a combination of Fibonacci and Gann fan/retracements.
The script can automatically draw as many:
Fibonacci Retracements
Fibonacci Fan
Gann Retracements
Gann Fan
as the user requires on the chart. Each level set or fan consists of 7 lines based on the most important ratios of Fibonacci/Gann.
Basics
What are Fibonacci retracements?
Fibonacci retracement levels are horizontal lines that indicate where support and resistance are likely to occur. They stem from Fibonacci’s sequence. Each level is associated with a percentage which is how much of a prior move the price has retraced. The Fibonacci retracement levels are 23.6%, 38.2%, 61.8%, and 78.6%. While not officially a Fibonacci ratio, 50% is also used. The indicator is useful because it can be drawn between any two significant price points, such as a high and a low. The indicator will then create the levels between those two points.
What are Gann retracements?
A developer of technical analysis and trading was W.D. Gann. Gann theory expects a normal retracement of 50 percent. This means that under normal selling pressure, the stock price will decline half the amount of its most recent rise, and vice versa. It also suggests that retracements occur at the halfway point of a move, such as 25 percent (half of 50 percent), 12.5 percent (half of 25 percent), and so on.
What is Fibonacci fan?
Fibonacci fan is a set of sequential trend lines drawn from a trough or peak through a set of points dictated by Fibonacci retracements. The first step to create it is to draw a trend line covering the local lowest and highest prices of a security. To reach retracement levels, the trader divides the difference in price at the low and high end by ratios determined by the Fibonacci series. The lines formed by connecting the starting point for the base trend line and each retracement level create the Fibonacci fan.
What is Gann fan?
A Gann fan consists of a series of lines called Gann angles. These angles are superimposed over a price chart to show potential support and resistance levels. The resulting image is supposed to help technical analysts predict price changes. Gann believed the 45-degree angle to be most important, but the Gann fan also draws angles at degrees like 75, 63.75, 26.25 and 15. The Gann fan originates at a low or high point. The resulting lines show areas of potential future support and resistance. The 45-degree line is known as the 1:1 line because the price will rise or fall at a 45-degree angle when the price moves up/down one unit for each unit of time. All other lines in the Gann fan are drawn above and below the 1:1 line. The other angles are associated with 2:1, 3:1, 4:1, 8:1 and 1:8, 1:4, 1:3, and 1:2 time-to-price moves.
Challenges
The most of the time I dedicated to writing this script has been spent on handling these problems:
1. Finding Local Highest/Lowest Prices
In order to draw Fibonacci and Gann fan/retracements, it's necessary to find local highest and lowest price points (Extrema) on the chart. As this could be so challenging, most traders and coders draw the lines covering the low and high prices over a given period of time or a limited number of bars back instead. I already wrote an indicator using this approach ( Auto Fibonacci Combo ).
In this new script I tried to find the exact highest and lowest prices based on this idea that: if a high point is formed lower than previous high which was after a lowest point, then that previous one was the local highest point, and vice versa if a low point is formed higher than previous low which was after a highest point, then that previous one was the local lowest point. So logically an extremum price on the chart won't be found until the next high/low point is formed.
2. Finding Proper Chart Scale for Gann Fan
Based on the theory, Gann angles are sensitive to the chart price scale and in order to have the right angles, the chart must be made with the proper scale. J.A. Hyerczyk in his book "Pattern, Price & Time - Using Gann Theory in Technical Analysis" suggests that the easiest way to determine the scale of a market is by taking the difference between top-to-top and bottom-to-bottom and dividing it by the time it took the market to move from top to top and bottom to bottom.
Thus on a properly constructed chart, the basic equation for calculating Gann angles is: Price * Time.
3. Drawing Fans and Relocating Fan Labels at Each New Bar in Pine (A Programming-Related Subject)
To do this, I used linear equations and line slopes. Of course it was so complicated and exhausting, but finally I overcame that thanks to my genius cousin.
Settings and Usage
By default, the script shows detected extremum points plus 1 Fibonacci fan, 1 Gann fan, 1 set of Fibonacci retracements and no Gann retracements on the chart. All of these could be changed in the indicator settings beside the color and transparency of each line.
Feel free to use this and send me your thoughts!

# Fibonaccifan

Auto Fib Speed Resistance Fans by DGTFibonacci Speed and Resistance Fan is an analytical drawing tool used to indicate the support and resistance levels of an existing trend and the price level at which possible changes in the trend may occur.
A Fibonacci Speed Resistance Fan consists of a trend line drawn between two extreme points - a trough and opposing peak or a peak and opposing trough - on which a set of sequential speed resistance lines are drawn above (which represents time) and below (which represents price). These lines are drawn based on time/price percentages of the distance between the beginning and the end of the trend line.
Speed resistance lines not only help to measure trend corrections but also measure the speed of a trend (the rate at which a trendline ascends or descends)
Traders can use the lines of the Fibonacci Speed and Resistance Fan to predict key points of resistance or support, at which they might expect price trends to reverse. Once a trader identifies patterns within a chart, they can use those patterns to predict future price movements and future levels of support and resistance. Traders use the predictions to time their trades. Key support and resistance levels tend to occur frequently at the 61.8-percent level on both uptrends and downtrends.
Please check for further details in the education post that I will share shortly after this publication :
Nobody appears to know whether Fibonacci tools work because markets exhibit some form of natural pattern or because many investors use Fibonacci ratios to predict price movements, making them a self-fulfilling prophecy.
█ Study OPTIONS
Auto Fibonacci Speed and Resistance Fan , the main aim of the study
- Pivot threshold can be adjusted via “Deviation” and “Depth” input options
- Historical Fans option will allow plotting of Speed and Resistance Fans on previous pivot high/lows
- Ability to set ALERTs for the Speed and Resistance Levels
- Price Grid Lines if extended it will result with Fib Retracement levels
- All lines, line levels are customizable, default values are set exactly to the same with the available Fib Speed and Resistance Fan drawing tool
Zig Zag – Derived from build-in Auto Fib Retracement with some customization options.
Example Usages :
Disclaimer :
Trading success is all about following your trading strategy and the indicators should fit within your trading strategy, and not to be traded upon solely
The script is for informational and educational purposes only. Use of the script does not constitute professional and/or financial advice. You alone have the sole responsibility of evaluating the script output and risks associated with the use of the script. In exchange for using the script, you agree not to hold dgtrd TradingView user liable for any possible claim for damages arising from any decision you make based on use of the script

4SMA Fibonacci 55/89/223/610just noticed the correlation of SMAs and fibonacci on my charts.
maybe it will help you to.