calclibimp/README.md

90 lignes
3,1 Kio
Markdown
Brut Lien permanent Vue normale Historique

2026-02-12 14:48:58 -03:00
# Library calclibimp
2026-01-02 09:59:37 +00:00
2026-02-12 14:48:58 -03:00
**Reusable MQL5 library (.ex5) demo using KnitPkg packages**
*MIT License*
2026-01-02 11:20:43 -03:00
2026-02-12 14:48:58 -03:00
---
2026-01-02 11:20:43 -03:00
2026-02-12 14:48:58 -03:00
## What is this?
2026-01-02 11:20:43 -03:00
2026-02-12 14:48:58 -03:00
`calclibimp` is a **demonstration project** that showcases how to build a reusable MetaTrader 5 **MQL5 Library** (a compiled `.ex5`) using KnitPkg.
It compiles a library that implements `SMA_Close_TimeSeries`, a helper that calculates a rolling Simple Moving Average (SMA) for a given symbol and timeframe. The goal is to demonstrate how to encapsulate logic into a compiled library that can be imported by other projects (for example, `@douglasrechia/calclib`).
2026-01-02 11:20:43 -03:00
2026-02-12 14:48:58 -03:00
This project is intended **only as an educational example** of how to structure a library project, manage dependencies, and compile MQL5 code with KnitPkg. It is **not** meant to be a production-grade trading system.
2026-01-02 11:20:43 -03:00
## Prerequisites
2026-02-12 14:48:58 -03:00
To build and use this project, you will need:
2026-01-02 11:20:43 -03:00
1. [**MetaTrader 5**](https://www.mql5.com/) installed.
2026-01-07 14:52:24 -03:00
2. **KnitPkg CLI**: The KnitPkg package manager for MetaTrader. If you don't have it, you can install it by following the instructions in the [main KnitPkg repository](https://github.com/knitpkg-dev/knitpkg-mt.git).
2026-02-12 14:48:58 -03:00
3. **KnitPkg homepage**: See [https://knitpkg.dev](https://knitpkg.dev) for an overview and [https://docs.knitpkg.dev](https://docs.knitpkg.dev) for documentation.
2026-01-02 11:20:43 -03:00
2026-02-12 14:48:58 -03:00
---
2026-01-02 11:20:43 -03:00
2026-02-12 14:48:58 -03:00
## Features
2026-01-02 11:20:43 -03:00
2026-02-12 14:48:58 -03:00
- **Library type** (`type: library`) — a compiled `.ex5` library project (not a package)
- **SMA library function** — implements `SMA_Close_TimeSeries`
- **Dependency installation** — uses the KnitPkg registry to resolve and download dependencies
- **Dependencies**
- `@douglasrechia/calc` — technical analysis functions (SMA, etc.)
- `@douglasrechia/bar` — time series data access utilities
- **MQL5 target** — designed for MetaTrader 5
- **Compile support** — `kp compile` builds the library into an `.ex5` binary
2026-01-02 11:20:43 -03:00
2026-02-12 14:48:58 -03:00
---
2026-01-02 11:20:43 -03:00
2026-02-12 14:48:58 -03:00
## One-command download/build via the registry
2026-01-02 11:20:43 -03:00
2026-02-12 14:48:58 -03:00
You can use `kp get` to query the registry for metadata and automatically download/build the latest stable version.
2026-01-02 11:20:43 -03:00
2026-02-12 14:48:58 -03:00
Example (run from your MetaTrader *Data Folder* root if you have MetaTrader installed in more than one location):
2026-02-03 08:41:40 -03:00
2026-02-12 14:48:58 -03:00
```bash
cd "C:\Users\username\AppData\Roaming\MetaQuotes\Terminal\<TERMINAL_ID>"
2026-02-03 08:41:40 -03:00
kp get mql5 @douglasrechia/calclibimp
2026-02-12 14:48:58 -03:00
```
---
## Exploring the project locally (optional)
If you want to learn how to structure your own library with KnitPkg packages, clone this repository into your MetaTrader `Libraries` folder.
2026-02-03 08:41:40 -03:00
2026-02-12 14:48:58 -03:00
### 1) Clone into MetaTrader `Libraries` folder (example)
```bash
# Go to your MetaTrader 'Libraries' directory.
# Tip: in MetaEditor, right-click the `Libraries` folder and choose "Open Folder".
cd "C:\Users\username\AppData\Roaming\MetaQuotes\Terminal\<TERMINAL_ID>\MQL5\Libraries"
git clone https://forge.mql5.io/DouglasRechia/calclibimp.git
cd calclibimp
```
### 2) Install dependencies
```bash
kp install
2026-02-03 08:41:40 -03:00
```
2026-02-12 14:48:58 -03:00
### 3) Compile
2026-01-02 11:20:43 -03:00
2026-02-12 14:48:58 -03:00
```bash
kp compile
```
---
2026-01-02 11:20:43 -03:00
## License
2026-02-12 14:48:58 -03:00
This project is released under the **MIT License**. See `LICENSE` for details.
---
2026-01-02 11:20:43 -03:00
## Disclaimer
2026-02-12 14:48:58 -03:00
This code is provided **as-is**, for **educational purposes only**.
No warranty (express or implied) is provided. Use at your own risk.