**Documentation Structure:** - Created docs/ subdirectory organization (analysis/, architecture/, bugs/, cluster/, deployments/, roadmaps/, setup/, archived/) - Moved 68 root markdown files to appropriate categories - Root directory now clean (only README.md remains) - Total: 83 markdown files now organized by purpose **New Content:** - Added comprehensive Environment Variable Reference to copilot-instructions.md - 100+ ENV variables documented with types, defaults, purpose, notes - Organized by category: Required (Drift/RPC/Pyth), Trading Config (quality/ leverage/sizing), ATR System, Runner System, Risk Limits, Notifications, etc. - Includes usage examples (correct vs wrong patterns) **File Distribution:** - docs/analysis/ - Performance analyses, blocked signals, profit projections - docs/architecture/ - Adaptive leverage, ATR trailing, indicator tracking - docs/bugs/ - CRITICAL_*.md, FIXES_*.md bug reports (7 files) - docs/cluster/ - EPYC setup, distributed computing docs (3 files) - docs/deployments/ - *_COMPLETE.md, DEPLOYMENT_*.md status (12 files) - docs/roadmaps/ - All *ROADMAP*.md strategic planning files (7 files) - docs/setup/ - TradingView guides, signal quality, n8n setup (8 files) - docs/archived/2025_pre_nov/ - Obsolete verification checklist (1 file) **Key Improvements:** - ENV variable reference: Single source of truth for all configuration - Common Pitfalls #68-71: Already complete, verified during audit - Better findability: Category-based navigation vs 68 files in root - Preserves history: All files git mv (rename), not copy/delete - Zero broken functionality: Only documentation moved, no code changes **Verification:** - 83 markdown files now in docs/ subdirectories - Root directory cleaned: 68 files → 0 files (except README.md) - Git history preserved for all moved files - Container running: trading-bot-v4 (no restart needed) **Next Steps:** - Create README.md files in each docs subdirectory - Add navigation index - Update main README.md with new structure - Consolidate duplicate deployment docs - Archive truly obsolete files (old SQL backups) See: docs/analysis/CLEANUP_PLAN.md for complete reorganization strategy
5.8 KiB
5.8 KiB
MA Crossover Detection Implementation - Nov 27, 2025
✅ COMPLETED
Objective: Configure n8n workflow to capture death cross and golden cross events from TradingView alerts for MA crossover pattern validation.
What Was Implemented
1. n8n Workflow Update
- File:
workflows/trading/parse_signal_enhanced.json - Changes: Added MA crossover detection logic to JavaScript Code node
New Detection Logic:
// Detect MA crossover events (death cross / golden cross)
const isMACrossover = body.match(/crossing/i) !== null;
// Determine crossover type based on direction
const isDeathCross = isMACrossover && direction === 'short';
const isGoldenCross = isMACrossover && direction === 'long';
New Return Fields:
return {
// ... existing fields ...
// MA Crossover detection (NEW: Nov 27, 2025)
isMACrossover, // true if "crossing" detected in alert message
isDeathCross, // true if MA50 crossing below MA200 (bearish)
isGoldenCross, // true if MA50 crossing above MA200 (bullish)
// ... existing fields ...
}
2. TradingView Alert Configuration (User-completed)
- Symbol: SOLUSDT.P
- Condition: MA50&200 Crossing MA50/MA200
- Interval: Same as chart (5 minutes)
- Trigger: Once per bar close
- Message Format: Will contain "crossing" keyword that n8n will detect
3. Documentation Updates
- File:
INDICATOR_V9_MA_GAP_ROADMAP.md - Section: Validation Strategy
- Added: n8n workflow update status and crossover detection capabilities
How It Works
Alert Flow:
- TradingView detects MA50/MA200 crossover on 5-minute chart
- Alert fires once per bar close with message containing "crossing"
- n8n webhook receives alert, passes to Parse Signal Enhanced node
- Workflow extracts:
isMACrossover = true(detected "crossing" keyword)isDeathCross = true(if direction is short/sell)isGoldenCross = true(if direction is long/buy)- All standard metrics: ATR, ADX, RSI, VOL, POS, MAGAP, signalPrice
- Bot receives complete signal with crossover flags for data logging
Expected Behavior
When Death Cross Alert Fires:
{
"symbol": "SOL-PERP",
"direction": "short",
"isMACrossover": true,
"isDeathCross": true,
"isGoldenCross": false,
"adx": 29.5,
"atr": 0.65,
"signalPrice": 138.42,
"maGap": -0.15,
"indicatorVersion": "v9"
}
When Golden Cross Alert Fires:
{
"symbol": "SOL-PERP",
"direction": "long",
"isMACrossover": true,
"isDeathCross": false,
"isGoldenCross": true,
"adx": 24.8,
"atr": 0.58,
"signalPrice": 145.20,
"maGap": 0.12,
"indicatorVersion": "v9"
}
Data Collection Purpose
Goal: Validate the pattern discovered on Nov 27, 2025
Pattern Hypothesis:
- v9 signals fire 35 minutes BEFORE actual MA crossover
- ADX is weak when signal first fires (e.g., 22.5)
- ADX strengthens DURING the crossover (e.g., 22.5 → 29.5)
- By the time MA50/MA200 actually cross, ADX is strong (e.g., 29.5)
Validation Plan:
- Collect 5-10 MA crossover events (death + golden crosses)
- For each event, compare:
- Time of v9 signal vs time of actual MA cross
- ADX at v9 signal time vs ADX at MA cross time
- Whether pattern consistently shows weak → strong ADX progression
- If pattern is consistent:
- Consider adjusting quality scoring to favor signals near MA convergence
- Potentially create special handling for "pre-crossover" signals
- Validate Smart Entry Timer's ability to catch ADX strengthening
Next Steps (User Action Required)
1. Import Workflow to n8n
- Open n8n UI
- Navigate to Parse Signal Enhanced workflow
- Import updated
parse_signal_enhanced.json - Verify workflow shows crossover detection code
2. Test with Next Crossover
- Wait for TradingView alert to fire on next MA50/MA200 cross
- Check n8n workflow execution logs for crossover flags
- Verify bot receives
isMACrossover,isDeathCross, orisGoldenCrossfields
3. Monitor Bot Logs
- Watch for incoming signals with crossover flags
- Confirm bot logs these separately (or saves to BlockedSignal table)
- Collect ADX values at crossover times
4. Data Analysis (After 5-10 Examples)
- Compare v9 signal timing vs actual MA cross timing
- Analyze ADX progression pattern consistency
- Determine if quality scoring adjustments needed
Git Commit
Commit: 633d204
Message: "feat: Add MA crossover detection to n8n workflow"
Changes:
- Updated
workflows/trading/parse_signal_enhanced.jsonwith crossover detection - Documented in
INDICATOR_V9_MA_GAP_ROADMAP.mdvalidation strategy - Created backup:
parse_signal_enhanced.json.backup
Pushed to: origin/master
Technical Notes
Detection Method:
- Keyword matching: Searches for "crossing" (case-insensitive) in alert body
- Direction-based: Uses existing direction parsing (short/long) to determine crossover type
- Backward compatible: Existing signals without "crossing" keyword will have all flags set to
false
File Locations:
- Workflow:
/home/icke/traderv4/workflows/trading/parse_signal_enhanced.json - Backup:
/home/icke/traderv4/workflows/trading/parse_signal_enhanced.json.backup - Documentation:
/home/icke/traderv4/INDICATOR_V9_MA_GAP_ROADMAP.md
Integration Points:
- n8n workflow →
/api/trading/executeendpoint - Bot receives crossover flags in signal body
- Can be used for logging, filtering, or special handling
Status: ✅ READY FOR TESTING
The system now knows what to do with MA crossover alerts from TradingView. When the next death cross or golden cross occurs, the workflow will automatically detect it and flag it appropriately for data collection and analysis.