OPEN-SOURCE SCRIPT

Percentile Based Trend Strength

Telah dikemas kini
The "Percentile Based Trend Strength" (PBTS) calculates trend strength based on percentile values of high and low prices for various length periods and then identifies the current trend as either Bullish, Bearish, or N/A (No Trend). Here's a step-by-step explanation of the code:

Percentile Calculations:

For each specified length period (13, 21, 34, 55, 89, and 144 - Fibonacci numbers), the code calculates the 75th percentile of high prices (e.g., percentile_13H) and the 25th percentile of low prices (e.g., percentile_13L). These percentiles represent levels that prices need to exceed or fall below to indicate a strong trend.
Calculate Highest High and Lowest Low:

The highest high (75th percentile high price of longest length) and lowest low (25th percentile low price of longest length) for the longest length period (144) are calculated as highest_high and lowest_low. These values represent threshold price levels .
Trend Strength Conditions:

The code calculates various conditions to determine trend strength. For each percentile value and each length period, it checks if the percentile value is greater than the highest high (trendBull) or less than the lowest low (trendBear). These conditions are used to assess the strength of the bullish and bearish trends.
Count Bull and Count Bear:

The countBull and countBear variables count the number of bullish and bearish conditions met, respectively. These counts help evaluate trend strength.
Weak Bull and Weak Bear Count:

The code calculates the number of weak bullish and bearish conditions. Weak conditions occur when a percentile value falls within the range defined by the highest high and lowest low but doesn't meet the strong trend criteria.
Bull Strength and Bear Strength:

bullStrength and bearStrength are calculated based on the counts of bullish, bearish, weak bullish, and weak bearish conditions. These values represent the overall strength of the bullish and bearish trends.

Strong Bull and Bear Conditions:

These conditions occur when the 75th percentile of high prices (for bull conditions) or the 25th percentile of low prices (for bear conditions) exceeds or falls below the highest high or lowest low, respectively, for the specified length period.
Strong bull conditions indicate a strong upward trend, while strong bear conditions indicate a strong downward trend.
Strong conditions are indicative of more significant price movements and are considered as primary signals of trend strength.
Weak Bull and Bear Conditions:

Weak bull and bear conditions are more nuanced. They occur when the 75th percentile of high prices (for weak bull conditions) or the 25th percentile of low prices (for weak bear conditions) falls within the range defined by the highest high and lowest low for the specified length period.
In other words, prices are not strong enough to reach the extreme levels represented by the highest high or lowest low, but they still exhibit some bullish or bearish tendencies within that range.
Weak conditions suggest a less robust trend. They may indicate that while there is some bias toward a bullish or bearish trend, it is not as strong or decisive as in the case of strong conditions.

Current Trend Identification:

The current trend is determined by comparing bullStrength and bearStrength. If bullStrength is greater, it's considered a Bull trend; if bearStrength is greater, it's a Bear trend. If they are equal, the trend is identified as N/A (No Trend).
Displaying Trend Information:

The code creates a table to display the current trend, reversal probability (strength), count of bullish and bearish conditions, weak bullish and weak bearish counts, and colors the text accordingly.

Plotting Percentiles:

Finally, the code plots the percentile lines for visualization, with 20% transparency. It also plots the highest high and lowest low lines (75th and 25th percentile of the longest length 144) using their original colors.
In summary, this indicator calculates trend strength based on percentile levels of high and low prices for different length periods. It then counts the number of bullish and bearish conditions, factors in weak conditions, and compares the strengths to identify the current trend as Bullish, Bearish, or No Trend. It provides a table with trend information and visualizes percentile lines on the chart.
Nota Keluaran
Made some changes to weights to make it more responsive.
percentilereversalstatisticsTrend Analysistrendstrength

Skrip sumber terbuka

Dalam semangat sebenar TradingView, penulis telah menerbitkan kod Pine ini sebagai sumber terbuka supaya pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda boleh menggunakan perpustakaan ini secara percuma, tetapi penggunaan semula kod dalam penerbitan ini adalah dikawal oleh Peraturan dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Ingin menggunakan skrip ini pada carta?

Penafian