forked from MasoodIqbal/RSI-Stoch-MA-EA
My first EA with RSI + Stoch + MA
| .forgejo/workflows | ||
| Ailabels.mqh | ||
| Aisignalconfirmation.mqh | ||
| Candlepatterns.mqh | ||
| Chartlabels.mqh | ||
| Chartstructure.mqh | ||
| config.mqh | ||
| Fiblevels.mqh | ||
| Globalvariables.mqh | ||
| Indicators.mqh | ||
| Inputparams.mqh | ||
| Marketstate.mqh | ||
| Masteraicoordinator.mqh | ||
| NeuralNet.mqh | ||
| NNDataLogger.mqh | ||
| NNFeatures.mqh | ||
| Openai.mqh | ||
| Patterncoordinator.mqh | ||
| Patternsystemcomplete.mqh | ||
| Positionmanagement.mqh | ||
| Praise.mqh | ||
| profitmaxxingt.mq5 | ||
| profitmaxxingt1.mq5 | ||
| profitmaxxingt2.mq5 | ||
| profitmaxxingt3.1.mq5 | ||
| profitmaxxingt3.mq5 | ||
| python_server.py | ||
| README.md | ||
| Reentry.mqh | ||
| rt.txt | ||
| Signalcoordinator.mqh | ||
| Tradeexecution.mqh | ||
| Tradingsetups.mqh | ||
| Utilities.mqh | ||
| Warnings.mqh | ||
QuarterTheory Trading Bot - Modular Refactoring
📦 Project Overview
This project refactors the monolithic QuarterTheory_VIZION_FINAL_v5.8.mq5 (1,175 lines) into a clean, modular architecture with 15 separate files for better maintainability, readability, and extensibility.
✅ Completed Files (9/15)
Core Infrastructure
- Config.mqh - Base configuration, enums, and structures
- InputParams.mqh - All input parameters organized by groups
- GlobalVariables.mqh - Global state variables and arrays
- Utilities.mqh - Helper functions (price checks, conversions, etc.)
Systems
- Indicators.mqh - Indicator initialization and updates
- FibLevels.mqh - Fibonacci level calculation and drawing
- Warnings.mqh - Comprehensive warning detection (MA, Fib, MFIB, Stoch)
- Praise.mqh - 8 trend strength signals for aggressive trading
- PositionManagement.mqh - Complete position lifecycle management
📋 Remaining Files (6/15)
To Be Created
- MarketState.mqh - Market mode detection (TRENDING/RANGING/CHOP)
- ReEntry.mqh - Smart re-entry system with 10 combo triggers
- TradeExecution.mqh - Trade opening with dynamic lot sizing
- ChartLabels.mqh - Visual feedback system
- TradingSetups.mqh - All 18 trading setups execution
- Main EA File - Orchestrates all modules
🏗️ Architecture
Config.mqh (base definitions)
↓
GlobalVariables.mqh
↓
InputParams.mqh
↓
Utilities.mqh
↓
├─ Indicators.mqh
├─ FibLevels.mqh
├─ Warnings.mqh
├─ Praise.mqh
├─ MarketState.mqh (to create)
├─ ReEntry.mqh (to create)
├─ PositionManagement.mqh
├─ TradeExecution.mqh (to create)
├─ ChartLabels.mqh (to create)
└─ TradingSetups.mqh (to create)
↓
Main EA File (to create)
🔑 Key Features
War Survivor System
- 2.5x lot multiplier for larger initial positions
- 25% MFIB partials at each rejection level
- Maximum 4 MFIB partials per trade
- Designed to survive frequent trailing stops
Praise System (8 Signals)
- Triple Magnet - MA7×14×21 tight hold
- Power Couple - MA14×21 close alignment
- MFIB Staircase - Sequential level advance
- MFIB Express - Skip MFIB levels
- MFIB Breakout - Level break + hold
- MA Stack - Perfect MA alignment
- Clean Reclaim - MFIB+MA+Fib together
- Multi-Breakout - Everything breaks at once
Warning System (17+ Signals)
- Stochastic extremes and crosses
- MA cross warnings (7×14, 7×21, 7×50)
- Fibonacci reject/reclaim/break
- MFIB reject/reclaim/break
- MA reject/reclaim/break
- Band snap detection
- Pullback/retracement confluence
Re-Entry System (10 Combos)
- 3+ Reject/Reclaim at strong MAs
- MA14 Magnet + Fib/MFIB break
- Strong MA bounce + Stoch confirm
- Trend resumption post-pullback
- Level reclaim + MA alignment
- Band snap recovery
- Triple level confluence
- Stoch extreme + level
- MA cross + level break
- 4+ warning confluence
📊 Trading Setups
Continuation (14 setups - 150 SL, 4000 TP)
- MA14 Cross
- MA50 Bounce
- MA140 Bounce
- MA230 Bounce
- MA500 Touch
- Fib Break
- Fib Reclaim
- Magnet Walk
- MFIB Ladder
- Staircase Advance
- Controlled Pullback
- Timeframe Reset
- MFIB Press
- [2 more in original]
Counter-Trend (4 setups - 50 SL, 3000 TP)
- Pullback Counter
- Retracement Counter
- Range Engine
- Mean Reversion
🎯 How to Use
Current State
The project includes 9 working .mqh files that can be included in your main EA. See EXAMPLE_MAIN_FILE_STRUCTURE.mq5 for implementation pattern.
To Complete
- Review
REFACTORING_GUIDE.txtfor full specifications - Create remaining 6 files by extracting code from original
- Test each module independently
- Integrate into main EA file
- Compile and backtest
💡 Benefits
Maintainability
- Single Responsibility - Each file has one clear purpose
- Easy Debugging - Find issues quickly in isolated modules
- Clear Structure - Logical organization of related code
Readability
- Self-Documenting - File names explain purpose
- Small Files - Each under 500 lines (most under 300)
- Focused Functions - Do one thing well
Testability
- Unit Testing - Test each module independently
- Mock Dependencies - Isolate components for testing
- Debug Isolation - Issues contained to specific files
Scalability
- Easy Extensions - Add setups in TradingSetups.mqh
- New Signals - Extend Warnings.mqh or Praise.mqh
- Feature Flags - Control systems via InputParams.mqh
Collaboration
- Parallel Development - Multiple devs work on different files
- Reduced Conflicts - Separate files minimize merge issues
- Clear Ownership - Each file can have an owner
📁 File Contents
Config.mqh (163 lines)
- MODE_FAMILY enum (4 types)
- TREND_BIAS enum (3 states)
- TREND_STRENGTH enum (3 levels)
- PRICE_STATE enum (14 states)
- SETUP_TYPE enum (18 setups)
- TRADE_CATEGORY enum (2 types)
- PositionRec structure (20 fields)
- ClosedPositionRec structure (7 fields)
InputParams.mqh (106 lines)
- Core settings (5 params)
- Market mode system (4 params)
- MA system (11 params)
- Stochastic (7 params)
- MFIB (2 params)
- Fibonacci (2 params)
- Continuation trades (6 params)
- Counter-trend trades (6 params)
- War Survivor (4 params)
- Praise system (6 params)
- Band snap (1 param)
- Re-entry (2 params)
GlobalVariables.mqh (118 lines)
- Indicator handles (13 handles)
- Indicator values (arrays)
- MA values (3 arrays × 10 MAs)
- Price levels (7 static fib levels)
- MFIB levels (5 levels + bias)
- Stoch key levels (5 levels)
- Market state (9 variables)
- Warning flags (23 flags)
- Re-entry flags (5 flags)
- Praise flags (9 flags)
- Position tracking (2 arrays)
- Statistics (7 counters)
Utilities.mqh (187 lines)
- MidPrice() - Calculate mid price
- NearLevel() - Check proximity to level
- StochCrossUp/Down() - Detect crosses
- IsBullBias/IsBearBias() - Check bias
- Bull_MA50_Reclaimed() - MA50 reclaim detection
- Bear_MA50_Reclaimed() - MA50 reclaim detection
- FamilyToText() - Convert enum to string
- BiasToText() - Convert enum to string
- StrengthToText() - Convert enum to string
- StateToText() - Convert enum to string
Indicators.mqh (71 lines)
- InitializeIndicators() - Create all handles
- ReleaseIndicators() - Clean up handles
- UpdateIndicators() - Update all values
FibLevels.mqh (136 lines)
- CalculateLevels() - Calculate Fib + MFIB
- DrawLevels() - Draw on chart
- CleanupLevels() - Remove from chart
Warnings.mqh (352 lines)
- DetectWarnings() - Comprehensive detection:
- Stochastic analysis
- MA cross analysis
- Band snap detection
- Fibonacci level analysis
- MFIB level analysis
- Strong MA analysis
- Pullback confluence
- Warning confluence count
- Re-entry combo flags
Praise.mqh (298 lines)
- DetectPraiseSignals() - 8 trend signals:
- Triple Magnet (MA7×14×21)
- Power Couple (MA14×21)
- MFIB Staircase
- MFIB Express
- MFIB Breakout Hold
- MA Stack Perfection
- Clean Reclaim Sequence
- Multi-Level Breakout
PositionManagement.mqh (179 lines)
- RecordClosure() - Track closed positions
- RecentlyStopped() - Check recent SL/BE hits
- MarkRunners() - Identify runner positions
- CloseOnFullReversal() - Reversal protection
- ManagePositions() - Complete lifecycle:
- Standard partial TPs
- MFIB partials (War Survivor)
- Breakeven management
- Trailing stops
- Closure tracking
🔧 Next Steps
Phase 1: Complete Core Files
- Create MarketState.mqh (extract from lines 601-735)
- Create ReEntry.mqh (extract from lines 343-486)
- Create TradeExecution.mqh (extract from lines 888-973)
Phase 2: UI & Setup Execution
- Create ChartLabels.mqh (extract from lines 736-887)
- Create TradingSetups.mqh (extract from OnTick lines 974-1167)
Phase 3: Final Integration
- Create Main EA File using EXAMPLE_MAIN_FILE_STRUCTURE.mq5 as template
- Test compilation
- Backtest each module
- Full system integration test
📝 Notes
- All created files follow MQL5 conventions
- Each file is independently testable
- Clear dependency hierarchy prevents circular includes
- War Survivor and Praise systems fully integrated
- Re-entry combos ready for implementation
- Original 18 setups preserved
📞 Support
For questions or issues:
- Review
REFACTORING_GUIDE.txtfor detailed specifications - Check
EXAMPLE_MAIN_FILE_STRUCTURE.mq5for usage patterns - Reference original file for complete logic
📄 License
Same as original QuarterTheory x VIZION project.
Version: 5.8 (Modular)
Status: 60% Complete (9/15 files)
Lines: ~1,600 lines across 9 files (vs 1,175 in original monolith)
Organization: ⭐⭐⭐⭐⭐