mql4-bar/README.md

65 lines
2.9 KiB
Markdown
Raw Permalink Normal View History

2026-01-07 16:36:28 -03:00
# knitpkg-mt4-bar
2026-01-05 16:50:37 -03:00
**Simple, fast and reliable bar access with NewBar detection**
*MIT License*
---
## What is this?
2026-01-07 16:36:28 -03:00
`knitpkg-mt4-bar` is a **demonstration project** that showcases how to use **KnitPkg for MetaTrader** to manage MQL4 packages.
2026-01-05 16:50:37 -03:00
It provides a small, self‑contained package that provides interfaces such as `IBar` and `ITimeSeries` along with actual
implementations to provide access to broker data, together with a tiny test suite.
2026-01-07 16:36:28 -03:00
The project is intended **only as an educational example** of how to structure, package and compile MQL4 code with KnitPkg – it is **not** meant to be a production‑grade library for large-scale use.
2026-01-05 16:50:37 -03:00
## Features
2026-01-07 16:36:28 -03:00
- **Package type** (`type: package`) – header‑only library that can be consumed by other KnitPkg projects.
2026-01-05 16:50:37 -03:00
- **MQL4 target** – works with MetaTrader5.
2026-01-07 16:36:28 -03:00
- **Compile support** – `kp-mt compile` compiles the test suite.
2026-01-05 16:50:37 -03:00
2026-01-07 16:36:28 -03:00
## Adding `knitpkg-mt4-bar` as a dependency in your project
2026-01-05 16:50:37 -03:00
2026-01-07 16:36:28 -03:00
To use `knitpkg-mt4-bar` in your own KnitPkg project, add it as a dependency in your `knitpkg.yaml` file:
2026-01-05 16:50:37 -03:00
``` yaml
dependencies:
2026-01-07 16:36:28 -03:00
'@knitpkg.dev/knitpkg-mt4-bar': https://forge.MQL4.io/DouglasRechia/knitpkg-mt4-bar.git#^1.0.0
2026-01-05 16:50:37 -03:00
```
2026-01-07 16:36:28 -03:00
When you run `kp-mt install`, KnitPkg will automatically download `knitpkg-mt4-bar` into your project.
2026-01-05 16:50:37 -03:00
Notice the caret ^ preceding the version number: it means your project will get any minor or patch changes in
2026-01-07 16:36:28 -03:00
`knitpkg-mt4-bar` automatically whenever you issue the install command (that is, any SemVer tag like 2.x.y). Alternatively, you can run `kp-mt install --locked` to use the locked version, ensuring reproducible releases of your project. See KnitPkg docs for more details.
2026-01-05 16:50:37 -03:00
2026-01-07 16:36:28 -03:00
## Downloading `knitpkg-mt4-bar` and running Unit tests (optional)
2026-01-05 16:50:37 -03:00
2026-01-07 16:36:28 -03:00
If you're interested in exploring how a KnitPkg package project is structured, do the following:
2026-01-05 16:50:37 -03:00
``` bash
# Change to your 'Scripts' source directory.
# How to find it: in the MetaEditor navigator, right‑click the `Scripts` folder and select "Open Folder".
cd "C:\Users\username\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075\MQL4\Scripts"
# Clone the repository
2026-01-07 16:36:28 -03:00
git clone https://forge.MQL4.io/DouglasRechia/knitpkg-mt4-bar.git
2026-01-05 16:50:37 -03:00
2026-01-07 16:36:28 -03:00
cd knitpkg-mt4-bar
2026-01-05 16:50:37 -03:00
# Compile the test script
2026-01-07 16:36:28 -03:00
kp-mt compile
2026-01-05 16:50:37 -03:00
# Close MetaTrader and launch it again (needed to refresh navigator Scripts). Open any chart you want.
2026-01-07 16:36:28 -03:00
# The compiled binary `UnitTests.ex5` will appear in MetaTrader navigator under the Scripts/knitpkg-mt4-bar entry.
2026-01-05 16:50:37 -03:00
# Double‑click it to run the tests. See test results in the 'Scripts' tab.
```
## License
This project is released under the **MIT License**. See the `LICENSE` file for the full text.
## Disclaimer
*The author provides this code **as‑is**, for **educational purposes only**.
No warranty, express or implied, is given. The author assumes **no liability** for any damages, losses, or legal consequences that may arise from using, modifying, or distributing this software. Use it at your own risk.*