#Part 14
FREE Analytical Course by PythonInvest HAS STARTED (you can still join)

Decoding Technical Analysis: Uncovering the Most Popular Indicators for Crypto and Stocks

Technical analysis offers a trove of indicators, but which ones are truly valuable in the fast-paced crypto and stock markets? This article takes a data-driven approach, algorithmically analyzing the popularity of TA-Lib's technical indicators across 20 top cryptocurrencies and 20 stocks. We'll uncover patterns of usage, examine their correlation to future growth predictions, and provide practical insights for casual analysts and traders.
Discussion in Telegram
Screencasts on Youtube
Articles on Medium
Code on Github
Author: Ivan Brigida
Data Analyst and Financial Enthusiast
The Content is for informational purposes only, you should not construe any such information or other material as legal, tax, investment, financial, or other advice.


In this article, we dive into technical indicators, revealing their power to forecast future returns for top stocks and cryptocurrencies. By tapping into data from the YFinance API, we explore how these indicators, spanning momentum and pattern recognition, offer practical insights for predicting market movements.

We pinpoint which indicators strongly correlate with future returns, shaping our predictive models. For instance, the Relative Strength Index (RSI) and Moving Average Convergence Divergence (MACD) often mirror subsequent price shifts, providing actionable insights for traders and investors.

Through decision trees, we uncover the key factors driving future trends, simplifying financial analysis. Historical returns and trading volume emerge as influential factors in forecasting price shifts, highlighting their importance in decision-making.

Executive Summary
This article provides a comprehensive examination of technical indicators' predictive power in finance, particularly focusing on stocks and cryptocurrencies. By leveraging Python's TA-Lib library, we demonstrate the straightforward generation of over 100 technical indicators. Through meticulous analysis, we unveil the most influential indicators for predicting market movements in both crypto and stock markets.

Moreover, we offer concrete examples of the most prevalent pattern indicators, such as CDLBelthold and CDLShortLine, highlighting their importance in identifying potential market reversals or continuations. This empirical approach equips traders and investors with actionable insights, enabling them to make informed decisions based on robust data analysis.

Summary of Results

  • Effortless Tech Indicator Generation
    Utilizing Python's TA-Lib library, we seamlessly generated over 100 technical indicators
  • Frequent Pattern Indicators
    E.g., for BTC-USD: CDLBelthold, CDLShortLine, CDLClosingMarubozu
  • Top Correlated With Future Returns Indicators
    Commodity Channel Index (CCI), Chande Momentum Oscillator (CMO), and Relative Strength Index (RSI)
  • Top Predictive Indicators for 1hr movement (decision trees)
    E.g. : Natr, Fastk
  • Top Predictive Indicators for 24hr movement (decision trees)
    E.g.: ad, obv, trix

Overview on YouTube

Video will be added soon (April 2024) and published on PythonInvest's Youtube channel.

Top Crypto and Stocks list

Firstly, we compiled lists of the top 25 most active trading stocks and the top 25 largest cryptocurrencies by market capitalization, followed by accessing hourly data for each ticker over the past two years using the YFinance API.

We extracted lists of stock tickers from the URL: While the former is commonly used for screening purposes for humans, we repurposed it to efficiently gather stock data. For cryptocurrencies, we referred to the link provided at

Subsequently, leveraging the YFinance API, we retrieved hourly data for each ticker, spanning the preceding two years. It's worth noting that accessing data beyond this timeframe (2 years for hourly data) may require subscription to paid data sources.

Here are the top 5 (out of 25) stocks and crypto tickers (data for 29th March 2024):

Single Dataframe with Historical Returns

The process involved gathering hourly OHLCV data from YFinance over the past two years for all 25 top stocks and 25 top cryptocurrencies, which were then merged into a single dataframe.

Stats for each ticker were downloaded and combined into one dataframe for streamlined analysis.

Moreover, additional features such as historical returns for different time intervals (1, 2, 5, 10, and 24 hours back, as well as 3, 7, and 30 days back) were generated to capture potential predictors of future values, particularly in autoregression (AR) models.

