# piardian/trendflowing-forex-ea architecture

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

- Interactive diagram: https://gitdiagram.com/piardian/trendflowing-forex-ea
- Repository: https://github.com/piardian/trendflowing-forex-ea

## Overview

TrendFlowing is a MetaTrader 5 Forex Expert Advisor for systematic research. Its documented workflow filters the higher-timeframe trend, detects lower-timeframe setups, constructs a risk-sized entry, applies risk guards, executes trades, manages open positions, and journals events. The graph follows the README’s architecture and module descriptions; source excerpts were not provided, so relationships are limited to those documented there.

Main entry points: [`src/TrendDetector.mqh`](https://github.com/piardian/trendflowing-forex-ea/blob/main/src/TrendDetector.mqh) (Trend Detector), [`src/SetupDetector.mqh`](https://github.com/piardian/trendflowing-forex-ea/blob/main/src/SetupDetector.mqh) (Setup Detector), [`src/EntryEngine.mqh`](https://github.com/piardian/trendflowing-forex-ea/blob/main/src/EntryEngine.mqh) (Entry Engine), [`src/RiskManager.mqh`](https://github.com/piardian/trendflowing-forex-ea/blob/main/src/RiskManager.mqh) (Risk Manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Market Analysis"]
  node_trend["Trend Detector<br/>[TrendDetector.mqh]"]
  node_setup["Setup Detector<br/>[SetupDetector.mqh]"]
end

subgraph group_decision["Trade Decision"]
  node_entry["Entry Engine<br/>[EntryEngine.mqh]"]
  node_risk["Risk Manager<br/>[RiskManager.mqh]"]
end

subgraph group_lifecycle["Trade Lifecycle"]
  node_execution["Execution Engine"]
  node_trade["Trade Manager<br/>[TradeManager.mqh]"]
end

subgraph group_observability["Event Logging"]
  node_logger["Event Logger<br/>[Logger.mqh]"]
end

node_mt5(("MetaTrader 5"))
node_ea["Expert Advisor<br/>[TrendFlowing.mq5]"]

node_mt5 -->|"hosts"| node_ea
node_ea -->|"filters trend"| node_trend
node_trend -->|"guides search"| node_setup
node_setup -->|"informs entry"| node_entry
node_entry -->|"sizes positions"| node_risk
node_risk -->|"guards opening"| node_execution
node_execution -->|"opens trades"| node_trade
node_trade -->|"journals events"| node_logger

click node_ea "https://github.com/piardian/trendflowing-forex-ea/blob/main/src/TrendFlowing.mq5"
click node_trend "https://github.com/piardian/trendflowing-forex-ea/blob/main/src/TrendDetector.mqh"
click node_setup "https://github.com/piardian/trendflowing-forex-ea/blob/main/src/SetupDetector.mqh"
click node_entry "https://github.com/piardian/trendflowing-forex-ea/blob/main/src/EntryEngine.mqh"
click node_risk "https://github.com/piardian/trendflowing-forex-ea/blob/main/src/RiskManager.mqh"
click node_execution "https://github.com/piardian/trendflowing-forex-ea/blob/main/src/ExecutionEngine.mqh"
click node_trade "https://github.com/piardian/trendflowing-forex-ea/blob/main/src/TradeManager.mqh"
click node_logger "https://github.com/piardian/trendflowing-forex-ea/blob/main/src/Logger.mqh"

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_trend,node_setup toneBlue
class node_entry,node_risk toneAmber
class node_execution,node_trade toneMint
class node_logger toneRose
class node_mt5 toneIndigo
class node_ea toneTeal
```

## Components

### Market Analysis

- [Trend Detector](https://github.com/piardian/trendflowing-forex-ea/blob/main/src/TrendDetector.mqh): `src/TrendDetector.mqh`
- [Setup Detector](https://github.com/piardian/trendflowing-forex-ea/blob/main/src/SetupDetector.mqh): `src/SetupDetector.mqh`

### Trade Decision

- [Entry Engine](https://github.com/piardian/trendflowing-forex-ea/blob/main/src/EntryEngine.mqh): `src/EntryEngine.mqh`
- [Risk Manager](https://github.com/piardian/trendflowing-forex-ea/blob/main/src/RiskManager.mqh): `src/RiskManager.mqh`

### Trade Lifecycle

- [Execution Engine](https://github.com/piardian/trendflowing-forex-ea/blob/main/src/ExecutionEngine.mqh): `src/ExecutionEngine.mqh`
- [Trade Manager](https://github.com/piardian/trendflowing-forex-ea/blob/main/src/TradeManager.mqh): `src/TradeManager.mqh`

### Event Logging

- [Event Logger](https://github.com/piardian/trendflowing-forex-ea/blob/main/src/Logger.mqh): `src/Logger.mqh`

### Other components

- **MetaTrader 5**
- [Expert Advisor](https://github.com/piardian/trendflowing-forex-ea/blob/main/src/TrendFlowing.mq5): `src/TrendFlowing.mq5`

## Connections

- MetaTrader 5 → Expert Advisor: hosts (evidence: `README.md`)
- Expert Advisor → Trend Detector: filters trend (evidence: `README.md`)
- Trend Detector → Setup Detector: guides search (evidence: `README.md`)
- Setup Detector → Entry Engine: informs entry (evidence: `README.md`)
- Entry Engine → Risk Manager: sizes positions (evidence: `README.md`)
- Risk Manager → Execution Engine: guards opening (evidence: `README.md`)
- Execution Engine → Trade Manager: opens trades (evidence: `README.md`)
- Trade Manager → Event Logger: journals events (evidence: `README.md`)
