MQL4/.github/instructions/mql5-indicators.instructions.md
Rahul Dhangar 669ecde7b7 Initial commit: Documentation and MT4 EA Phases 1-3 complete
- Added comprehensive MQ4/MQ5 comparison documentation (60+ pages)
- Added MT4 EA implementation plan and tracking documents (60+ pages)
- Phase 1: Core infrastructure with input parameters and data structures
- Phase 2: Bar detection system for H4, M30, M15 timeframes
- Phase 3: Pattern detection logic (Regular/Irregular Buy/Sell patterns)
- Reference files: FINAL_H4_ZONES.mq4, MultiTimeframeZoneEA.mq5, Strategy.md
2025-11-04 01:38:41 +05:30

26 lines
No EOL
1.8 KiB
Markdown

---
applyTo: "**/MQL5/Indicators/_Thivyam/**/*.mq5"
---
# Instructions for _Thivyam MQL5 Custom Indicators
## CRITICAL: MQL5 Syntax Compliance
**Before writing any MQL5 code, read and follow:** `mql5-syntax-critical.instructions.md`
Key mandatory rules:
- Use dot operator (`.`) for pointer member access, NOT arrow (`->`)
- Declare loop variables BEFORE for-loop: `int i; for(i=0; i<n; i++)`
- Use dynamic arrays (`Type[]`) for `ArraySetAsSeries()` and `CopyRates()`
- Verify property constant names in official MQL5 documentation
## Indicator-Specific Instructions
- **Properties:** Clearly define indicator properties at the top of the file (e.g., `#property indicator_chart_window`, `#property indicator_buffers`, `#property indicator_plots`).
- **Buffers:** All indicator buffers must be initialized in `OnInit()` using `SetIndexBuffer()`.
- **Calculation (`OnCalculate()`):**
- The `OnCalculate()` function is the core of the indicator and must be coded for maximum performance.
- **CRITICAL:** You **MUST** correctly handle the `prev_calculated` parameter to avoid recalculating the entire price history on every new tick. The calculation loop should start from `rates_total - prev_calculated`.
- Handle the potential for `EMPTY_VALUE` in indicator buffers when performing calculations.
- Validate all buffers for `ArraySetAsSeries()` consistency and log descriptive errors when buffer allocation fails.
- **Visualization:** Use `PlotIndexSetInteger()` and related helpers to keep plot naming and styling consistent with _Thivyam standards.
- **Performance Testing:** Profile heavy indicators using the MT5 Strategy Tester in visual mode and document any maximum history requirements.
- **Agent Workflow:** Add concise comments that describe non-obvious buffer shifts or smoothing logic so automated agents can refactor safely.