X

X

28 August 2026, 14:49
Rahul Sharma
0
19
PART 1 — XAUUSD ADAPTIVE EDGE M15 EA: MODULAR ARCHITECTURE

INTRODUCTION

The XAUUSD Adaptive Edge M15 Expert Advisor uses ten independent strategy modules:

- five BUY strategies;
- five SELL strategies.

The EA evaluates completed M15 candles, calculates shared market features, and passes valid signals through common risk-management, market-safety and execution controls.

This first part introduces the overall architecture. Individual strategy conditions are covered in later parts.

---

1. MULTI-STRATEGY CONCEPT

The EA separates entry logic into independent modules:

BUY

- BUY Strategy 1
- BUY Strategy 2
- BUY Strategy 3
- BUY Strategy 4
- BUY Strategy 5

SELL

- SELL Strategy 1
- SELL Strategy 2
- SELL Strategy 3
- SELL Strategy 4
- SELL Strategy 5

Each strategy uses the same market features but applies its own conditions.

The strategy layer identifies setups. The risk and execution layers determine whether those setups can become valid trades.

---

2. HIGH-LEVEL ARCHITECTURE

New M15 Bar
     |
     v
Completed Candle
     |
     v
Feature Calculation
     |
     +--> BUY Strategies
     |
     +--> SELL Strategies
     |
     v
Signal Validation
     |
     v
Risk Management
     |
     v
Market-Safety Checks
     |
     v
Execution Validation
     |
   Execute or Skip

Strategy modules generate signals but do not control the complete execution process.

---

3. COMPLETED-CANDLE PROCESSING

The EA detects a new M15 bar and evaluates shift 1, the most recently completed candle.

New M15 Bar
     |
     v
Previous Candle
     |
     v
Calculate Features
     |
     v
Evaluate Strategies

Using completed candles prevents signal values from changing while the candle is still forming.

---

4. FEATURE CALCULATION

Before evaluating strategies, the EA calculates shared market features, including:

- OHLC data;
- candle range and body;
- wick structure;
- close location;
- ATR and volatility ratio;
- fast and slow EMA;
- trend information;
- tick volume;
- momentum;
- hour and day conditions.

Completed Candle
        |
        v
Feature Calculation
        |
        v
Common Feature Set

These standardized inputs are passed to all ten strategies.

---

5. STRATEGY MODULES

Each strategy has its own:

- direction;
- identity;
- magic number;
- enabled/disabled state;
- entry conditions.

struct StrategyDef
{
   string name;
   bool isBuy;
   long magic;
   bool enabled;
};

The exact structure may contain additional fields, but the key principle is that each strategy maintains its identity while sharing the common framework.

---

6. STRATEGY DISPATCHER

The dispatcher evaluates enabled strategies and passes valid signals to the common trade-processing layer.

for(int strategy = 0;
    strategy < StrategyCount;
    ++strategy)
{
   if(!Strategies[strategy].enabled)
      continue;

   bool signal =
      CheckStrategy(strategy, features);

   if(signal)
      ProcessTradeSignal(
         Strategies[strategy],
         features
      );
}

Its main tasks are:

1. identify enabled strategies;
2. evaluate their conditions;
3. process valid signals.

---

7. SEPARATION OF RESPONSIBILITIES

Market Data and Features

Calculates completed-candle data, indicators, volume, momentum and time information.

Strategy Layer

Evaluates the five BUY and five SELL modules.

«Is there a valid trading setup?»

Risk Management

Controls:

- position size;
- Stop Loss and Take Profit;
- Risk-to-Reward;
- holding period;
- maximum open trades;
- daily profit/loss limits;
- consecutive-loss protection.

Market Safety

Checks:

- spread;
- news conditions;
- trading permissions;
- broker stop levels;
- volume limits;
- margin;
- current prices.

Execution

Validates and submits the MetaTrader 5 trade request, including:

- Bid/Ask;
- final SL/TP;
- volume;
- margin;
- "OrderCheck()";
- final price validation.

---

