Skip to main content

Overview

The XAUUSD Trading Bot analyzes market data across multiple timeframes to provide comprehensive trading signals. Each timeframe offers different perspectives on market trends and patterns.

Supported Timeframes

The bot supports six standard timeframes, from daily to 5-minute charts:
# Timeframes are returned in the market_data dictionary
result = bot.run_analysis()

for timeframe in result['market_data'].keys():
    print(timeframe)
    
# Output:
# D1
# H4
# H1
# M30
# M15
# M5

Timeframe Definitions

D1 - Daily

D1
string
Daily timeframe - Each candle represents one trading dayUse cases:
  • Long-term trend identification
  • Major support/resistance levels
  • Swing trading strategies
  • Position trading entries/exits
Typical analysis period: 30-90 days of data

H4 - 4-Hour

H4
string
4-Hour timeframe - Each candle represents 4 hours of tradingUse cases:
  • Medium-term trend analysis
  • Intraday swing trading
  • Identifying session-based patterns
  • Confirming daily trends
Typical analysis period: 10-30 days of data

H1 - 1-Hour

H1
string
1-Hour timeframe - Each candle represents 1 hour of tradingUse cases:
  • Short-term trend analysis
  • Intraday trading opportunities
  • Session breakout strategies
  • Fine-tuning entry/exit points
Typical analysis period: 5-15 days of data

M30 - 30-Minute

M30
string
30-Minute timeframe - Each candle represents 30 minutes of tradingUse cases:
  • Scalping and day trading
  • Quick trend reversals
  • News event trading
  • Precise entry timing
Typical analysis period: 3-7 days of data

M15 - 15-Minute

M15
string
15-Minute timeframe - Each candle represents 15 minutes of tradingUse cases:
  • Active day trading
  • Scalping strategies
  • Quick profit targets
  • High-frequency analysis
Typical analysis period: 1-3 days of data

M5 - 5-Minute

M5
string
5-Minute timeframe - Each candle represents 5 minutes of tradingUse cases:
  • Ultra-short-term scalping
  • Market microstructure analysis
  • Very tight stop-losses
  • Rapid trade execution
Typical analysis period: 1-2 days of data

Multi-Timeframe Analysis

The bot performs analysis across all timeframes simultaneously to provide a comprehensive market view:

Displaying Timeframe Data

The Streamlit application displays timeframe data in a grid layout:
import streamlit as st

def display_market_data(data_str, timeframe):
    """Display formatted market data in an expander"""
    with st.expander(f"📊 {timeframe} Market Data", expanded=False):
        lines = data_str.split('\n')
        for line in lines:
            if line.strip():
                st.text(line)

# Display in 2-column grid
st.markdown("### 📈 Market Data by Timeframe")
cols = st.columns(2)

for idx, (tf, data) in enumerate(result['market_data'].items()):
    with cols[idx % 2]:
        display_market_data(data, tf)

Timeframe Data Structure

Each timeframe’s data is returned as a formatted multi-line string:
market_data[timeframe]
string
Formatted market data containing:
  • Price Data: Open, High, Low, Close (OHLC)
  • Volume: Trading volume for the period
  • Technical Indicators: Moving averages, RSI, MACD, etc.
  • Trend Information: Current trend direction and strength
  • Support/Resistance: Key price levels

Example Data Format

result = bot.run_analysis()
print(result['market_data']['H1'])

# Example output:
# Timeframe: H1
# Current Price: 2654.32
# High: 2656.18
# Low: 2651.45
# Volume: 15420
# Trend: BULLISH
# RSI: 62.4
# MACD: Positive crossover
# Support: 2650.00
# Resistance: 2660.00

Best Practices

Code Examples

result = bot.run_analysis()

# Access specific timeframe data
h4_data = result['market_data']['H4']
print(f"4-Hour Chart Data:\n{h4_data}")

Build docs developers (and LLMs) love