Loading image

Blogs / Technology

Predicting Cryptocurrency Price Movements with Candlestick Charts & Technical Indicators

Predicting Cryptocurrency Price Movements with Candlestick Charts & Technical Indicators

  • showkat ali
  • 0 Comments
  • 216 View

๐Ÿง  Introduction: Why Predicting Crypto Price Movement Is Crucial

Cryptocurrencies are notorious for their volatility, but with the right tools, you can spot trends and react with confidence. This article explains how our Python-based crypto forecasting tool analyzes candlestick patterns and technical indicators like RSI and Momentum to predict the next price movement — for any cryptocurrency, whether it's Ethereum (ETH), Solana (SOL), or even emerging altcoins.


โš™๏ธ How It Works: Step-by-Step Breakdown

This tool gives hourly predictions based on 7 days of historical market data from Yahoo Finance.

โœ… Step 1: Fetch Live Crypto Market Data

Using yfinance, the script pulls OHLCV data for any coin pair like:

  • ETH-USD

  • SOL-USD

  • XRP-USD

โœ… Step 2: Apply Technical Indicators

We calculate:

  • RSI (Relative Strength Index): Measures overbought/oversold strength.

  • Momentum (Rate of Change): Detects velocity and direction of price movement.

  • ATR (Average True Range): Estimates market volatility.

โœ… Step 3: Make a Prediction

Our model checks for:

  • Bullish Signals: Close > Open, RSI < 30, Momentum > 0

  • Bearish Signals: Close < Open, RSI > 70, Momentum < 0

  • Neutral: No strong signal detected

โœ… Step 4: Price Range Forecast

We use the ATR to predict the high and low of the next candlestick, helping traders plan entry and exit zones.

โœ… Step 5: Plot & Save the Candlestick Chart

Using mplfinance, the last 60 candles are plotted with:

 

  • Real-time support & resistance levels

  • Volume

  • Visual overlays

 Candlestick Chart

Final Candlestick Prediction Python Script (BTC-USD, 1H)

import yfinance as yf
import pandas as pd
import ta
import mplfinance as mpf
from datetime import datetime

def predict_next_candle():
    ticker = "BTC-USD"        // change the coin (ETH-USD , TRB-USD , SOL-USD)
    interval = "1h"
    lookback = "7d"

    print(f"Fetching data for {ticker}...")

    # Download data
    df = yf.download(ticker, interval=interval, period=lookback, auto_adjust=False)

    # ๐Ÿ”ง Fix MultiIndex column issue
    if isinstance(df.columns[0], tuple):
        df.columns = [col[0] for col in df.columns]

    print("Cleaned Columns:", df.columns.tolist())

    # Drop rows with missing required data
    required_cols = ['Open', 'High', 'Low', 'Close', 'Volume']
    df.dropna(subset=required_cols, inplace=True)

    # Add technical indicators
    df['RSI'] = ta.momentum.RSIIndicator(close=df['Close']).rsi()
    df['Momentum'] = ta.momentum.ROCIndicator(close=df['Close']).roc()

    # Drop rows with NaNs created by indicators
    df.dropna(inplace=True)

    # Get last row for prediction
    last = df.iloc[-1]
    is_bull = (last['Close'] > last['Open'] and last['RSI'] < 30 and last['Momentum'] > 0)
    is_bear = (last['Close'] < last['Open'] and last['RSI'] > 70 and last['Momentum'] < 0)

    if is_bull:
        prediction = "๐Ÿ“ˆ Prediction: Next candle is likely Bullish"
    elif is_bear:
        prediction = "๐Ÿ“‰ Prediction: Next candle is likely Bearish"
    else:
        prediction = "โ“ Prediction: Neutral / Sideways"

    # Estimate ATR (volatility) and next candle price range
    df['HL'] = df['High'] - df['Low']
    atr_period = 14
    atr = df['HL'].rolling(window=atr_period).mean().iloc[-1]
    predicted_low = last['Close'] - atr
    predicted_high = last['Close'] + atr

    # Support & Resistance
    recent_data = df.tail(60)
    support = recent_data['Low'].min()
    resistance = recent_data['High'].max()

    # Print enhanced prediction
    print("\n๐Ÿ“Š Prediction Summary")
    print(f"๐Ÿ•’ Time: {datetime.now()}")
    print(f"{prediction}")
    print(f"๐Ÿ“‰ Support: {support:.2f}")
    print(f"๐Ÿ“ˆ Resistance: {resistance:.2f}")
    print(f"\n๐Ÿ“ Predicted Next Candle Range:")
    print(f"→ From: {predicted_low:.2f}")
    print(f"→ To:   {predicted_high:.2f}")
    print(f"↔ Expected Volatility (ATR): {atr:.2f}")
    print(f"\n๐Ÿ•ฏ๏ธ Last Candle Info:")
    print(f"Open:     {last['Open']:.2f}")
    print(f"High:     {last['High']:.2f}")
    print(f"Low:      {last['Low']:.2f}")
    print(f"Close:    {last['Close']:.2f}")
    print(f"RSI:      {last['RSI']:.2f}")
    print(f"Momentum: {last['Momentum']:.2f}")

    # Plot candlestick chart with support/resistance lines
    apds = [
        mpf.make_addplot([support] * len(recent_data), color='green', linestyle='--'),
        mpf.make_addplot([resistance] * len(recent_data), color='red', linestyle='--')
    ]

    mpf.plot(
        recent_data,
        type='candle',
        style='yahoo',
        title=f'{ticker} - Last 60 Candles',
        ylabel='Price ($)',
        volume=True,
        addplot=apds
    )

    # Save to file
    with open("prediction.txt", "w", encoding="utf-8") as f:
        f.write("๐Ÿ“Š Prediction Summary\n")
        f.write(f"๐Ÿ•’ Time: {datetime.now()}\n")
        f.write(f"{prediction}\n")
        f.write(f"Support: {support:.2f}\n")
        f.write(f"Resistance: {resistance:.2f}\n")
        f.write(f"\nPredicted Next Candle Range:\n")
        f.write(f"→ From: {predicted_low:.2f}\n")
        f.write(f"→ To:   {predicted_high:.2f}\n")
        f.write(f"Volatility (ATR): {atr:.2f}\n")
        f.write(f"\nLast Candle Info:\n")
        f.write(f"Open:     {last['Open']:.2f}\n")
        f.write(f"High:     {last['High']:.2f}\n")
        f.write(f"Low:      {last['Low']:.2f}\n")
        f.write(f"Close:    {last['Close']:.2f}\n")
        f.write(f"RSI:      {last['RSI']:.2f}\n")
        f.write(f"Momentum: {last['Momentum']:.2f}\n")

    print("\nโœ… Prediction saved to 'prediction.txt'")

