MQL4/.github/instructions/mql5-scripts.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

24 lines
1.6 KiB
Markdown

---
applyTo: "**/MQL5/Scripts/_Thivyam/**/*.mq5"
---
# Instructions for _Thivyam MQL5 Scripts
## 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
## Script-Specific Instructions
- **Purpose:** Scripts must perform a single, well-defined task (e.g., order cleanup, data export) and exit cleanly after execution.
- **Entry Point:** Use `OnStart()` as the sole entry point. Do not rely on `OnTick()` or `OnChartEvent()` in scripts.
- **Input Parameters:** Expose configurable behaviour through clearly named `input` variables. Validate parameters up front and abort with descriptive logs when invalid.
- **Risk Controls:** When scripts place or close trades, reuse shared `_Thivyam` risk and execution helpers to honour firm-wide limits.
- **Error Handling:** Wrap calls to terminal APIs in conditionals, check results, and print `GetLastError()` codes for any failures.
- **Logging:** Emit concise status updates to the Experts log so automation can trace script progress.
- **Cleanup:** Release indicator handles, chart objects, or file handles before returning from `OnStart()`.
- **Agent Workflow:** Add short comments explaining non-obvious terminal interactions so future automated agents can maintain behaviour safely.