Article-24281-AI-Powered-Tr.../README.md
121 라인
EOL 없음
7.2 KiB
Markdown
# Article-24281-AI-Powered-Trading-Systems-Structured-Approval-Cards
This repository is an article-derived reference project based on the original MQL5 article. It does not claim to reproduce the full original source code unless files are explicitly attached.
![Article preview](https://c.mql5.com/2/248/Screenshot_2026-08-23_220230_1200x628.jpg)
## Overview
This reference/reconstruction project is derived from an MQL5 article about improving the approval interface of an AI-assisted trading Expert Advisor.
Part 14 replaces prose-only confirmations with structured canvas cards containing a title, labeled action details, selectable owner groups, and approve/reject buttons. Users can resolve ambiguous bulk-close requests directly on the card before execution, without another model round-trip.
The project documents the design and integration points; the supplied input does not establish which source files are present in this repository.
## Original Article
- **Article ID:** 24281
- **Title:** Building AI-Powered Trading Systems in MQL5 (Part 14): A Structured Approval Card with Selectable Choices
- **Author:** Allan Munene Mutiiria
- **Publication date:** Not available
- **Category:** Integration
- **Article:** https://www.mql5.com/en/articles/24281
- **Author profile:** https://www.mql5.com/en/users/29210372
## Repository Purpose
This repository provides a reference for reconstructing or studying the article’s structured approval workflow.
Readers can learn how to:
- Separate action presentation from execution.
- Model detail rows and selectable choices as structured state.
- Measure and render content-dependent canvas widgets.
- Write user-selected scope into queued tool arguments.
- Resume a paused tool loop after approval or rejection.
The design extends an existing canvas interface and approval gate rather than introducing a standalone trading strategy.
## Key Concepts
- Integration between an AI tool loop and MetaTrader 5 actions.
- Human-in-the-loop trade approval.
- Structured card state using parallel arrays.
- Canvas layout, text measurement, and value truncation.
- Checkbox hit testing distinct from row-hover feedback.
- Position ownership classification using magic numbers.
- JSON argument updates and multi-group scope matching.
- Queued-action validation, logging, and conversation continuation.
## Algorithm / Architecture Summary
1. **Prepare the card.** Reset previous card state, identify the queued tool, and assign a title and consequence-specific footer.
2. **Build action details.** Parse tool arguments. Ordinary actions use labeled rows derived from the existing action description.
3. **Build sweep choices.** For bulk closes, count positions and floating profit/loss by ownership group: this EA, manually placed trades, and other robots. Apply the relevant symbol and result filters. Disable groups without matching positions.
4. **Render the widget.** Measure the content, clamp card width to the chat pane, shorten oversized detail values, and draw the title, rows, choices, buttons, and footer. Record interaction rectangles.
5. **Handle selections locally.** Checkbox clicks toggle selection and repaint without calling the model. Clicking the remainder of a choice row does not change its selection.
6. **Validate resolution.** Reject stale, foreign-chat, duplicate, invalid-index, and premature clicks. When choices are required, refuse approval until at least one enabled group is selected.
7. **Update and execute.** Join selected owner keys into a comma-separated `scope`, update the queued JSON arguments, and execute the approved action—or record rejection without execution.
8. **Continue processing.** Log and annotate the outcome, display the next pending card, or resume the tool loop. Executors match position owners against the selected scope list.
With auto-approval disabled—the article’s default—the described workflow holds actions until user approval.
## Mentioned or Attached Files
### Attachment availability
ARTICLE META confirms an attached ZIP archive is available. Its internal contents were not independently provided or inspected in the processed input.
The article’s attachment table identifies the following deliverables; these descriptions do not verify their presence in this repository.
| File | Article-described role |
|---|---|
| `AI Canvas Theme.mqh` | Layout constants, fonts, glyph codes, and interface palettes, including choice-state colors. |
| `AI Canvas Primitives.mqh` | Drawing primitives, fast canvas, caches, and vector graphics helpers. |
| `AI JSON FILE.mqh` | JSON parsing and serialization. |
| `AI Canvas State.mqh` | Shared state, structured card fields, choice arrays, and hit rectangles. |
| `AI Canvas Scrollbar.mqh` | Scrollbar state and scrolling helpers. |
| `AI Canvas Editor.mqh` | Multi-line text editing functionality. |
| `AI Canvas Render.mqh` | Dashboard rendering and approval-card measurement and drawing. |
| `AI Logic.mqh` | Request lifecycle, card construction, argument updates, and resolution. |
| `AI Canvas Interact.mqh` | Input routing, hit testing, and checkbox toggling. |
| `AI Canvas Shell.mqh` | Program lifecycle, canvas management, layout, and event integration. |
| `AI EA PART 14.mq5` | Main Expert Advisor entry point and user inputs. |
| `MQL5.zip` | Article-described project archive intended for extraction into the terminal data folder. |
### Files only mentioned in text
No additional source filenames are identified outside the attachment table.
## Statistics
| Metric | Value |
|---|---|
| Word count | Not available |
| Reading time | Not available |
| Image count | Not available |
| Code block count | Not available |
| Verified repository file count | Not available |
## Tags
`mql5` `metatrader-5` `integration` `difficulty-advanced`
## Difficulty
**Advanced** — Requires familiarity with MQL5 event handling, custom canvas rendering, shared interface state, JSON tool arguments, trading-position ownership, and paused AI tool loops.
## Limitations
- Full original source contents were not supplied for inspection; article snippets and attachment descriptions do not establish a complete, compilable repository.
- Reconstruction depends on files actually attached or provided by the author, including the existing interface and approval-loop infrastructure from earlier parts.
- Position counts and floating results describe conditions when the card is built; they are not guarantees of later execution results.
- The article demonstrates the workflow on an Exness demo hedging account using BTCUSDm, a one-minute chart, and MetaTrader 5 build 6230. This is not evidence of profitability or universal account compatibility.
- The project is a reference, not a claim of production readiness. Review argument handling, execution behavior, and approval safeguards before trading use.
## Reference
- [Original article](https://www.mql5.com/en/articles/24281)
- [Allan Munene Mutiiria — author profile](https://www.mql5.com/en/users/29210372)
- [Algo Forge repository](https://forge.mql5.io/29210372/Article-24281-AI-Powered-Trading-Systems-Structured-Approval-Cards)
- [Previous article: Part 13](https://www.mql5.com/en/articles/24272)