mql4-sma/README.md
2026-02-12 15:16:15 -03:00

2.8 KiB

Indicator sma

Simple Moving Average indicator using KnitPkg packages
MIT License


What is this?

Indicator sma is a demonstration project that showcases how to build a MetaTrader 4 indicator by consuming KnitPkg packages.

It implements a complete Simple Moving Average (SMA) indicator, and is meant to be an educational example of how to structure an indicator project, manage dependencies, and compile MQL4 code with KnitPkg. It is not meant to be a production-grade trading system.

Prerequisites

To build and use this project, you will need:

  1. MetaTrader 4 installed.
  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.
  3. KnitPkg homepage: See https://knitpkg.dev for an overview and https://docs.knitpkg.dev for documentation.

Features

  • Indicator type (type: indicator) — a complete indicator project (not a package)
  • SMA demo — Simple Moving Average indicator
  • Dependency installation — uses the KnitPkg registry to resolve and download dependencies
  • Dependencies
    • @douglasrechia/calc — SMA calculation utilities
  • MQL4 target — designed for MetaTrader 4
  • Compile supportkp compile builds the indicator into an .ex4 binary

One-command download/build via the registry

You can use kp get to query the registry for metadata and automatically download/build the latest stable version.

Example (run from your MetaTrader Data Folder root if you have MetaTrader installed in more than one location):

cd "C:\Users\username\AppData\Roaming\MetaQuotes\Terminal\<TERMINAL_ID>"

kp get mql4 @douglasrechia/sma

Restart MetaTrader afterward to refresh the Navigator.


Exploring the project locally (optional)

If you want to explore how an indicator project is structured with KnitPkg, clone it into your MetaTrader Indicators folder.

1) Clone into MetaTrader Indicators folder (example)

# Go to your MetaTrader 'Indicators' directory.
# Tip: in MetaEditor, right-click the `Indicators` folder and choose "Open Folder".
cd "C:\Users\username\AppData\Roaming\MetaQuotes\Terminal\<TERMINAL_ID>\MQL4\Indicators"

git clone https://forge.mql5.io/DouglasRechia/sma.git
cd sma

2) Install dependencies

kp install

3) Compile

kp compile

License

This project is released under the MIT License. See LICENSE for details.


Disclaimer

This code is provided as-is, for educational purposes only.
No warranty (express or implied) is provided. Use at your own risk.