TradingView

TechnicalRating

█  OVERVIEW


This library is a Pine Script™ programmer’s tool for incorporating TradingView's well-known technical​ ratings within their scripts. The ratings produced by this library are the same as those from the speedometers in the technical​ analysis​ summary and the "Rating" indicator in the Screener, which use the aggregate biases of 26 technical​ indicators to calculate their results.



█  CONCEPTS


Ensemble analysis

Ensemble analysis uses multiple weaker models to produce a potentially stronger one. A common form of ensemble analysis in technical​ analysis​ is the usage of aggregate indicators together in hopes of gaining further market insight and reinforcing trading decisions.


Technical ratings

Technical ratings provide a simplified way to analyze financial markets by combining signals from an ensemble of indicators into a singular value, allowing traders to assess market sentiment more quickly and conveniently than analyzing each constituent separately. By consolidating the signals from multiple indicators into a single rating, traders can more intuitively and easily interpret the "technical health" of the market.


Calculating the rating value

Using a variety of built-in TA functions and functions from our ta library, this script calculates technical ratings for moving averages, oscillators, and their overall result within the `calcRatingAll()` function.

The function uses the script's `calcRatingMA()` function to calculate the moving average technical rating from an ensemble of 15 moving averages and filters:
 • Six Simple Moving Averages and six Exponential Moving Averages with periods of 10, 20, 30, 50, 100, and 200
 • A Hull Moving Average with a period of 9
 • A Volume-Weighted Moving Average with a period of 20
 • An Ichimoku Cloud with a conversion line length of 9, base length of 26, and leading span B length of 52

The function uses the script's `calcRating()` function to calculate the oscillator technical rating from an ensemble of 11 oscillators:
 • RSI with a period of 14
 • Stochastic with a %K period of 14, a smoothing period of 3, and a %D period of 3
 • CCI with a period of 20
 • ADX with a DI length of 14 and an ADX​ smoothing period of 14
 • Awesome Oscillator
 • Momentum with a period of 10
 • MACD with fast, slow, and signal periods of 12, 26, and 9
 • Stochastic RSI with an RSI​ period of 14, a %K period of 14, a smoothing period of 3, and a %D period of 3
 • Williams %R with a period of 14
 • Bull Bear Power with a period of 50
 • Ultimate Oscillator with fast, middle, and slow lengths of 7, 14, and 28

Each indicator is assigned a value of +1, 0, or -1, representing a bullish​​, neutral, or bearish​​ rating. The moving​ average​ rating is the mean of all ratings that use the `calcRatingMA()` function, and the oscillator rating is the mean of all ratings that use the `calcRating()` function. The overall rating is the mean of the moving average​ and oscillator ratings, which ranges between +1 and -1. This overall rating, along with the separate MA​ and oscillator ratings, can be used to gain insight into the technical strength of the market. For a more detailed breakdown of the signals and conditions used to calculate the indicators' ratings, consult our Help Center explanation.


Determining rating status

The `ratingStatus()` function produces a string representing the status of a series of ratings. The `strongBound` and `weakBound` parameters, with respective default values of 0.5 and 0.1, define the bounds for "strong" and "weak" ratings.

The rating status is determined as follows:

    Rating Value	    Rating Status


   < -strongBound	    Strong Sell
   < -weakBound	            Sell
-weakBound to weakBound	    Neutral
   >  weakBound	            Buy
   >  strongBound	    Strong Buy

By customizing the `strongBound` and `weakBound` values, traders can tailor the `ratingStatus()` function to fit their trading style or strategy, leading to a more personalized approach to evaluating ratings.



Look first. Then leap.



█ FUNCTIONS


This library contains the following functions:


calcRatingAll()
  Calculates 3 ratings (ratings total, MA ratings, indicator ratings) using the aggregate biases of 26 different technical indicators.
  Returns: A 3-element tuple: ([(float) ratingTotal, (float) ratingOther, (float) ratingMA].

countRising(plot)
  Calculates the number of times the values in the given series increase in value up to a maximum count of 5.
  Parameters:
    plot: (series float) The series of values to check for rising values.
  Returns: (int) The number of times the values in the series increased in value.

ratingStatus(ratingValue, strongBound, weakBound)
  Determines the rating status of a given series based on its values and defined bounds.
  Parameters:
    ratingValue: (series float) The series of values to determine the rating status for.
    strongBound: (series float) The upper bound for a "strong" rating.
    weakBound: (series float) The upper bound for a "weak" rating.
  Returns: (string) The rating status of the given series ("Strong Buy", "Buy", "Neutral", "Sell", or "Strong Sell").



Get $15 worth of TradingView Coins for you and a friend: www.tradingview.com/share-your-love/

Read more about the new tools and features we're building for you: www.tradingview.com/blog/en/
Biblioteka Pine

Działając zgodnie z prawdziwym duchem TradingView, autor opublikował ten kod Pine jako bibliotekę o otwartym kodzie źródłowym, aby inni programiści Pine z naszej społeczności mogli go ponownie wykorzystać. Brawa dla niego! Możesz korzystać z tej biblioteki prywatnie lub w innych publikacjach typu open source, ale ponowne wykorzystanie tego kodu w publikacji podlega Regulaminowi.

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.

Chcesz skorzystać z tej biblioteki?

Skopiuj poniższy wiersz i wklej go w swoim skrypcie.