Trabalho concluído
Termos de Referência
I need help to make my EA work as well live as it does demo.
The EA is synced to 4m charts and that works well.
Code and setfiles will be supplied.
Thanks.
This is what Claude AI say is the issue? IDK
Looking at this codebase from a developer perspective, I can see several architectural and implementation issues that would cause demo vs live performance divergence:
Core Architecture Problems
1. Race Condition in State Management The EA maintains multiple global state variables ( consecutiveLosses , breakoutCount , usingAdaptiveSettings ) that are modified across different event handlers ( OnTick , OnTradeTransaction , CheckClosedTradesInHistory ). In live environments with higher tick frequency, these create race conditions where state changes can be lost or duplicated.
2. Inconsistent Event Processing You have duplicate trade monitoring logic in both OnTradeTransaction and CheckClosedTradesInHistory . This creates a scenario where the same trade result might be processed twice, causing incorrect state transitions. Demo environments are more predictable, masking this issue.
3. Handle Management Anti-Pattern The indicator handles are being recreated dynamically in ApplySettings() , but there's no proper synchronization to ensure the new handles have valid data before they're used. The sleep-and-retry pattern is a code smell that suggests timing dependencies.
Data Reliability Issues
4. Unsafe Buffer Operations Your buffer copying operations assume data availability without proper validation:
// Pattern seen throughout - assumes success CopyBuffer(handle, 0, 0, 2, values) == 2
Live feeds have more data gaps and timing inconsistencies than demo feeds.
5. Historical Data Dependencies The core logic relies heavily on historical price lookups ( iHighest , iLowest , iTime ) without checking data completeness. Live brokers often have different historical data depth and quality.
6. Timeframe Synchronization Assumptions The isNewBar() logic assumes consistent bar timing across timeframes, but live servers can have bar boundary variations that don't exist in demo environments.
Execution Model Flaws
7. Synchronous Execution Assumptions The trade execution model assumes immediate order processing and position updates. The retry logic in executeTrade() is primitive and doesn't handle partial fills or order state transitions properly.
8. Event Ordering Dependencies The adaptive switching logic depends on trade events being processed in a specific order. Live environments have more complex event sequences that can break these assumptions.
9. Price Data Staleness Multiple price lookups throughout the execution path ( SymbolInfoDouble calls) can return stale data in fast-moving live markets, leading to inconsistent calculations within the same tick.