Files
mql-trading-bots/scripts/validate-settings.sh

129 lines
4.1 KiB
Bash
Executable File

#!/bin/bash
# MQL Trading Bot Settings Validator
# This script validates .set files for common issues
REPO_DIR="/home/garfield/mql-trading-bots"
cd "$REPO_DIR" || exit 1
ISSUES=0
echo "=== MQL Settings Validation Report ==="
echo "Date: $(date)"
echo ""
# Check 1: Count set files
echo "[INFO] Checking set files..."
CONFLUENCE_COUNT=$(ls -1 confluence-*.set 2>/dev/null | wc -l)
GRID_COUNT=$(ls -1 grid-*.set 2>/dev/null | wc -l)
echo " Confluence settings: $CONFLUENCE_COUNT files"
echo " Grid settings: $GRID_COUNT files"
if [ $CONFLUENCE_COUNT -eq 0 ] && [ $GRID_COUNT -eq 0 ]; then
echo "ISSUE: No .set files found!"
ISSUES=$((ISSUES + 1))
fi
# Check 2: Invalid variable names (typos)
echo ""
echo "[INFO] Checking for invalid variable names..."
INVALID=$(grep -l "InpMinConfluenceStrength\|MinConfluenceStrength\|ConfluenceStrength" confluence-*.set 2>/dev/null)
if [ -n "$INVALID" ]; then
echo "ISSUE: Invalid variable names found:"
echo "$INVALID" | while read -r file; do
echo " - $file"
done
ISSUES=$((ISSUES + 1))
else
echo " ✓ No invalid variable names found"
fi
# Check 3: Missing critical parameters in Confluence sets
echo ""
echo "[INFO] Checking Confluence settings completeness..."
for file in confluence-*.set; do
[ -f "$file" ] || continue
MISSING=""
grep -q "^InpMinConfluence=" "$file" || MISSING="$MISSING InpMinConfluence"
grep -q "^InpMinStrength=" "$file" || MISSING="$MISSING InpMinStrength"
grep -q "^InpRequireAllAgree=" "$file" || MISSING="$MISSING InpRequireAllAgree"
grep -q "^InpMagicNumber=" "$file" || MISSING="$MISSING InpMagicNumber"
grep -q "^InpMaxDailyDrawdown=" "$file" || MISSING="$MISSING InpMaxDailyDrawdown"
grep -q "^InpCloseBeforeWeekend=" "$file" || MISSING="$MISSING InpCloseBeforeWeekend"
if [ -n "$MISSING" ]; then
echo "ISSUE: $file missing:$MISSING"
ISSUES=$((ISSUES + 1))
fi
done
# Check 4: Missing critical parameters in Grid sets
echo ""
echo "[INFO] Checking Grid settings completeness..."
for file in grid-*.set; do
[ -f "$file" ] || continue
MISSING=""
grep -q "^InpMaxDailyDrawdown=" "$file" || MISSING="$MISSING InpMaxDailyDrawdown"
grep -q "^InpCloseBeforeWeekend=" "$file" || MISSING="$MISSING InpCloseBeforeWeekend"
if [ -n "$MISSING" ]; then
echo "ISSUE: $file missing:$MISSING"
ISSUES=$((ISSUES + 1))
fi
done
# Check 5: Very restrictive settings (may explain no trades)
echo ""
echo "[INFO] Checking for overly restrictive settings..."
HIGH_STRENGTH=$(grep "InpMinStrength=0.8" confluence-*.set 2>/dev/null | cut -d: -f1)
if [ -n "$HIGH_STRENGTH" ]; then
echo "WARNING: High strength thresholds (may block trades):"
echo "$HIGH_STRENGTH" | while read -r file; do
strength=$(grep "InpMinStrength=" "$file" | head -1)
echo " - $file: $strength"
done
fi
# Check 6: Debug mode status
echo ""
echo "[INFO] Debug mode status..."
DEBUG_OFF=$(grep "InpDebugMode=false" confluence-*.set grid-*.set 2>/dev/null | wc -l)
DEBUG_ON=$(grep "InpDebugMode=true" confluence-*.set grid-*.set 2>/dev/null | wc -l)
echo " Debug ON: $DEBUG_ON files"
echo " Debug OFF: $DEBUG_OFF files"
if [ $DEBUG_OFF -gt 5 ]; then
echo "WARNING: Many files have debug disabled - you won't see trade decisions"
fi
# Check 7: Weekend protection status
echo ""
echo "[INFO] Weekend protection status..."
WEEKEND_OFF=$(grep "InpCloseBeforeWeekend=false" confluence-*.set grid-*.set 2>/dev/null | wc -l)
if [ $WEEKEND_OFF -gt 0 ]; then
echo "WARNING: $WEEKEND_OFF files have weekend protection DISABLED"
ISSUES=$((ISSUES + 1))
else
echo " ✓ All files have weekend protection enabled"
fi
# Check 8: Git status
echo ""
echo "[INFO] Checking git status..."
UNTRACKED=$(git ls-files --others --exclude-standard *.set 2>/dev/null | wc -l)
if [ $UNTRACKED -gt 0 ]; then
echo "WARNING: $UNTRACKED untracked .set files:"
git ls-files --others --exclude-standard *.set 2>/dev/null | head -5
fi
# Summary
echo ""
echo "=== Summary ==="
if [ $ISSUES -eq 0 ]; then
echo "✅ All checks passed!"
else
echo "❌ Found $ISSUES issue(s)"
fi
exit $ISSUES