8. SHARED FEATURE SET

A shared feature layer avoids repeating calculations inside every strategy.

For example:

double range = high - low;

can be calculated once and reused by multiple modules.

Completed Candle
       |
       v
Shared Features
       |
       +--> BUY Strategies
       |
       +--> SELL Strategies
       |
       v
Common Framework

This improves consistency, maintenance and extensibility.

---

9. SIGNAL VS EXECUTED TRADE

A valid signal does not guarantee an executed trade.

Strategy Signal
      |
      v
Risk Checks
      |
      v
Market-Safety Checks
      |
      v
Broker Validation
      |
      v
OrderCheck()
      |
      v
Execute or Skip

A trade may be rejected because of:

- trade limits;
- daily protection rules;
- excessive spread;
- news restrictions;
- invalid volume;
- insufficient margin;
- invalid SL/TP distance;
- broker restrictions;
- failed request validation.

---

10. STRATEGY CONTROLS

Individual strategies can be enabled or disabled without changing the remaining modules.

Each strategy can also use its own magic number, allowing trades to be identified by module.

BUY Strategy 1 -> Magic A
BUY Strategy 2 -> Magic B
...
SELL Strategy 5 -> Magic J

---

11. COMMON TRADE FLOW

Strategy Signal
      |
      v
Position Checks
      |
      v
Risk Controls
      |
      v
Spread / News Checks
      |
      v
Bid / Ask Validation
      |
      v
SL / TP Calculation
      |
      v
Volume and Margin Checks
      |
      v
Broker Stop-Level Check
      |
      v
OrderCheck()
      |
      v
Execute or Skip

The same process applies to all ten strategies.

---

12. ARCHITECTURAL ADVANTAGES

A modular EA provides:

- independent strategy development;
- shared calculations;
- consistent risk controls;
- consistent execution validation;
- easier testing;
- centralized maintenance.

---

13. COMPLETE SYSTEM FLOW

XAUUSD M15
    |
    v
New M15 Bar
    |
    v
Completed Candle
    |
    v
Feature Layer
    |
    +--> BUY Strategies
    |
    +--> SELL Strategies
    |
    v
Signal Check
    |
    v
Risk Management
    |
    v
Market-Safety Layer
    |
    v
Execution Validation
    |
    v
OrderCheck
    |
    v
Execute or Skip

The architecture separates:

Market analysis


Signal generation


Risk management


Trade execution

---

14. NEXT PARTS

Part 2 — Market Features and Completed-Candle Processing

Candle structure, ATR, EMA, volume, momentum and time conditions.

Part 3 — BUY Strategies 1–5

The five BUY modules and their signal conditions.

Part 4 — SELL Strategies 1–5

The five SELL modules and their signal conditions.

Part 5 — Risk Management

Position sizing, SL/TP, trade limits, daily protection and consecutive-loss controls.

Part 6 — Trade Execution and Market Safety

Bid/Ask validation, broker limits, volume, margin and "OrderCheck()".

Part 7 — Complete EA Backtest
Testing the interaction between strategies, risk controls and execution.

Part 8 — Complete System Overview

A summary of the complete Expert Advisor architecture.

---

CONCLUSION

The XAUUSD Adaptive Edge M15 Expert Advisor uses ten independent strategy modules supported by shared features and common trade-management controls.

M15 Data
   |
   v
Completed Candle
   |
   v
Feature Calculation
   |
   v
10 Strategies
   |
   v
Signal Validation
   |
   v
Risk Management
   |
   v
Market Safety
   |
   v
Trade Execution

The strategies identify setups, while the risk and execution framework determines whether those setups can become valid MetaTrader 5 trades.

The next part will examine the common market features used by all ten modules.

---

XAUUSD ADAPTIVE EDGE M15 EXPERT ADVISOR

The Expert Advisor is available through the MetaTrader  Market 

Product page:   [  https://www.mql5.com/en/market/product/192502?source=Site+Profile+Seller#!tab=overview  ]



The Market page contains the product description, versions, screenshots and testing information.