A library that allows you to run workflows in an MT5 bot. Both asynchronous and synchronous jobs that require OnTimer\OnChartEvent to function... all through a YAML file where the user defines each step of the flow.
Find a file
Nique_372 1039d19933
2026-05-29 11:42:24 -05:00
Images new files added 2026-05-29 11:41:33 -05:00
Src - Se agrego sporte para out in namepsace tsn 2026-05-29 11:19:36 -05:00
Test/First - Actulizacion a a nueva version de YamlParser 2026-05-29 09:01:06 -05:00
dependencies.json Actualizar dependencies.json 2026-04-13 12:49:53 +00:00
LICENSE Actualizar LICENSE 2026-04-14 22:16:19 +00:00
README.md 2026-05-29 11:42:24 -05:00
WorkflowsByLeo.mqproj Generated by MQL5 Wizard 2026-04-04 21:14:16 -05:00

WorkflowsByLeo Logo

A lightweight workflow engine for MQL5 that lets you define and run multi-step automation sequences from a simple YAML file.


Main Features

Define workflows in YAML

name: "my workflow"
env:
  my_var: "hello"
steps:
  - name: "RunEA"
    module: "Generic"
    with:
      fixed:
        name: "Experts\\MyEA.ex5"
        symbol: _Symbol
        timeframe: _Period
        run_flags: "DLL|AutoTrading"
        ms_sincronizacion: 500
        timeout_segundos: 300
      ea_params:
        - InpNum: ["TYPE_UINT", "${{internal.number}}"]
  - name: "PowerShellCommand"
    module: "Generic"
    with:
      run: |
        echo 'done'
      timeout_segundos: 30

Run from MQL5

#resource "my_workflow.yml" as const string yml_workflow

TSN::CWorkflow flow;
TSN::CWfCallBack* callback = new TSN::CWfCallBack();
flow.AddCallBack(callback);

// Inject runtime variables
flow.Variables().Set("internal.number", string(GetTickCount()));

if(!flow.Init(yml_workflow))
   return INIT_PARAMETERS_INCORRECT;

flow.First();

Callbacks

class CMyCallback : public TSN::IWorkflowCallback
 {
public:
  inline uint8_t FlagsCall() const override { return WORKFLOWBYLEO_CALLBACK_ALL_FLAGS; }

  bool OnWorkflowStart() override
   {
    Print("Workflow started");
    return true;
   }
  void OnWorkflowStep(int code, int step_index) override
   {
    PrintFormat("Step %d finished with code %d", step_index, code);
   }
  void OnWorkflowEnd(int code, int step_index) override
   {
    Print("Workflow ended, code: ", code);
   }
 };

Variable interpolation

Reference any variable inside the YAML using ${{key}}:

ea_params:
  - InpMagic: ["TYPE_INT",    "${{env.magic}}"]
  - InpSymbol: ["TYPE_STRING", "${{env.symbol}}"]

Built-in steps

Module Name Description
Generic RunEA Opens a chart and runs an Expert Advisor with custom parameters, waits for it to finish
Generic PowerShellCommand Executes a PowerShell command and waits for completion
Generic SendMessage Sends a message (Telegram, etc.)
Generic File File operations

Repository Structure

WorkflowsByLeo/
├── Src/
│   ├── Core/    # Core definitions: CWorkflow, CWorkflowStep, IWorkflowCallback, factory
│   ├── Steps/   # Built-in steps (RunEA, RunProcess, Messages, File)
│   └── Final/   # Orchestrator — workflow execution engine
├── Test/
│   └── First/   # Basic usage example (sync workflow: RunEA + PowerShell)
└── Images/      # Repository assets

License

Read Full License

By downloading or using this repository, you accept the license terms.


Requirements

See dependencies.json for the full list of dependencies.

Some dependencies are private or require a purchase. Check each entry's comment field for access instructions.


Installation

cd "C:\Users\YOUR_USER\AppData\Roaming\MetaQuotes\Terminal\YOUR_ID\MQL5\Shared Projects"
tsndep install "https://forge.mql5.io/nique_372/WorkflowsByLeo.git"
  • Requires the tsndep package — available on PyPI. It automatically downloads and installs all declared dependencies.
  • If any dependency is private or paid, the install will fail for that package — check dependencies.json and contact me for access.

Quick Start

1. Define your workflow — create a .yml file and embed it as a resource:

#resource "my_workflow.yml" as const string yml_workflow

2. Include the library:

// TSN Ecosystem file include 
#include <TSN\\WFlows\\Orquestador.mqh>
#include <TSN\\WFlows\\AllSteps.mqh>
// Or relative at your project
#include "..\\WorkflowsByLeo\\Src\\Steps\\All.mqh"

3. Instantiate, configure and run:

TSN::CWorkflow flow;
flow.Variables().Set("internal.number", string(GetTickCount()));

if(!flow.Init(yml_workflow))
   return INIT_PARAMETERS_INCORRECT;

flow.First();

4. Clean up on deinit:

void OnDeinit(const int reason)
 {
  TSN::CWorflowsFactory::Deinit(reason);
 }

See Test\First\Generic.mq5 and Test\First\test.yml for a complete working example.


Contact