Mamba2 is a Python-based algorithmic trading framework designed for backtesting and live trading with MetaTrader 5. The framework provides a clean, type-hinted API for developing, testing, and deploying trading strategies.
- Unified Broker Interface: Common interface for both live and mock trading
- MT5 Integration: Seamless integration with MetaTrader 5
- Mock Trading: Full-featured mock implementation for testing strategies without a live account
- Type Hints: Full Python type hint support for better IDE assistance and code quality
- Testing: Comprehensive test suite with unit and integration tests
- Install Python 3.8+
- Install the package in development mode:
git clone <repository-url> cd mamba2 uv pip install -e .
- For MT5 support, install the MetaTrader5 package:
uv pip install MetaTrader5
from mamba2.broker import MT5Broker, MT5Mock
# For live trading
broker = MT5Broker(login=YOUR_LOGIN, password="YOUR_PASSWORD", server="YOUR_SERVER")
# For testing/development
mock_broker = MT5Mock()
# Initialize connection
if broker.initialize():
try:
# Get account info
account = broker.account_info()
print(f"Account: {account['login']} Balance: {account['balance']}")
# Example: Get market data
if broker.symbol_select("EURUSD"):
bars = broker.copy_rates_from_pos("EURUSD", 1, 0, 10) # Last 10 M1 bars
print(f"Got {len(bars)} bars of EURUSD data")
finally:
broker.shutdown()mamba2/- Core packagebroker/- Broker interface and implementationsbase.py- Abstract base class for all brokersmt5_broker.py- MT5 live trading implementationmt5_mock.py- Mock implementation for testing
strategy/- Strategy interfaces and base classestrader/- Trading client and execution logic
tests/- Test suiteunit/- Unit testsintegration/- Integration tests
examples/- Example scripts and strategies
-
Core Infrastructure
- Package structure and module organization
- Test infrastructure with pytest
- CI/CD pipeline
-
Broker Implementation
-
Brokerabstract base class -
MT5Broker- Live trading with MetaTrader 5 -
MT5Mock- Mock implementation for testing - Comprehensive test coverage
- Example usage scripts
-
-
Documentation
- API documentation
- Usage examples
- Developer guide
-
Backtesting Engine
- Historical data processing
- Strategy performance metrics
- Optimization framework
-
Strategy Development
- Built-in technical indicators
- Risk management tools
- Performance analytics
-
Live Trading
- Paper trading mode
- Risk management system
- Performance monitoring
-
Advanced Features
- Machine learning integration
- Multi-timeframe analysis
- Web dashboard
Contributions are welcome! Please read our Contributing Guidelines for details on how to get started.
This project is licensed under the MIT License - see the LICENSE file for details.
Trend lines are simple straight lines that help you see the market’s direction. Use them to spot potential support (in an up-trend) or resistance (in a down-trend). Here are the essentials:
-
Minimum touches
• A reliable line needs at least three touches.
• Only two touches? Treat the line as tentative until there is a third test. -
Drawing an up-trend line
• Start at the lowest visible swing low (Point A).
• Connect it to the next higher swing low that price has not crossed (Point B).
• Extend the line to the right; it marks possible future support. -
Drawing a down-trend line
• Start at the highest visible swing high.
• Connect it to the next lower swing high that price has not crossed.
• Extend to the right; it marks possible future resistance. -
Typical price behaviour
• Respect: price bounces off the line and the trend continues.
• Break: price closes beyond the line, often followed by consolidation and a new trend. -
Best-practice tips
• Aim for a 30°–45° slope. Extremely steep lines break easily.
• Do not force the line through candles—let it fit naturally.
• Very rapid price moves can ignore any drawn line, so always watch live price action.
Follow these rules and trend lines will become a quick, reliable tool in your trading toolkit.