feat: SL/TP risk formulas, project docs, symbol specs
SKILL.md Section 5 rewritten with PointValue-based formulas:
- Direction A: SL points → SL price
- Direction B: Risk% + lots → SL price (with currency conversion)
- Direction C: SL price + risk% → lot size
- FindFXRate helper for profit_currency ≠ account_currency
- OrderCalcProfit verification pattern
Section 8 expanded with 6 SL/TP pitfalls (PointValue vs TICK_VALUE,
TickSize ≠ Point, currency conversion, NormalizeDouble rounding,
lot step quantization, STOPS_LEVEL check).
Section 9 EA skeleton now includes inline PointValue, FindFXRate,
CalcSLFromRisk, CalcLotsFromSL functions.
New files:
- LICENSE (MIT)
- README.md
- docs-dev/symbol-spec.md (symbol spec workflow)
- skills/mql5/references/symbol-spec/specs-{XAUUSD,USDJPY}.csv
- skills/mql5/scripts/verify_sl_tp_formulas.py (Python verification)
Updated: pyproject.toml, AGENTS.md, .gitignore, docs-dev/skill-design.md
This commit is contained in:
+57
-70
@@ -9,106 +9,93 @@ conforming to the [AgentSkills.io Specification](https://agentskills.io/specific
|
||||
---
|
||||
name: mql5
|
||||
description: >
|
||||
MQL5 development skill for MetaTrader 5. Covers Expert Advisors, Indicators,
|
||||
Scripts, and Services. Focus on positions, orders, indicators, ticks, and bars.
|
||||
Includes programming book and API reference documentation.
|
||||
MQL5 development skill for MetaTrader 5 Expert Advisors, Indicators, Scripts,
|
||||
and Services. Focus on positions, orders, indicators, ticks, bars, risk
|
||||
management, backtesting, and multi-instance MT5 operations. Includes
|
||||
programming book and API reference documentation.
|
||||
version: "0.1"
|
||||
license: MIT
|
||||
compatibility: >
|
||||
Target: MetaTrader 5 platform. Language: MQL5 (C++-like syntax).
|
||||
File extensions: *.mq5 (source), *.mqh (headers).
|
||||
References: mql5.com/en/book (programming), mql5.com/en/docs (API).
|
||||
Run time: Windows native, Linux via Wine, macOS via Wine.
|
||||
metadata:
|
||||
project-version: "0.1.0"
|
||||
sources:
|
||||
book: sitemaps/sitemap_book_en.xml (581 URLs)
|
||||
docs: sitemaps/sitemap_docs_en.xml (4135 URLs)
|
||||
focus-areas:
|
||||
- positions
|
||||
- orders
|
||||
- indicators
|
||||
- ticks
|
||||
- bars
|
||||
- risk-management
|
||||
- backtesting
|
||||
---
|
||||
```
|
||||
|
||||
## Body Content Structure
|
||||
|
||||
The body should be structured as follows:
|
||||
### 1. MQL5 Fundamentals
|
||||
- Language and file types (.mq5, .mqh, .ex5)
|
||||
- Program types: EA, Indicator, Script, Service
|
||||
- MQL5 directory structure (Windows, Linux/Wine)
|
||||
- Multi-instance MT5 operations
|
||||
|
||||
### 1. Overview
|
||||
### 2. Trading Operations
|
||||
- Core concepts: Order, Deal, Position
|
||||
- CTrade class usage patterns
|
||||
- Position queries (Hedging vs Netting)
|
||||
- Order execution pattern with error handling
|
||||
|
||||
Brief description of MQL5 and MetaTrader 5:
|
||||
- MQL5 is the programming language for MetaTrader 5
|
||||
- Syntax similar to C++
|
||||
- File types: `.mq5` (source), `.mqh` (headers)
|
||||
- Program types: Expert Advisors, Indicators, Scripts, Services
|
||||
### 3. Indicators and Multi-Timeframe
|
||||
- Built-in indicator handles (iMA, iRSI, iMACD, iBands)
|
||||
- Reading indicator values via CopyBuffer
|
||||
- Multi-timeframe analysis pattern
|
||||
- New bar detection
|
||||
|
||||
### 2. Quick Reference — Key Operations
|
||||
### 4. Ticks and Bars
|
||||
- Timeseries access (MqlRates, ArraySetAsSeries)
|
||||
- Tick data (MqlTick, SymbolInfoTick)
|
||||
- Key functions table
|
||||
|
||||
Focus areas with concise API patterns:
|
||||
### 5. Risk Management and Lot Sizing
|
||||
- **PointValue concept**: profit-currency per 1-point move for 1 lot
|
||||
- Forex/CFD: `point × ContractSize`
|
||||
- Futures: `point × TickValue / TickSize`
|
||||
- **Direction A**: SL distance points → SL price
|
||||
- **Direction B**: Risk% + fixed lots → SL price (with currency conversion)
|
||||
- **Direction C**: SL price + risk% → lot size
|
||||
- **Profit verification**: OrderCalcProfit + manual formula
|
||||
- Risk-to-Reward ratio
|
||||
- Position sizing rules (7 rules)
|
||||
|
||||
#### Positions
|
||||
- `CTrade` class for position management
|
||||
- `PositionGetSymbol()`, `PositionSelect()`, `PositionGetDouble()`
|
||||
- `CTrade::PositionOpen()`, `CTrade::PositionClose()`
|
||||
### 6. Backtesting and Optimization
|
||||
- Strategy Tester concepts
|
||||
- OnTester custom optimization criterion
|
||||
- Key statistics table
|
||||
- Backtesting workflow
|
||||
|
||||
#### Orders
|
||||
- `CTrade::OrderSend()` for pending orders
|
||||
- `ORDER_TYPE_BUY_LIMIT`, `ORDER_TYPE_SELL_LIMIT`, etc.
|
||||
- `OrderGetTicket()`, `OrderSelect()`
|
||||
### 7. Event Handlers Reference
|
||||
- Handler table (OnInit through OnTesterPass)
|
||||
|
||||
#### Indicators
|
||||
- `iMA()`, `iRSI()`, `iMACD()`, `iBands()` — built-in indicators
|
||||
- `CopyBuffer()` to read indicator values
|
||||
- `IndicatorCreate()` for custom indicators
|
||||
### 8. Common Pitfalls
|
||||
- **General** (10 items): ResultRetcode, MagicNumber, NormalizeDouble, etc.
|
||||
- **SL/TP and Risk Calculation** (6 items): PointValue vs TICK_VALUE,
|
||||
TickSize vs Point, currency conversion, NormalizeDouble rounding,
|
||||
lot step quantization, STOPS_LEVEL check
|
||||
|
||||
#### Ticks
|
||||
- `SymbolInfoTick()` — current tick data
|
||||
- `MqlTick` structure: `bid`, `ask`, `last`, `volume`, `time`
|
||||
- `OnTick()` handler for Expert Advisors
|
||||
### 9. Quick Reference — EA Skeleton
|
||||
- Complete EA template with inline risk functions:
|
||||
- `PointValue()`, `FindFXRate()`, `CalcSLFromRisk()`, `CalcLotsFromSL()`
|
||||
- OnTick example with SL calculation and loss verification
|
||||
|
||||
#### Bars
|
||||
- `Bars()`, `BarsCalculated()` — bar count
|
||||
- `CopyOpen()`, `CopyHigh()`, `CopyLow()`, `CopyClose()`, `CopyVolume()`
|
||||
- `CopyRates()`, `CopyTime()`
|
||||
- `CTerminalInfo`, `CSymbolInfo` for symbol/bar info
|
||||
|
||||
### 3. Program Types
|
||||
|
||||
| Type | Purpose | Key Handler |
|
||||
|------|---------|-------------|
|
||||
| Expert Advisor | Automated trading | `OnTick()`, `OnInit()`, `OnDeinit()` |
|
||||
| Indicator | Technical analysis | `OnCalculate()` |
|
||||
| Script | One-shot execution | `OnStart()` |
|
||||
| Service | Background task | `OnStart()`, `OnTimer()` |
|
||||
|
||||
### 4. Common Patterns
|
||||
|
||||
- Trade execution with error handling
|
||||
- Indicator buffer management
|
||||
- Timer-based operations
|
||||
- Chart object manipulation
|
||||
- File I/O for logging/data
|
||||
|
||||
### 5. References
|
||||
|
||||
Point to the extracted documentation:
|
||||
- `references/book/` — Programming book (learning path)
|
||||
- `references/docs/` — API reference (function/type lookup)
|
||||
|
||||
### 6. Pitfalls & Best Practices
|
||||
|
||||
- `RefreshRates()` before trading operations
|
||||
- `NormalizeDouble()` for price comparisons
|
||||
- Check `Retcode()` after trade operations
|
||||
- Use `CTrade` class over raw `OrderSend()`
|
||||
- Handle `OnTimer()` for periodic operations
|
||||
- Test with Strategy Tester before live deployment
|
||||
### 10. References
|
||||
- In-skill references (book/, docs/, symbol-spec/, scripts/)
|
||||
- External links (MQL5 Reference, MQL5 Book, Strategy Tester Guide)
|
||||
|
||||
## Implementation Notes
|
||||
|
||||
- The SKILL.md should be concise (< 1024 chars for description, body can be longer)
|
||||
- Body is loaded as context by AI agents — prioritize actionable patterns
|
||||
- Reference files provide depth; SKILL.md provides the "what to do"
|
||||
- Risk formulas verified against real symbol specs (XAUUSD, USDJPY)
|
||||
via `scripts/verify_sl_tp_formulas.py`
|
||||
- Version 0.1: initial content, will expand as extraction completes
|
||||
|
||||
Reference in New Issue
Block a user