Skip to content

ThangakumarC/forex-signal-prediction

Repository files navigation

📈 Real-Time FOREX Signal Prediction Dashboard using LSTM

📌 Project Overview

The Foreign Exchange (FOREX) market exhibits high volatility, non-linearity, and strong temporal dependencies that traditional rule-based trading strategies fail to model effectively. This project implements a real-time FOREX Signal Prediction System using Long Short-Term Memory (LSTM) networks combined with neural feature prediction and a live Streamlit dashboard.

The system fetches live OHLC price data from the Twelve Data (12fdata) API, predicts key technical indicators using neural regression models, and generates Buy, Sell, or Hold trading signals with confidence scores, take-profit (TP), and stop-loss (SL) levels.

🎯 Objectives

  • Generate real-time Buy / Sell / Hold trading signals
  • Capture temporal market behavior using LSTM
  • Predict technical indicators using neural networks instead of formulas
  • Visualize live signals through an interactive Streamlit dashboard
  • Provide a practical decision-support tool for FOREX traders

🧠 System Architecture

The system follows a hybrid deep learning architecture:

  1. Live Data Ingestion
    • OHLC data fetched from Twelve Data API
  2. Neural Feature Prediction
    • EMA-10, EMA-50, ATR, Support, Resistance
    • RSI predicted using a separate neural model
  3. LSTM Signal Model
    • Uses rolling time windows to predict trade signals
  4. Risk Management Logic
    • ATR-based Take Profit and Stop Loss calculation
  5. Streamlit Dashboard
    • Real-time visualization and signal monitoring

🔴 Real-Time Data Source (Twelve Data API)

Live market data is obtained using the Twelve Data REST API.

Configuration used in the project:

  • Symbol: EUR/USD
  • Interval: 5 minutes
  • Output size: 150 candles
  • Data fields: Open, High, Low, Close (OHLC)

📊 Features Used

🔹 Price-Based Inputs

  • Open
  • High
  • Low
  • Close
  • Daily Range (High − Low)

🔹 Predicted Technical Indicators

  • Exponential Moving Average (EMA-10)
  • Exponential Moving Average (EMA-50)
  • Relative Strength Index (RSI)
  • Average True Range (ATR)
  • Support Level
  • Resistance Level

All indicators are predicted using trained neural networks, not calculated using traditional formulas.

⚙️ Methodology

  1. Fetch live OHLC data from Twelve Data API
  2. Create lag features for time-series learning
  3. Predict RSI using a dedicated neural network
  4. Predict EMA, ATR, Support & Resistance using a feature regression model
  5. Feed the last 20 timesteps into the LSTM model
  6. Predict Buy / Sell / Hold signal with confidence
  7. Compute ATR-based Take Profit (TP) and Stop Loss (SL)
  8. Log and visualize results in real time

🤖 Model Details

🔹 Feature Predictor Model

  • Predicts: EMA_10, EMA_50, ATR, Support, Resistance
  • Input: OHLC + lag features

🔹 RSI Predictor Model

  • Predicts RSI values from price history
  • Separate scaler and neural network

🔹 LSTM Signal Model

  • Input shape: (1, 20, 11)
  • Output classes:
    • Buy
    • Sell
    • Hold

📈 Performance Metrics

  • Mean Absolute Error (MAE)
  • Signal confidence score
  • Stability of Buy/Sell decisions
  • Visual backtesting via live charts

🖥️ Technologies Used

  • Python
  • TensorFlow / Keras
  • Pandas, NumPy
  • Scikit-learn
  • Streamlit
  • Plotly
  • Twelve Data (12fdata) API

🚀 How to Run the Project

# Clone the repository
git clone https://github.com/your-username/forex-signal-prediction.git
cd forex-signal-prediction

# Get your 12data API Key
 
# Install dependencies
pip install -r requirements.txt

# Run the Streamlit dashboard
streamlit run dashboard.py

Result

image image image

About

A real-time FOREX signal prediction system that uses LSTM neural networks and neural feature models to generate Buy, Sell, and Hold signals from live market data fetched via the Twelve Data API, visualized through an interactive Streamlit dashboard.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors