e49nana
Algorithmic-trading
MQL5

Open-source trading tools (MQL5 & NinjaTrader) + DeFi crypto bot + AlgoSphere Quant showcase

Last updated Jun 10, 2026
41
Stars
11
Forks
0
Issues
0
Stars/day
Attention Score
69
Language breakdown
MQL5 45.3%
C# 26.4%
MQL4 25.2%
Python 1.7%
HTML 1.2%
Solidity 0.3%
โ–ธ Files click to expand
README

MQL5 C# Python Web3.py Solidity Ethereum License: MIT

Open-source tools & strategies for algorithmic trading โ€” from traditional markets to DeFi. Commercial products by AlgoSphere Quant are listed below but hosted on the MQL5 Marketplace.


๐Ÿ“– About

This repository brings together my algorithmic trading work across two worlds:

| | TradFi | DeFi | |---|---|---| | Platforms | MetaTrader 5, NinjaTrader | Ethereum, Arbitrum, Polygon, Solana | | Languages | MQL5, C# | Python, Solidity (learning) | | Focus | Indicators, EAs, position management | CEX/DEX connectors, arbitrage, MEV | | Status | Mature (14+ products) | Active development |


๐Ÿ“‚ Repository Structure

Algorithmic-Trading/
โ”‚
โ”œโ”€โ”€ tradfi/
โ”‚   โ”œโ”€โ”€ mql5/
โ”‚   โ”‚   โ”œโ”€โ”€ libraries/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ SessionTimeFilter.mqh
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ PositionSizer.mqh
โ”‚   โ”‚   โ”œโ”€โ”€ indicators/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ SpreadAnalyzer.mq5
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ CandlePatternDetector.mq5
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ MultiTimeframeDashboard.mq5
โ”‚   โ”‚   โ”œโ”€โ”€ experts/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ DrawdownGuard.mq5
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ TradeStatistics.mq5
โ”‚   โ”‚   โ””โ”€โ”€ scripts/
โ”‚   โ”‚       โ”œโ”€โ”€ RiskCalculator.mq5
โ”‚   โ”‚       โ””โ”€โ”€ TradeJournal.mq5
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ ninjatrader/
โ”‚       โ”œโ”€โ”€ indicators/
โ”‚       โ”‚   โ”œโ”€โ”€ VolumeProfile.cs
โ”‚       โ”‚   โ”œโ”€โ”€ OrderFlowImbalance.cs
โ”‚       โ”‚   โ””โ”€โ”€ SessionHighLow.cs
โ”‚       โ””โ”€โ”€ strategies/
โ”‚           โ””โ”€โ”€ snippets/
โ”‚
โ”œโ”€โ”€ defi/
โ”‚   โ”œโ”€โ”€ crypto-trade-bot/
โ”‚   โ”‚   โ”œโ”€โ”€ connectors/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ cex/                       # CEX connectors (Binance, Bybit, OKX)
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ base.py
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ binance.py
โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ bybit.py
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ okx.py
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ dex/                       # DEX connectors
โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ base.py                # AbstractDEXConnector
โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ uniswap.py             # Uniswap V3 (Web3.py)
โ”‚   โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ exchangeratelimiter.py   # Token bucket rate limiting
โ”‚   โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ””โ”€โ”€ tests/                         # 294 tests, 0 failures
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ contracts/                         # Solidity (coming soon)
โ”‚       โ””โ”€โ”€ README.md
โ”‚
โ””โ”€โ”€ docs/
    โ”œโ”€โ”€ architecture.md
    โ””โ”€โ”€ defi-roadmap.md

๐Ÿ’น TradFi โ€” MetaTrader 5 & NinjaTrader

MQL5 โ€” Open-Source Tools

| Tool | Description | Type | |------|-------------|------| | SessionTimeFilter | Filter trades by session (London, NY, Tokyo, Sydney) with overlap detection | Library | | PositionSizer | Risk-based position sizing โ€” fixed lot, percent risk, Kelly criterion | Library | | SpreadAnalyzer | Real-time spread monitoring with statistics (avg, max, percentile) | Indicator | | CandlePatternDetector | Automated detection of 15+ candlestick patterns with alerts | Indicator | | MultiTimeframeDashboard | Multi-timeframe trend direction panel (RSI, MA, ADX) | Indicator | | DrawdownGuard | Automated equity protection with daily/weekly drawdown limits | Expert | | TradeStatistics | Real-time win rate, expectancy, profit factor, Sharpe ratio | Expert | | RiskCalculator | One-click lot size calculator based on SL distance & risk % | Script | | TradeJournal | Export complete trade history to CSV for external analysis | Script |

All MQL5 tools are also available on the MQL5 Code Base.

NinjaTrader โ€” C# Indicators

| Indicator | Description | Market | |-----------|-------------|--------| | VolumeProfile | Volume distribution at each price level, VAH/VAL/POC | Futures | | OrderFlowImbalance | Bid/Ask imbalance detection for scalping | Futures | | SessionHighLow | Automatic session (RTH/ETH) high/low/mid levels | Futures |


โ›“๏ธ DeFi โ€” Crypto Trading Bot

Multi-exchange, multi-chain trading bot with CEX and DEX support, built in Python with async architecture.

Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     Telegram Bot Interface                    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                      Strategy Engine                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚   CEX Connectors   โ”‚            DEX Connectors               โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚   Binance     โ”‚ โ”‚  โ”‚   Uniswap V3 (Web3.py)            โ”‚ โ”‚
โ”‚  โ”‚   Bybit       โ”‚ โ”‚  โ”‚   โ”œโ”€ Ethereum mainnet              โ”‚ โ”‚
โ”‚  โ”‚   OKX         โ”‚ โ”‚  โ”‚   โ”œโ”€ Arbitrum                      โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚  โ”‚   โ””โ”€ Polygon                       โ”‚ โ”‚
โ”‚          โ”‚         โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚          โ–ผ         โ”‚                                         โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚           Smart Contracts               โ”‚
โ”‚  โ”‚  Rate Limiter โ”‚ โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚ Token Bucket  โ”‚ โ”‚  โ”‚   Quoter V2    (price quotes)      โ”‚ โ”‚
โ”‚  โ”‚ per-exchange  โ”‚ โ”‚  โ”‚   SwapRouter02 (execute swaps)     โ”‚ โ”‚
โ”‚  โ”‚ per-endpoint  โ”‚ โ”‚  โ”‚   ERC-20       (approve/balance)   โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚              Config  โ”‚  Logging  โ”‚  294 Tests                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Key Features

  • 3 CEX connectors โ€” Binance, Bybit, OKX via ccxt (async)
  • Uniswap V3 DEX connector โ€” Direct smart contract interaction via Web3.py (Quoter V2, SwapRouter02)
  • Multi-chain โ€” Ethereum mainnet, Arbitrum, Polygon
  • Token bucket rate limiter โ€” Per-exchange, per-endpoint (order/market_data/account), with 10-20% headroom below real limits
  • Async-first โ€” aiogram for Telegram, asyncio.to_thread() for sync ccxt calls
  • 294 tests, 0 failures

Rate Limiter โ€” Exchange Limits

| Exchange | Global | Orders | Market Data | Account | |----------|:------:|:------:|:-----------:|:-------:| | Binance | 1000/min | 400/min | 800/min | 400/min | | Bybit | 5000/min | 500/min | 2000/min | 600/min | | OKX | 2000/min | 500/min | 1200/min | 500/min |


๐Ÿ”— Blockchain & Smart Contracts (Roadmap)

Currently learning Solidity and smart contract development. Planned projects:

| Phase | Project | Stack | Status | |:-----:|---------|-------|:------:| | 1 | Solidity fundamentals + first contract deployment | Solidity, Remix, Hardhat | ๐Ÿ“‹ Planned | | 2 | DEX mechanics โ€” study Uniswap V2/V3 source code | Solidity, Foundry | ๐Ÿ“‹ Planned | | 3 | Flashloan arbitrage bot | Solidity, Aave V3, Foundry | ๐Ÿ“‹ Planned | | 4 | MEV extraction (backrunning, sandwich detection) | Solidity, Flashbots | ๐Ÿ“‹ Planned | | 5 | Smart contract security auditing | Slither, Mythril, CTFs | ๐Ÿ“‹ Planned |

Learning resources in progress: CryptoZombies, Ethernaut, Damn Vulnerable DeFi


๐Ÿข AlgoSphere Quant โ€” Commercial Products

Source code is private โ€” links point to the MQL5 Marketplace.

๐Ÿ† Flagship Products

| Product | Description | Version | |---------|-------------|:-------:| | Trade Manager PRO | Position management โ€” automated BE, trailing, partial closes, TP ladders, session filter, journal export | v7.10 | | SafeScalperPro | Automated scalping EA with risk management and prop firm compliance | v3.0 |

Product Suite (14 products)

๐Ÿ“ˆ 9 Indicators + ๐Ÿ›ก๏ธ 5 Utilities (click to expand)

Indicators: SmartMoney Concepts, Liquidity Heatmap, Volume Profile, Divergence Scanner, Order Flow, Correlation Matrix, Session Control, Account Analytics, Risk Manager

Utilities: PropGuard (prop firm compliance), Risk Manager (drawdown protection), Trade Journal, Position Sizer, News Filter

All products feature the unified ASQ Dark Theme built on shared includes (ASQTheme.mqh, ASQCommon.mqh).


๐Ÿ—๏ธ Architecture Philosophy

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    EA / Bot / DApp                    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚  โ”‚  Signal   โ”‚  โ”‚  Filter  โ”‚  โ”‚  Risk Management  โ”‚ โ”‚
โ”‚  โ”‚  Module   โ”‚  โ”‚  Module  โ”‚  โ”‚     Module        โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”˜  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜            โ”‚
โ”‚                      โ–ผ                               โ”‚
โ”‚            โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                      โ”‚
โ”‚            โ”‚ Trade Management โ”‚                      โ”‚
โ”‚            โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                      โ”‚
โ”‚                     โ–ผ                                โ”‚
โ”‚         โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                       โ”‚
โ”‚         โ”‚   Execution Layer  โ”‚                       โ”‚
โ”‚         โ”‚  (Deterministic)   โ”‚                       โ”‚
โ”‚         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚  TradFi: MQL5/C#  โ”‚  DeFi: Web3.py/Solidity        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Shared principles across TradFi & DeFi:

  • Deterministic execution โ€” Timer/block-driven, no race conditions
  • Monotonic state machines โ€” States progress forward, never backward
  • Rate limiting โ€” Token bucket per exchange/endpoint
  • Modular composition โ€” Reusable signal, filter, risk modules

๐Ÿš€ Quick Start

git clone https://github.com/e49nana/Algorithmic-trading.git
cd Algorithmic-trading

โ”€โ”€ TradFi โ”€โ”€

MQL5: Copy to MetaTrader data folder (Indicators/, Experts/, Include/, Scripts/)

NinjaTrader: Tools โ†’ Import โ†’ NinjaScript Add-On

โ”€โ”€ DeFi โ”€โ”€

cd defi/crypto-trade-bot pip install -r requirements.txt

Configure your API keys in config/

python -m pytest tests/ -q # 294 tests

๐Ÿ› ๏ธ Tech Stack

| Domain | Languages | Frameworks & Tools | |--------|-----------|-------------------| | TradFi | MQL5, C# | MetaTrader 5, NinjaTrader | | DeFi | Python, Solidity (learning) | Web3.py, ccxt, aiogram, Hardhat | | Blockchain | โ€” | Ethereum, Arbitrum, Polygon, Solana | | Testing | Python | pytest (294 tests) | | Smart Contracts | โ€” | Uniswap V3 (Quoter, Router, Pool) |


๐Ÿ“ˆ Roadmap

TradFi:

  • [x] 10 open-source MQL5 Code Base publications
  • [x] NinjaTrader indicator suite for futures
  • [x] AlgoSphere Quant product suite (14 products)
  • [x] TradeManager v7.10 with deterministic engine
  • [ ] Modular EA Framework (CTradeManager, CPositionSizer, CRiskManager)
DeFi:
  • [x] Multi-CEX async connector (Binance, Bybit, OKX)
  • [x] Uniswap V3 DEX connector (Web3.py)
  • [x] Token bucket rate limiter (294 tests)
  • [ ] Solidity fundamentals + first testnet deployment
  • [ ] Flashloan arbitrage contract (Aave V3)
  • [ ] MEV extraction bot (Flashbots)
  • [ ] Smart contract security auditing

โš ๏ธ Disclaimer

Trading involves significant risk of loss. The code in this repository is provided for educational and research purposes only. Past performance does not guarantee future results. Always test on demo/testnet before live trading.


๐Ÿ‘ค Author

Emmanuel Nana Nana Founder, AlgoSphere Quant B.Sc. Applied Mathematics & Physics โ€” TH Nรผrnberg

GitHub MQL5


๐Ÿ“„ License

Open-source code: MIT License. AlgoSphere Quant products: proprietary โ€” see algosphere-quant.com.


๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท e49nana/Algorithmic-trading ยท Updated daily from GitHub