Furthermore, future returns for the next 1 hour and binary indicators for positive future returns in 1 hour and 24 hours were calculated to discern the most influential factors in predicting future prices. Importantly, it's noteworthy that the binary indicator "is_positive_future_growth_1h" (or ".._24h") is evenly split between two classes, highlighting the importance of balanced consideration when assessing predictive models.
Subsequently, correlations and feature importance in simple decision tree models will be analyzed to identify influential predictors in forecasting future price movements.

Here you can check the resulting dataframe example with some of the new "growth" fields:

TA-Lib Library for Generating Technical Indicators

As the next step we explore the utilization of the TA-Lib library ( to generate technical indicators (full list of functions), enhancing our analysis of hourly OHLCV data dumps.

Initially, we utilize hourly OHLCV data as the base stats, laying the groundwork for our analysis. The TA-Lib library is then imported, enabling the precalculation of over 100 additional metrics or technical indicators crucial for strategy development and model building.

These indicators are grouped into four categories:

  1. Momentum (30+): Momentum indicators measure the speed and strength of price movements. Examples include the Relative Strength Index (RSI).

  2. Volume, Volatility, Cycle, Price (15): This category encompasses indicators related to volume, volatility, cyclical patterns, and price movements. Examples include Bollinger Bands.

  3. Pattern Recognition (60): These indicators identify specific patterns in price movements that may signal potential reversals or continuations of trends. Examples include candlestick patterns like Doji and Engulfing.

  4. Other: This category may include various other indicators like moving averages and trendlines.

    Pattern Recognition Indicators

    Let's look more in detail into the pattern indicators, as there are so many of them.

    Firstly, we apply all indicator functions (60) for one ticker (BTC-USD) and explore the distribution of values, total sum of indicators per hour, and reveal the top frequency pattern indicators such as CDLBelthold, CDLShortLine, CDLClosingMarubozu, CDLLongLine.

    Here are the most popular indicators for 2 years of hourly BTC-USD (crypto) data (17k observations):
      As you can see - there is at least one pattern indicator matched in 77% of cases, and the most popular indicators match 10-20% cases. You can read about the Pattern names on this page: Github TA-Lib pattern indicators .

      In the next step we show the descriptive statistics for the pattern indicators (10 showed out of 61):
        Most of the time, indicator value equals to 0 ("no match"), but sometimes it is +100 or -100 ("indicator was triggered") - you can see this from the min, 25%, 50%, 75%, max fields.

        Finally, we calculate the indicators for all tickers (25 cryptocurrencies and 25 stocks) and combine them into one dataframe. The resulting dataframe comprises approximately 500,000 records, with around 427,000 for cryptocurrencies and 87,000 for stocks. This comprehensive dataset serves as the basis for further analysis and model development.

        Now, let's explore pattern indicators across all records. We're interested in understanding how many indicators can match for one ticker within a period.

        The distribution of pattern indicators ranges from -1000 to +1000 per ticker, per period (hour), with most periods showing 0, 1, or 2 matches. However, some periods may have as many as 8 to 10 matched indicators:

          Analyzing Future Returns Correlation (next 1 and 24 hours predictions)

          Following the generation of new features with indicators, our next step is to assess their correlation with future returns. Even approximate correlations provide valuable clues, guiding us towards relevant indicators to explore among the numerous new fields, facilitating feature return prediction.

          As depicted in the table below, individual technical indicators, including but not limited to pattern indicators, exhibit loose correlations with returns, with absolute correlation values typically below 0.1. While not reaching the extremes of -1 or 1, these correlations still offer valuable insights for analysis.

          Top Correlated Indicators:

          • For 1-hour future growth, notable negative correlations include Commodity Channel Index (CCI, -0.046), Williams %R (WillR, -0.045), and Stochastic Fast (Fast_k and Fast_d, -0.043), while positive correlations are observed with Aroon Indicator (Aroon_1, 0.02).

          • In the case of 24-hour future growth, leading negative correlations encompass Commodity Channel Index (CCI, -0.045), Chande Momentum Oscillator (CMO, -0.043), Relative Strength Index (RSI, -0.04), Williams %R (WillR, -0.04), and (not indicator) historic growth_24h (-0.04). Conversely, positive correlations stand out with Hilbert Transform - SineWave (HT_SINE_LEADSINE, 0.023) and Aroon Indicator (Aroon_1, 0.034).

          Decision Trees for Explainability

          Our next step involves moving beyond mere correlation analysis. We've constructed a simple predictive model, specifically a decision tree, to forecast future growth in 1 and 24 hours and ascertain feature importance. Additionally, we offer insights into the tree's structure by showcasing the features involved in three steps of its path. While these steps may not precisely denote the most crucial features, they provide valuable insights into which features and in what sequence better segment the tree into subtrees.

          The importance of features in the updated list surpasses simple correlations, as they are integrated into a statistical model, collectively influencing predictions rather than acting independently as in correlation analysis.

          Top Indicators for 1-Hour Prediction:

          • (Normalized) Average True Range (Natr, 0.029)
          • Stochastic Fast (Fast_k and Fast_d, 0.026)
          • Growth_2h (0.026)
          • Growth_1h (0.025)
          • Growth_168h (0.025)
          Ivan's Comments: This aligns with intuition, as previous growth (growth_* indicators) typically holds significant importance. Here, three out of five indicators pertain to previous growth.

          Detailed results in the tables below (ALL DATA, ONLY CRYPTO, ONLY STOCKS):
          24-Hour Returns Prediction (Decision Tree):

          • Growth_720h (0.063)
          • The Accumulation/Distribution indicator (AD, 0.054)
          • On-Balance Volume (OBV, 0.05)
          • Growth_168h (0.05)
          • Triple Exponential Average (TRIX, 0.048)
          Ivan's Comments: Similarly, two out of five indicators relate to previous growth, while the remaining three (AD, OBV, TRIX) offer diverse insights.

          Detailed results in the tables below (ALL DATA, ONLY CRYPTO, ONLY STOCKS):
          Understanding how decision trees make predictions can seem complex, but breaking it down simplifies the process. Let's take a peek into the decision-making of a decision tree, focusing on the top 2-3 levels.

          Decision trees start at the root, where key features take center stage. These features, with their associated decision rules (like "feature > value"), are like signposts guiding the tree's path. They're chosen because they best split the data into distinct groups.

          As we traverse down the tree, each level refines the prediction. It's like a game of "20 Questions" where each question (feature) narrows down the possibilities until a guess is made.

          By checking feature values at each level, the decision tree divides the data until it reaches the end, where predictions are made based on the majority in each group.

          This simple breakdown helps demystify how decision trees work, offering a clearer picture of their predictive magic.

          Here is an image of a tree, that predicts 24hrs returns on all data (STOCKS+CRYPTO):

          In conclusion, our analysis has provided a straightforward method for generating a diverse set of technical indicators using the TA-Lib library in Python. By leveraging this powerful tool, traders and investors can effortlessly access over 100 indicators, facilitating comprehensive market analysis.

          Additionally, our study has shed light on the significance of various technical indicators across different datasets, highlighting key predictors for market movements in both cryptocurrency and stock markets. From the identification of top predictive indicators such as the Relative Strength Index (RSI) and Moving Average Convergence Divergence (MACD) to the revelation of highly correlated indicators like the Commodity Channel Index (CCI) and Relative Strength Index (RSI), our findings offer actionable insights for informed decision-making.

          Moreover, our examination of pattern indicators, particularly in BTC-USD data, has revealed common patterns such as CDLBelthold and CDLShortLine, providing valuable signals for traders seeking to capitalize on market trends.

          By equipping traders and investors with a simple yet powerful method for generating technical indicators and providing insights into their predictive power, our study aims to empower market participants to make informed decisions and optimize their trading strategies for success in the dynamic financial landscape.

          Do you find the article useful?

          Do you like the content?
          Consider to make a donation
          Whether you're grateful for the content, or you wish to support one of the ideas in the wishlist (published on the BuyMeACoffee page)

          Leave your feedback on the article

          For example, is it easy to understand?
          For example, could you run the code?
          For example, do you have idea to improve the article ?

          Here you'll find the best articles from PythonInvest. Only useful digests, no spam.