Creating Projects¶
In this section, we will walk through the process of creating a new project using KnitPkg. While creating a project is very similar to creating a package, this guide provides a dedicated example to highlight the key differences and best practices.
Example: Creating an ATR Indicator¶
We will create a new indicator project called atr, which implements the Average True Range (ATR) using the ATR function from the @douglasrechia/calc package. The resulting binary will be named KnitPkgATR.ex5.
Step 1–4: Follow the Package Initialization Flow¶
You can follow the same initial steps described in Creating Packages:
- Create a new Git repository (e.g., DouglasRechia/atr)
- Open a terminal in your
MQL5/Indicatorsdirectory - Run
kp init - Choose
indicatoras the project type
Here’s an example of the terminal output during initialization:

Note
While this example uses an indicator project, you could just as easily create an Expert Advisor or any other type of project to consume KnitPkg packages.
Step 5: Add and Install Dependencies¶
We will use two packages:
@douglasrechia/bar— for bar and time series utilities@douglasrechia/calc— for the ATR calculation
Run the following commands:
Note
For packages, you use kp autocomplete. For projects (indicators, experts, etc.), use kp install.
After installation, your dependencies section in knitpkg.yaml should look like this:
A lock.json file will also be created, locking the resolved versions.
Step 6: Implement the Indicator¶
Now let’s use the ATR function from calc to implement the indicator logic.
You can find the complete source code here:
Once implemented, compile the indicator:
Attach the compiled KnitPkgATR.ex5 to a chart in MetaTrader to visualize the result:

Step 7: Register the Project¶
Once the indicator is working and committed to Git, follow the instructions in Registering a New Project to register it in the KnitPkg Registry.
To verify the registration:
Congratulations! You’ve created and registered a complete indicator project using KnitPkg packages. This demonstrates how easy it is to build modular, maintainable MQL5 projects with dependency management and version control.