Skip to content

Repository files navigation

GitHub stars GitHub license Python

MT5 Smart Money Concepts

CI Python MetaTrader 5 Plotly Local first

An interactive market-analysis and strategy-backtesting toolkit built around MetaTrader 5, completed candles, and auditable Smart Money Concepts signals.

View the portfolio case study · Usage and troubleshooting

XAUUSD M15 Smart Money Concepts analysis chart

Two focused workflows

Workflow Launcher Purpose
Market analysis run_analysis.bat Display FVGs, order blocks, liquidity, structure, sessions, and confluence on an interactive chart.
Strategy backtest run_backtest.bat Apply a strategy file and inspect its entries, exits, stop-losses, take-profits, balance, and trade history.

Both launchers ask for an MT5 instrument and an execution timeframe in the terminal. M15, H1, and H4 are supported, and custom broker symbol names can be entered.

Quick start

Requirements:

  • Windows;
  • MetaTrader 5 installed, open, logged in, and connected;
  • Python 3.13;
  • a virtual environment named .venv.

Install the dependencies:

.venv\Scripts\python.exe -m pip install -r requirements.txt

Then double-click either run_analysis.bat or run_backtest.bat.

Market analysis

The analysis dashboard uses completed MT5 candles and refreshes after a newly completed candle is available. It can display:

  • fair value gaps and whether they have been mitigated;
  • bullish and bearish order blocks;
  • buy-side and sell-side liquidity;
  • liquidity sweeps;
  • BOS and CHoCH structure events;
  • swing structure and the active dealing range;
  • previous daily and four-hour levels;
  • London and New York sessions;
  • retracement, confluence, and live-session panels.

Reading the chart example

In the screenshot above, green and red zones represent bullish and bearish FVGs, hatched blue and orange zones represent order blocks, dashed horizontal levels represent liquidity or reference levels, and labeled swing points explain the detected structure.

Strategy backtesting

Choose the instrument, execution timeframe, and one of the retained strategy files:

Strategy Main idea
strategies/mtf_trend_pullback.py Align higher-timeframe trends, then enter an execution-timeframe pullback with momentum confirmation.
strategies/ict_liquidity_fvg.py Look for liquidity and fair-value-gap conditions before entering.
strategies/confirmed_smc_pullback.py Require confirmed SMC structure and a valid pullback before entering.

XAUUSD M15 backtest chart with numbered entries, exits, TP, and SL paths

The report includes:

  • numbered entries and exits on the same chart style as the analysis workflow;
  • each trade's initial stop-loss and take-profit;
  • overall win rate, balance, net P&L, profit factor, and drawdown;
  • complete trade history;
  • indicator values captured when each entry was taken;
  • CSV export for an independent audit.

Backtests use completed candles and modeled execution costs. Historical results are simulations, not guarantees of future performance.

Privacy and scope

  • Both web interfaces bind to 127.0.0.1; they are not published as internet services.
  • MT5 account credentials are neither requested nor stored by this repository.
  • Generated candles, reports, CSV files, Plotly assets, logs, caches, and lock files stay under ignored local paths.
  • Strategy files contain research rules only. Nothing in this project places a live order.

Before publishing a fork, review its Git history and never commit broker credentials, account exports, or generated market-data files.

Command-line use

The launchers also accept arguments for repeatable runs:

run_analysis.bat --symbol EURUSD --timeframe H1

run_backtest.bat --symbol XAUUSD --timeframe M15 --strategy strategies\ict_liquidity_fvg.py

Backtest-only options:

  • --use-cache reuses the latest cached candles;
  • --no-browser does not open the report automatically;
  • --once writes the result and exits without keeping a local service open.

Project structure

gold_smc/          Shared chart, MT5, indicator, dashboard, and backtest code
strategies/        Editable strategy definitions
tests/             Automated regression tests
docs/images/       README screenshots and trading-chart examples
run_analysis.bat   Market-analysis launcher
run_backtest.bat   Strategy-backtest launcher

Runtime files are written to outputs/ and excluded from Git. The local Plotly runtime is generated automatically when it is missing.

Development

Run the regression suite with:

.venv\Scripts\python.exe -m unittest discover -s tests -v

The GitHub Actions workflow runs the same suite on Windows and Python 3.13.

Topics

metatrader5 · smart-money-concepts · algorithmic-trading · backtesting · technical-analysis · price-action · forex · xauusd · plotly · python

See docs/USAGE.md for detailed usage and troubleshooting.

About

Smart Money Concepts (SMC) trading strategy project for analyzing Gold (XAUUSD) using market structure, liquidity, order blocks, and fair value gaps.

Topics

Resources

Stars

7 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Contributors

Languages