Files
mql-trading-bots/N8N_WORKFLOW_SETUP.md
T
garfield 0894d18db4 WIP: 6+ weeks of uncommitted EA development and preset tuning
Confluence EA (v1.16 → v1.20):
- Per-EA realized P&L tracking via history deals
- Weekly drawdown protection
- Warmup bars, pivot cache, state persistence
- Point-scaled pivot thresholds, ranging ATR factor
- Market filling mode helper per symbol

Grid EA (v3.1 → v4.1):
- Adaptive filters, adaptive entry, spread filter
- Session filter, breakeven, correlation caps, range drift
- Profit protection (stop-after-profit, cycle reports)
- Edge cleanup v5.0 — close wrong-side positions outside grid
- Master one-shot shutdown, grid state persistence

Presets:
- Fix GetOut=Y shutdown bug on 4 grid presets
- Relax ADXMax 18→40, widen RSI 20/80 across grid presets
- Standardize daily drawdown 3%→5%, add weekly 10%
- Increase grid lots 0.01→0.03
- Normalize confluence ATR thresholds per pair
- Add XAGUSD, EURCHF, EURGBP, AUDNZD presets

Docs & DevOps:
- April 23 audit files (preset mismatch, code review, checklist)
- n8n workflow and validation infrastructure updates
- AI agent analyses in notes/

Known issues carried forward:
- Shared drawdown budget contamination (both EAs)
- Confluence ranging-market threshold inversion
- Older grid presets missing v4.1 safety controls
2026-05-12 09:02:25 -04:00

153 lines
3.7 KiB
Markdown
Executable File

# N8N Workflow for MQL Settings Monitoring
## Overview
This n8n workflow monitors your `.set` files every 6 hours and alerts you if there are issues like:
- Invalid variable names (typos)
- Missing critical parameters
- Overly restrictive settings blocking trades
- Weekend protection disabled
- Files not tracked in git
## Files Included
| File | Purpose |
|------|---------|
| `n8n-workflow-simple.json` | Simple workflow (recommended) |
| `n8n-workflow-check-sets.json` | Advanced workflow with Discord |
| `scripts/validate-settings.sh` | Validation script |
## Quick Setup (Simple Workflow)
### 1. Install N8N
```bash
# Using Docker
docker run -it --rm \
--name n8n \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
n8nio/n8n
```
### 2. Import Workflow
1. Open N8N: http://localhost:5678
2. Click **"Add Workflow"**
3. Click **"Import from File"**
4. Select `n8n-workflow-simple.json`
### 3. Configure Environment Variables
Add these to your n8n credentials or `.env`:
```bash
# Telegram Notifications (recommended)
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id
# Optional: Email Notifications
ALERT_EMAIL=garfield@fetcherpay.com
# Optional: Discord Notifications
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/...
```
### 4. Get Telegram Chat ID
1. Message @userinfobot on Telegram - it will give you your ID
2. Or use @getidsbot
### 5. Activate Workflow
1. Open the imported workflow
2. Click **"Active"** toggle (top right)
3. Click **"Save"**
## Validation Script
You can also run the validation manually:
```bash
# Run validation
./scripts/validate-settings.sh
# Run from anywhere
/home/garfield/mql-trading-bots/scripts/validate-settings.sh
```
## What It Checks
| Check | Description | Alert Level |
|-------|-------------|-------------|
| File count | Ensures .set files exist | Error |
| Invalid variables | Finds typos like `InpMinConfluenceStrength` | Error |
| Missing parameters | Checks critical params exist | Error |
| High strength | Warns if `InpMinStrength` > 0.8 | Warning |
| Debug mode | Warns if debug disabled | Warning |
| Weekend protection | Ensures `InpCloseBeforeWeekend=true` | Error |
| Git status | Warns about untracked files | Warning |
## Sample Telegram Alert
```
🚨 MQL Settings Issues Found:
ISSUE: confluence-eurusd.set missing: InpCloseBeforeWeekend
ISSUE: confluence-usdjpy.set missing: InpCloseBeforeWeekend
WARNING: High strength thresholds (may block trades):
- confluence-gbpusd.set: InpMinStrength=0.80
⏰ 2026-03-30 14:30
```
## Sample Success Message
```
✅ Settings check passed
Confluence settings: 13 files
Grid settings: 13 files
✓ No invalid variable names found
✓ All files have weekend protection enabled
```
## Scheduling Options
Edit the Schedule Trigger node to change frequency:
| Frequency | Settings |
|-----------|----------|
| Every 15 minutes | `interval: 15 minutes` |
| Every hour | `interval: 1 hour` |
| Every 6 hours | `interval: 6 hours` (default) |
| Daily at 9am | `cron: 0 9 * * *` |
## Troubleshooting
### No alerts received
- Check Telegram bot token is valid
- Verify chat ID is correct
- Check n8n execution log
### Script fails with permission denied
```bash
chmod +x /home/garfield/mql-trading-bots/scripts/validate-settings.sh
```
### Workflow shows error
- Ensure n8n can access `/home/garfield/mql-trading-bots`
- Check that script exists and is executable
## Advanced: Custom Checks
Edit `scripts/validate-settings.sh` to add your own checks:
```bash
# Example: Check for specific EA version
grep -q "EA_Version=1.16" *.set || echo "ISSUE: Files not updated to v1.16"
```
## Related Documentation
- [AGENTS.md](AGENTS.md) - Project context
- [SETTINGS_GUIDE.md](SETTINGS_GUIDE.md) - Settings documentation