OPEN-SOURCE SCRIPT

Visible Fibonacci

█  OVERVIEW


This indicator displays Fibonacci​ retracement​ and extension levels on the price chart using data within the chart's visible range, providing traders with an automated alternative to our well-known drawing tool.



█  CONCEPTS


Fibonacci sequence and the Golden ratio

The Fibonacci sequence is a sequence of numbers where each term is the sum of the previous two terms. In his book Liber Abaci, Fibonacci used this sequence to estimate the growth of rabbit populations. Although most commonly associated with Fibonacci, this numeric sequence appeared in Indian mathematics as early as 200 BC​. As this sequence approaches infinity, the ratio of the last element to the preceding approaches the Golden ratio (1.618033...), a well-known metallic ratio theoretically observed in many natural and synthetic systems. Many traders believe that the Fibonacci sequence and the Golden ratio carry significance in the financial markets.


Fibonacci retracements and extensions

Fibonacci retracements and extensions are extremely popular in ​technical analysis. They are created by connecting two extreme points, typically ​pivot points, by a ​trend line and multiplying the range between them by the ratios of steps in the Fibonacci sequence, or more precisely, powers of the Golden Ratio, to produce estimated levels of support​ and resistance​. The ratios used for retracement multipliers are typically the Golden ratio raised to the power of 0, -0.5, -1, -2, and -3, or 1, 0.786, 0.618, 0.382, and 0.236, respectively. It is also common to see traders use a retracement ratio of 0.5. The ratios used for extension multipliers are typically the Golden ratio raised to the power of 0.5, 1, 2, and 3, or 1.272, 1.618, 2.618, and 4.236, respectively. Traders often combine these retracement and extension ratios with others they deem significant for a more personalized output.


​Zig Zag​

​Zig ​Zag​ is a popular indicator that filters out minor price fluctuations to denoise data and emphasize trends. Traders commonly use ​​Zig Zag​ for trend confirmation, identifying potential ​support and ​resistance​, and pattern detection​. It is formed by identifying significant local high and low points in alternating order and connecting them with straight lines, omitting all other data points from their output. There are several ways to calculate the ​Zig Zag​'s data points and the conditions by which its direction changes. This script uses the highest and lowest values over a specified length to estimate the locations of pivots​. The Zig Zag​ reverses its direction when a new high or low emerges in the opposite direction. Additionally, enabling the "Detect additional pivots​" option in the script settings will locate extra pivots​ when the number of bars in which no new pivot​​ occurs exceeds the Zig Zag​​ length.


Visible Fibonacci

This script uses the chart's visible bars to calculate and display an automated Fibonacci retracement tool with extreme points based on either of two calculation methods:
 • Visible Chart Range: This method uses the highest and lowest points from the visible chart range for Fibonacci level calculation.
 • Visible Zig Zag: This method uses historical pivots​ from a Zig Zag​ indicator​ for level calculation. The "nth Last Pivot​" input in the script settings controls how many pivots​ back from the last visible one will be used to calculate the Fibonacci levels.

As traders pan and zoom on their charts, the script dynamically recalculates its values explicitly using the bars within the visible range.

Note that levels drawn outside the range between the high and low points may affect the scale of the chart. To prevent this, select the "Scale price chart only" option in the chart settings.


█ FOR Pine Script™ CODERS


 • This script utilizes functions from the VisibleChart library by our resident PineCoders. The library exploits the chart.left_visible_bar_time and chart.right_visible_bar_time variables, which return the opening time of the leftmost and rightmost bars on the chart. They are only two of many new built-ins in the `chart.*` namespace. See this blog post for more information, or look them up by typing "chart." in the Pine Script™ Reference Manual.
 • This script's architecture utilizes user-defined types (UDTs) to create custom objects which are the equivalent of variables containing multiple parts, each able to hold independent values of different types. The recently added feature was announced in this blog post.



Look first. Then leap.


Chart patternsCyclesTrend Analysis

Mã nguồn mở

Theo tinh thần TradingView thực sự, tác giả của tập lệnh này đã xuất bản dưới dạng nguồn mở để các nhà giao dịch có thể hiểu và xác minh. Chúc mừng tác giả! Bạn có thể sử dụng miễn phí. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?


Share TradingView with a friend:
tradingview.com/share-your-love/

Read more about the new tools and features we're building for you: tradingview.com/blog/en/
Ngoài ra, trên:

Thông báo miễn trừ trách nhiệm