# nevio111998/algorithmic-trading-trendstrategy architecture

> Architecture diagram of the GitHub repository nevio111998/algorithmic-trading-trendstrategy, 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/nevio111998/algorithmic-trading-trendstrategy
- Repository: https://github.com/nevio111998/algorithmic-trading-trendstrategy

## Overview

This repository contains two versions of a MetaTrader 5 trend-following Expert Advisor. The documented workflow moves from daily bias through H4 structure and retracement analysis to M15 momentum entries; trade management adds ATR stops and risk-based sizing. Version 2.0 retains the signal logic and adds pre-trade safeguards, hardened execution, persistent state, and trade/rejection logging. The source files were not available to inspect, so component relationships below rely on README statements rather than implementation details.

Main entry points: [`TrendFollowingEA_V2.0.mq5`](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA_V2.0.mq5) (Order Execution), [`TrendFollowingEA.mq5`](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA.mq5) (M15 Entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_analysis["Strategy Analysis"]
  node_daily["Daily Bias"]
  node_structure["H4 Structure"]
  node_fvg["FVG Zones"]
  node_entry["M15 Entry"]
end

subgraph group_risk["Risk Controls"]
  node_atr["ATR Stops"]
  node_sizing["Position Sizing"]
  node_session["Session Filter"]
  node_guards["Safety Guards"]
  node_circuit["Circuit Breaker"]
  node_exposure["Exposure Checks"]
end

subgraph group_execution["Execution and State"]
  node_execution["Order Execution"]
  node_state["Persistent State"]
end

subgraph group_monitoring["Trade Monitoring"]
  node_journal["Trade Journal"]
  node_rejections["Rejected Trades"]
end

node_market(("Market Data"))
node_mt5(("MetaTrader 5"))

node_market -.->|"analyzes"| node_daily
node_daily -->|"sets context"| node_structure
node_structure -->|"identifies zones"| node_fvg
node_fvg -.->|"informs entries"| node_entry
node_entry -.->|"sets stop"| node_atr
node_entry -.->|"sizes trade"| node_sizing
node_mt5 -->|"hosts EA"| node_execution
node_guards -->|"validates before"| node_execution
node_exposure -->|"checks before"| node_execution
node_execution -.->|"logs trades"| node_journal
node_execution -.->|"logs rejections"| node_rejections
node_state -.->|"supports recovery"| node_execution
node_session -.->|"filters trading"| node_entry
node_circuit -.->|"limits trading"| node_execution

click node_daily "https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA.mq5"
click node_structure "https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA.mq5"
click node_fvg "https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA.mq5"
click node_entry "https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA.mq5"
click node_atr "https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA.mq5"
click node_sizing "https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA.mq5"
click node_session "https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA.mq5"
click node_guards "https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA_V2.0.mq5"
click node_circuit "https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA_V2.0.mq5"
click node_exposure "https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA_V2.0.mq5"
click node_execution "https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA_V2.0.mq5"
click node_state "https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA_V2.0.mq5"
click node_journal "https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA_V2.0.mq5"
click node_rejections "https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA_V2.0.mq5"

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_daily,node_structure,node_fvg,node_entry toneBlue
class node_atr,node_sizing,node_session,node_guards,node_circuit,node_exposure toneAmber
class node_execution,node_state toneMint
class node_journal,node_rejections toneRose
class node_market,node_mt5 toneIndigo
```

## Components

### Strategy Analysis

- [Daily Bias](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA.mq5): `TrendFollowingEA.mq5`
- [H4 Structure](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA.mq5): `TrendFollowingEA.mq5`
- [FVG Zones](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA.mq5): `TrendFollowingEA.mq5`
- [M15 Entry](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA.mq5): `TrendFollowingEA.mq5`

### Risk Controls

- [ATR Stops](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA.mq5): `TrendFollowingEA.mq5`
- [Position Sizing](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA.mq5): `TrendFollowingEA.mq5`
- [Session Filter](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA.mq5): `TrendFollowingEA.mq5`
- [Safety Guards](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA_V2.0.mq5): `TrendFollowingEA_V2.0.mq5`
- [Circuit Breaker](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA_V2.0.mq5): `TrendFollowingEA_V2.0.mq5`
- [Exposure Checks](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA_V2.0.mq5): `TrendFollowingEA_V2.0.mq5`

### Execution and State

- [Order Execution](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA_V2.0.mq5): `TrendFollowingEA_V2.0.mq5`
- [Persistent State](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA_V2.0.mq5): `TrendFollowingEA_V2.0.mq5`

### Trade Monitoring

- [Trade Journal](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA_V2.0.mq5): `TrendFollowingEA_V2.0.mq5`
- [Rejected Trades](https://github.com/nevio111998/algorithmic-trading-trendstrategy/blob/main/TrendFollowingEA_V2.0.mq5): `TrendFollowingEA_V2.0.mq5`

### Other components

- **Market Data**
- **MetaTrader 5**

## Connections

- Market Data → Daily Bias: analyzes (evidence: `README.md`)
- Daily Bias → H4 Structure: sets context (evidence: `README.md`)
- H4 Structure → FVG Zones: identifies zones (evidence: `README.md`)
- FVG Zones → M15 Entry: informs entries
- M15 Entry → ATR Stops: sets stop
- M15 Entry → Position Sizing: sizes trade
- MetaTrader 5 → Order Execution: hosts EA (evidence: `README.md`)
- Safety Guards → Order Execution: validates before (evidence: `README.md`)
- Exposure Checks → Order Execution: checks before (evidence: `README.md`)
- Order Execution → Trade Journal: logs trades
- Order Execution → Rejected Trades: logs rejections
- Persistent State → Order Execution: supports recovery
- Session Filter → M15 Entry: filters trading
- Circuit Breaker → Order Execution: limits trading
