Техническое задание
Project Background
This project involves redesigning and improving an existing MetaTrader 5 custom indicator. This indicator analyzes price and volume delta (change) values, categorizes these changes into different classes, and displays the results on a panel. The current code is not functioning properly, particularly with delta calculations being problematic and showing inconsistent behavior across different timeframes and symbol types.
Current Status and Issues
The existing code that I will share with you contains the basic functionality but fails to perform as expected due to various issues. The code tracks price and volume changes to classify them into 9 different states, but:
-
Delta Calculation Problems:
- Price and volume delta values are not calculated correctly
- Patterns mostly show zero values
- The 9-state analysis does not produce meaningful distribution
-
Scaling Issues:
- Large volume values in monthly charts cause errors
- Inconsistent performance across different timeframes (minute, hourly, daily, weekly, monthly)
-
Flexibility Issues:
- Inconsistent performance with custom symbols and standard symbols
- Problems with historical data analysis (both bar-based and tick-based)
Project Requirements
1. Delta Calculation Engine
-
Accurate Delta Calculation:
- Correctly calculate price delta (closing price changes)
- Correctly calculate volume delta (volume changes)
- Calculate standard deviation values accurately for both
-
Scaling:
- Normalization techniques that work across all timeframes
- Mathematical approach to handle very large/small values
- Compatible operation across all symbol types (forex, stocks, crypto, indices, etc.)
2. Analysis Modes
-
Historical Analysis Mode:
- Calculate based on the last N bars (e.g., 250 bars)
- Analyze historical data with bar-based analysis
-
Real-Time Tick Analysis Mode:
- Analyze tick data within the last N minutes (e.g., 250 minutes)
- Collect and process ticks within the specified time window
-
Symbol Flexibility:
- Work with standard symbols
- Work with custom symbols
- Automatically detect necessary symbol properties
3. Visualization and Interface
-
Panel Appearance:
- Readable and clear panel design
- Display tables for both original and mean-based analysis
- Automatically adjust table size
-
User Controls:
- Change analysis mode (bar-based/tick-based)
- Adjust analysis depth (how many bars/minutes)
- Adjust standard deviation threshold coefficient
4. Performance Optimization
-
Memory Management:
- Efficient data storage
- Avoid unnecessary calculations
-
Processing Speed:
- Fast update cycle
- Low CPU usage
5. Error Management
- Robustness:
- Proper operation in unexpected situations
- Prevent errors like division by zero, null references
- Display appropriate messages when there is insufficient data
Technical Tips
Delta Calculation Improvements
- The original code calculates delta based on a single previous value, instead:
- For price delta: Last close - Previous close (or moving average)
- For volume delta: Last volume - Previous volume (or average)
- Use standard deviation or ATR methods for normalization
Working with Different Timeframes
- Normalize volume values in monthly charts:
- Logarithmic scaling
- Use percentage changes
Data Collection Strategies
-
Bar-Based:
- Use CopyClose() , CopyVolume() functions to get historical data
- Analyze the last N bar data
-
Tick-Based:
- Store ticks correctly in OnCalculate()
- Process all ticks within the specified period
- Time-based cleanup algorithm
Important MQL5 Functions
- CopyClose() , CopyOpen() , CopyHigh() , CopyLow() , CopyVolume() - For retrieving bar data
- SymbolInfoTick() - For retrieving tick data
- TimeCurrent() , TimeTradeServer() - For proper time management
- MathMean() , MathStandardDeviation() - For statistical calculations
- StringFormat() - For panel text formatting
- ObjectCreate() , ObjectSetString() - For creating panels and labels
Test Scenarios
Tests Across Different Symbol Types
-
Forex Pairs:
- EUR/USD M1 (minute) chart with tick-based test
- GBP/JPY H1 (hourly) chart with bar-based test
- USD/TRY D1 (daily) chart with bar-based test
- AUD/CAD MN (monthly) chart with bar-based test
-
Cryptocurrency Symbols:
- BTCUSD M5 (5-minute) chart with tick-based test
- ETHUSD H4 (4-hour) chart with bar-based test
- LTCUSD D1 (daily) chart with bar-based test
- XRPUSD W1 (weekly) chart with bar-based test
-
Custom Symbols:
- US30.cash (Dow Jones CFD) M15 chart with tick-based test
- DE30.cash (DAX CFD) H1 chart with bar-based test
- TR30.cash (BIST30 CFD) D1 chart with bar-based test
- Sentimentum.MT5 (Broker-specific sentiment index symbol) H4 chart with bar-based test
Special Test Conditions
-
Volatility-Based Tests:
- EUR/USD M1 during high volatility period (e.g., during major economic data announcements)
- EUR/USD M1 during low volatility period (e.g., Asian session)
- BTCUSD chart during serious crisis/crash periods
-
Volume Variance-Based Tests:
- High-volume stock (e.g., AAPL)
- Low-volume cryptocurrency (e.g., altcoin)
- Chart with weekend or post-holiday opening gaps
-
Multi-Timeframe Consistency Test:
- Tests of the same symbol at different timeframes (M1, M5, H1, D1)
- Comparison of results and consistency analysis
-
Data Deficiency Test:
- Test with newly listed/low-data symbols
- Test with symbols having historical data gaps
Existing Code
I will share the existing non-working code with you. This code demonstrates the logic of the 9-state analysis but contains the issues mentioned above. The development of the new indicator should maintain the logic of the existing code while addressing the identified problems.
This project brief provides a roadmap to solve the issues with the existing indicator and create a more powerful, more flexible analysis tool. While preserving the core purpose of the indicator, it aims to provide significant improvements in terms of calculation engine and flexibility.