An automated trading bot for MetaTrader 5 built around Gann Box analysis and dynamic money management.
Gann Bot v3.0 is an automated trading robot designed based on Gann Boxes and dynamic capital management strategies.
It enters trades by analyzing dynamic support and resistance levels derived from the upper and lower boundaries of the Gann Box.
The bot is built to provide:
- Smarter position sizing
- Advanced risk control
- Flexible parameter customization
- Real-time chart information display
| Feature | Description |
|---|---|
| 📊 Dynamic Money Management | 4 different modes: Fixed Lot, Risk Percentage, Kelly Criterion, and Anti-Martingale |
| 🛡️ Advanced Risk Control | Daily loss limit, stop after consecutive losses, trailing stop |
| 📈 1:2 Risk-to-Reward Ratio | Default setup uses 300 pips stop loss and 600 pips take profit |
| 🔧 Fully Customizable | All parameters can be adjusted by the user |
| 🖥️ Real-Time Chart Info | Displays balance, trade status, and statistics directly on the chart |
| File | Path | Description |
|---|---|---|
GannBot_v3.ex5 |
MQL5/Experts/ |
Expert Advisor executable |
GannBox.ex5 |
MQL5/Indicators/ |
Required Gann Box custom indicator |
Important: The bot depends on the
GannBoxindicator.
Both files must be placed in the correct directories.
| Parameter | Default | Description |
|---|---|---|
MoneyManagement |
1 (Risk%) |
0 = Fixed Lot, 1 = Risk Percentage, 2 = Kelly Criterion, 3 = Anti-Martingale |
FixedLot |
0.1 |
Fixed trade volume when using MM_FIXED |
RiskPercent |
2.0 |
Risk percentage per trade when using MM_RISK_PERCENT |
| Parameter | Default | Description |
|---|---|---|
StopLoss |
300 |
Stop loss in pips |
TakeProfit |
600 |
Take profit in pips (1:2 risk-to-reward ratio) |
| Parameter | Default | Description |
|---|---|---|
MaxDailyLoss |
5.0 |
Maximum daily loss in percentage |
MaxConsecutiveLosses |
3 |
Maximum allowed consecutive losing trades before stopping |
UseTrailingStop |
true |
Enable or disable trailing stop |
TrailingStart |
200 |
Start trailing after this many pips in profit |
TrailingStep |
30 |
Trailing stop step in pips |
| Parameter | Default | Description |
|---|---|---|
GannTimeframe |
PERIOD_H4 |
Gann Box timeframe (H4, D1, W1) |
Slippage |
30 |
Maximum allowed slippage in pips |
# Copy indicator
GannBox.ex5 -> MQL5/Indicators/
# Copy expert advisor
GannBot_v3.ex5 -> MQL5/Experts/- Open MetaTrader 5
- Press F4 to open MetaEditor
- Open the files and click Compile (F7)
- In MetaTrader, go to View → Navigator or press Ctrl+N
- Open the Experts section
- Double-click GannBot_v3 or drag it onto a chart
- Adjust the settings as desired
- Click OK
Symbol: GBPUSD
Period: H4 (recommended)
Date: Any desired range
Optimization: falseTrades with a constant lot size defined by FixedLot.
Each trade risks up to RiskPercent percent of account equity.
Lot size is calculated based on the stop loss distance.
Formula:
Lot Size = (Account Balance × Risk %) / (Stop Loss Distance × Pip Value)Calculates the optimal position size based on historical performance, including win rate and reward/loss ratio.
Best suited for accounts with enough trading history.
- Increase lot size after a winning trade
- Decrease lot size after a losing trade
If daily loss reaches MaxDailyLoss, the bot will stop opening new trades until the next day.
After MaxConsecutiveLosses losing trades in a row, the bot stops trading automatically.
Once the trade reaches TrailingStart pips in profit, the stop loss moves forward automatically by TrailingStep pips to protect gains.
| Market | Timeframe | StopLoss | TakeProfit | RiskPercent |
|---|---|---|---|---|
| Forex (GBPUSD) | H4 |
300 |
600 |
2.0% |
| Forex (Scalping) | M15 |
50 |
100 |
1.0% |
| Gold (XAUUSD) | H1 |
800 |
1600 |
1.5% |
| Indices (US30) | H4 |
500 |
1000 |
1.5% |
| Issue | Solution |
|---|---|
cannot load custom indicator 'GannBox' |
Make sure GannBox.ex5 is copied into the MQL5/Indicators/ folder |
OnInit critical error |
Restart MetaTrader 5 and try again |
| No trades are opened | Make sure the chart timeframe matches GannTimeframe |
| Too many consecutive losses | Reduce RiskPercent (for example to 1.0%) |
This bot is provided for educational purposes and as a trading assistance tool only.
There is no guarantee of profitability.
Always test the bot on a demo account before using it on a live account.
Proper risk management is the most important part of trading.- GitHub: github.com/avangardistic
| Version | Year | Changes |
|---|---|---|
v3.0 |
2026 |
Dynamic money management, trailing stop, improved trade signals |
v2.0 |
2026 |
Added multiple money management methods |
v1.0 |
2026 |
Initial release with Gann Box trading logic |
If you use this project and find it helpful, consider giving it a star on GitHub.