# guzzuga/xauusd-scalper architecture

> Architecture diagram of the GitHub repository guzzuga/xauusd-scalper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/guzzuga/xauusd-scalper
- Repository: https://github.com/guzzuga/xauusd-scalper

## Overview

This is a command-line XAUUSD scalping application with signal-only, live, and backtest modes. Its main workflow obtains market data, analyzes M1/M5/M15 EMA trends and entry conditions, then presents and logs signals; live mode also applies trade checks and execution handling. The excerpts show MT5 connectivity and optional Telegram alerts. Some mode details and settings wiring are not fully shown, so the graph omits unverified links rather than inferring them.

Main entry points: [`main.py`](https://github.com/guzzuga/xauusd-scalper/blob/main/main.py) (CLI application), [`src/trading_agent.py`](https://github.com/guzzuga/xauusd-scalper/blob/main/src/trading_agent.py) (Trading agent), [`src/mt5_connector.py`](https://github.com/guzzuga/xauusd-scalper/blob/main/src/mt5_connector.py) (MT5 connector), [`src/ema_strategy.py`](https://github.com/guzzuga/xauusd-scalper/blob/main/src/ema_strategy.py) (Timeframe analyzer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime orchestration"]
  node_app["CLI application<br/>[main.py]"]
  node_settings["Trading settings<br/>[settings.py]"]
end

subgraph group_market["Market data"]
  node_feed["Live data feed<br/>[mt5_connector.py]"]
  node_connector["MT5 connector<br/>[mt5_connector.py]"]
  node_mt5["MetaTrader 5"]
end

subgraph group_strategy["Signal strategy"]
  node_analyzer["Timeframe analyzer<br/>[ema_strategy.py]"]
  node_ema["EMA and entry analysis<br/>[ema_strategy.py]"]
end

subgraph group_trading["Trade management"]
  node_agent["Trading agent<br/>[trading_agent.py]"]
  node_risk["Risk manager<br/>[trading_agent.py]"]
  node_filter["Signal filter<br/>[trading_agent.py]"]
end

subgraph group_outputs["Monitoring and alerts"]
  node_dashboard["Signal dashboard"]
  node_logger["Signal logger"]
  node_signalfiles[("Signal log files")]
  node_alerts["Alert manager"]
  node_telegram["Telegram API"]
end

node_user(("Operator"))

node_user -->|"selects mode"| node_app
node_app -->|"connects"| node_connector
node_app -->|"initializes"| node_feed
node_feed -->|"loads candles"| node_connector
node_connector -->|"requests market data"| node_mt5
node_app -->|"processes signals"| node_agent
node_agent -->|"analyzes prices"| node_analyzer
node_analyzer -->|"evaluates EMAs"| node_ema
node_agent -->|"checks trade risk"| node_risk
node_agent -->|"filters signals"| node_filter
node_app -->|"displays status"| node_dashboard
node_app -->|"logs signals"| node_logger
node_logger -->|"writes entries"| node_signalfiles
node_app -->|"sends alerts"| node_alerts
node_alerts -.->|"sends message"| node_telegram

click node_app "https://github.com/guzzuga/xauusd-scalper/blob/main/main.py"
click node_settings "https://github.com/guzzuga/xauusd-scalper/blob/main/config/settings.py"
click node_feed "https://github.com/guzzuga/xauusd-scalper/blob/main/src/mt5_connector.py"
click node_connector "https://github.com/guzzuga/xauusd-scalper/blob/main/src/mt5_connector.py"
click node_analyzer "https://github.com/guzzuga/xauusd-scalper/blob/main/src/ema_strategy.py"
click node_ema "https://github.com/guzzuga/xauusd-scalper/blob/main/src/ema_strategy.py"
click node_agent "https://github.com/guzzuga/xauusd-scalper/blob/main/src/trading_agent.py"
click node_risk "https://github.com/guzzuga/xauusd-scalper/blob/main/src/trading_agent.py"
click node_filter "https://github.com/guzzuga/xauusd-scalper/blob/main/src/trading_agent.py"
click node_dashboard "https://github.com/guzzuga/xauusd-scalper/blob/main/src/signal_dashboard.py"
click node_logger "https://github.com/guzzuga/xauusd-scalper/blob/main/src/signal_dashboard.py"
click node_alerts "https://github.com/guzzuga/xauusd-scalper/blob/main/src/signal_dashboard.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_settings toneBlue
class node_feed,node_connector,node_mt5 toneAmber
class node_analyzer,node_ema toneMint
class node_agent,node_risk,node_filter toneRose
class node_dashboard,node_logger,node_signalfiles,node_alerts,node_telegram,node_user toneIndigo
```

## Components

### Runtime orchestration

- [CLI application](https://github.com/guzzuga/xauusd-scalper/blob/main/main.py): `main.py`
- [Trading settings](https://github.com/guzzuga/xauusd-scalper/blob/main/config/settings.py): `config/settings.py`

### Market data

- [Live data feed](https://github.com/guzzuga/xauusd-scalper/blob/main/src/mt5_connector.py): `src/mt5_connector.py`
- [MT5 connector](https://github.com/guzzuga/xauusd-scalper/blob/main/src/mt5_connector.py): `src/mt5_connector.py`
- **MetaTrader 5**

### Signal strategy

- [Timeframe analyzer](https://github.com/guzzuga/xauusd-scalper/blob/main/src/ema_strategy.py): `src/ema_strategy.py`
- [EMA and entry analysis](https://github.com/guzzuga/xauusd-scalper/blob/main/src/ema_strategy.py): `src/ema_strategy.py`

### Trade management

- [Trading agent](https://github.com/guzzuga/xauusd-scalper/blob/main/src/trading_agent.py): `src/trading_agent.py`
- [Risk manager](https://github.com/guzzuga/xauusd-scalper/blob/main/src/trading_agent.py): `src/trading_agent.py`
- [Signal filter](https://github.com/guzzuga/xauusd-scalper/blob/main/src/trading_agent.py): `src/trading_agent.py`

### Monitoring and alerts

- [Signal dashboard](https://github.com/guzzuga/xauusd-scalper/blob/main/src/signal_dashboard.py): `src/signal_dashboard.py`
- [Signal logger](https://github.com/guzzuga/xauusd-scalper/blob/main/src/signal_dashboard.py): `src/signal_dashboard.py`
- **Signal log files**
- [Alert manager](https://github.com/guzzuga/xauusd-scalper/blob/main/src/signal_dashboard.py): `src/signal_dashboard.py`
- **Telegram API**

### Other components

- **Operator**

## Connections

- Operator → CLI application: selects mode (evidence: `README.md`)
- CLI application → MT5 connector: connects (evidence: `main.py`)
- CLI application → Live data feed: initializes (evidence: `main.py`)
- Live data feed → MT5 connector: loads candles (evidence: `src/mt5_connector.py`)
- MT5 connector → MetaTrader 5: requests market data (evidence: `src/mt5_connector.py`)
- CLI application → Trading agent: processes signals (evidence: `main.py`)
- Trading agent → Timeframe analyzer: analyzes prices (evidence: `src/trading_agent.py`)
- Timeframe analyzer → EMA and entry analysis: evaluates EMAs (evidence: `src/ema_strategy.py`)
- Trading agent → Risk manager: checks trade risk (evidence: `src/trading_agent.py`)
- Trading agent → Signal filter: filters signals (evidence: `src/trading_agent.py`)
- CLI application → Signal dashboard: displays status (evidence: `main.py`)
- CLI application → Signal logger: logs signals (evidence: `main.py`)
- Signal logger → Signal log files: writes entries (evidence: `src/signal_dashboard.py`)
- CLI application → Alert manager: sends alerts (evidence: `main.py`)
- Alert manager → Telegram API: sends message (evidence: `src/signal_dashboard.py`)
