# razashoeb07/trading-signal-detector architecture

> Architecture diagram of the GitHub repository razashoeb07/trading-signal-detector, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/razashoeb07/trading-signal-detector
- Repository: https://github.com/razashoeb07/trading-signal-detector

## Overview

This is a single-file Windows desktop signal detector and MT5 auto-executor. The main workflow captures a screen region, preprocesses frames for OCR, parses BUY/SELL price signals, waits for repeated stability, suppresses duplicates, notifies the user, and submits validated orders to MetaTrader 5. The code excerpt shows these stages within main.py; unsampled implementation details are not expanded into separate modules.

Main entry points: [`main.py`](https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py) (Order execution)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Screen Capture"]
  node_scanner["Scanner loop<br/>[main.py]"]
  node_capture_area["Screen capture<br/>[main.py]"]
end

subgraph group_recognition["Signal Recognition"]
  node_preprocess["Frame preprocessing<br/>[main.py]"]
  node_ocr["OCR extraction<br/>[main.py]"]
  node_parse["Signal parsing<br/>[main.py]"]
  node_stability["Stability filter<br/>[main.py]"]
  node_notify["Desktop notification<br/>[main.py]"]
end

subgraph group_execution["Trade Execution"]
  node_executor["Order execution<br/>[main.py]"]
  node_validation["SL/TP validation<br/>[main.py]"]
  node_fill_mode["Filling-mode fallback<br/>[main.py]"]
end

node_user(("Desktop user"))
node_screen["Selected screen region"]
node_tesseract["Tesseract OCR"]
node_mt5["MetaTrader 5"]
node_alerts["Desktop alerts"]

node_user -->|"starts"| node_scanner
node_scanner -->|"captures"| node_capture_area
node_capture_area -->|"reads"| node_screen
node_capture_area -->|"passes frame"| node_preprocess
node_preprocess -->|"passes image"| node_ocr
node_ocr -->|"extracts text"| node_tesseract
node_ocr -->|"passes text"| node_parse
node_parse -->|"checks signals"| node_stability
node_stability -->|"triggers alert"| node_notify
node_notify -->|"sends alert"| node_alerts
node_stability -->|"dispatches signal"| node_executor
node_executor -->|"validates levels"| node_validation
node_executor -->|"selects fallback"| node_fill_mode
node_executor -->|"submits orders"| node_mt5

click node_scanner "https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py"
click node_capture_area "https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py"
click node_preprocess "https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py"
click node_ocr "https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py"
click node_parse "https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py"
click node_stability "https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py"
click node_notify "https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py"
click node_executor "https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py"
click node_validation "https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py"
click node_fill_mode "https://github.com/razashoeb07/trading-signal-detector/blob/main/main.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_scanner,node_capture_area,node_user,node_screen toneBlue
class node_preprocess,node_ocr,node_parse,node_stability,node_notify toneAmber
class node_executor,node_validation,node_fill_mode toneMint
class node_tesseract,node_mt5,node_alerts toneIndigo
```

## Components

### Screen Capture

- [Scanner loop](https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py): `main.py`
- [Screen capture](https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py): `main.py`

### Signal Recognition

- [Frame preprocessing](https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py): `main.py`
- [OCR extraction](https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py): `main.py`
- [Signal parsing](https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py): `main.py`
- [Stability filter](https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py): `main.py`
- [Desktop notification](https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py): `main.py`

### Trade Execution

- [Order execution](https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py): `main.py`
- [SL/TP validation](https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py): `main.py`
- [Filling-mode fallback](https://github.com/razashoeb07/trading-signal-detector/blob/main/main.py): `main.py`

### Other components

- **Desktop user**
- **Selected screen region**
- **Tesseract OCR**
- **MetaTrader 5**
- **Desktop alerts**

## Connections

- Desktop user → Scanner loop: starts (evidence: `main.py`)
- Scanner loop → Screen capture: captures (evidence: `main.py`)
- Screen capture → Selected screen region: reads (evidence: `main.py`)
- Screen capture → Frame preprocessing: passes frame (evidence: `main.py`)
- Frame preprocessing → OCR extraction: passes image (evidence: `main.py`)
- OCR extraction → Tesseract OCR: extracts text (evidence: `main.py`)
- OCR extraction → Signal parsing: passes text (evidence: `main.py`)
- Signal parsing → Stability filter: checks signals (evidence: `main.py`)
- Stability filter → Desktop notification: triggers alert (evidence: `main.py`)
- Desktop notification → Desktop alerts: sends alert (evidence: `main.py`)
- Stability filter → Order execution: dispatches signal (evidence: `main.py`)
- Order execution → SL/TP validation: validates levels (evidence: `main.py`)
- Order execution → Filling-mode fallback: selects fallback (evidence: `main.py`)
- Order execution → MetaTrader 5: submits orders (evidence: `main.py`)