if __name__ == "__main__":
    predict_next_candle()

๐Ÿงพ Sample Output

๐Ÿ“Š Prediction Summary
๐Ÿ•’ Time: 2025-07-25 11:20:41.872191
โ“ Prediction: Neutral / Sideways
๐Ÿ“‰ Support: 115168.35
๐Ÿ“ˆ Resistance: 120265.52

๐Ÿ“ Predicted Next Candle Range:
→ From: 114987.43
→ To:   116227.28
↔ Expected Volatility (ATR): 619.92

๐Ÿ•ฏ๏ธ Last Candle Info:
Open:     115607.35
High:     116155.85
Low:      115364.42
Close:    115607.35
RSI:      23.58
Momentum: -193.28

โœ… Prediction saved to 'prediction.txt'

 

And the tool generates a full candlestick chart in a window.


๐Ÿ’ก Use Cases

  • โœ… Short-Term Trading Decisions

  • ๐Ÿ“‰ Risk Management via Support/Resistance

  • ๐Ÿ“Š Visual Backtesting with Historical Trends


๐Ÿ› ๏ธ How to Run It Yourself

Here’s how you can customize the asset being analyzed:

 

In your script, change this line:

 

ticker = "ETH-USD"  # or SOL-USD, ADA-USD, etc.
  • Technology
showkat ali Author

showkat ali

Greetings, I'm a passionate full-stack developer and entrepreneur. I specialize in PHP, Laravel, React.js, Node.js, JavaScript, and Python. I own interviewsolutionshub.com, where I share tech tutorials, tips, and interview questions. I'm a firm believer in hard work and consistency. Welcome to interviewsolutionshub.com, your source for tech insights and career guidance.

0 Comments

Post Comment

Recent Blogs

Recent posts form our Blog

Laravel 11 Cron Job Task Scheduling with Example

Laravel 11 Cron Job Task Scheduling with Example

showkat ali
/
Programming

Read More
The Difference Between === and == in JavaScript: A Complete Guide

The Difference Between === and == in JavaScript: A Complete Guide

showkat ali
/
Programming

Read More
The Importance of Employee Engagement: Strategies for Boosting Productivity and Retention

The Importance of Employee Engagement: Strategies for Boosting Productivity and Retention

rimsha akbar
/
Human Resource

Read More
How to Get a Job at Google: A Step-by-Step Guide

How to Get a Job at Google: A Step-by-Step Guide

showkat ali
/
Technology

Read More
Most Top Paying Technologies in 2024

Most Top Paying Technologies in 2024

showkat ali
/
Programming

Read More
Using Multiple Select as Count in the Select2 Search Box

Using Multiple Select as Count in the Select2 Search Box

showkat ali
/
Programming

Read More