2026-03-17 08:31:01 -05:00
//+------------------------------------------------------------------+
//| AiDataTaskRunnerByLeo.mq5 |
//| Copyright 2026, Niquel Mendoza. |
//| https://www.mql5.com/es/users/nique_372 |
//+------------------------------------------------------------------+
# property copyright " Copyright 2026, Niquel Mendoza. "
# property link " https://www.mql5.com/es/users/nique_372 "
# property version " 1.00 "
# property description " Automate data generation and AI model training through a simple, easy-to-use GUI. "
2026-03-25 21:39:19 -05:00
//#define RELEASE_VERSION
2026-04-17 22:43:49 -05:00
# define AIDATATASKRUNER_API_DEBUG
2026-03-17 08:31:01 -05:00
//+------------------------------------------------------------------+
2026-03-25 22:18:55 -05:00
//| Include |
2026-03-17 08:31:01 -05:00
//+------------------------------------------------------------------+
2026-03-21 06:15:18 -05:00
# include "Global.mqh"
2026-03-17 16:50:48 -05:00
# include "Backend\\All.mqh"
2026-03-17 08:31:01 -05:00
//+------------------------------------------------------------------+
2026-03-25 22:18:55 -05:00
//| Inputs |
2026-03-17 08:31:01 -05:00
//+------------------------------------------------------------------+
2026-04-17 17:57:30 -05:00
//---
2026-03-17 08:31:01 -05:00
sinput group " -- Panel folder -- "
2026-04-11 17:18:10 -05:00
input ENUM_VERBOSE_LOG_LEVEL InpLogLevelPanelFronted = VERBOSE_LOG_LEVEL_ALL ; // Log levels:
2026-03-17 08:31:01 -05:00
input string InpGeneralBaseFolder = " AiDataTaskRunner \\ " ; // Folder for panel files
input bool InpGeneralCommonFolder = true ; // In common folder ?
2026-04-17 17:57:30 -05:00
//---
2026-03-17 08:31:01 -05:00
sinput group " -- Generation -- "
2026-04-11 17:18:10 -05:00
input ENUM_VERBOSE_LOG_LEVEL InpLogLevelPanelBackend = VERBOSE_LOG_LEVEL_ALL ; // Log levels:
2026-03-17 08:31:01 -05:00
input bool InpBackendCommonIn = true ; // Files EA input in common folder ?
input bool InpBackendCommonOut = true ; // Files EA output in common folder ?
2026-04-11 17:18:10 -05:00
input ENUM_MTTESTER_MODELADO_MODE InpBackendModeladoType = MTTESTER_MODELADO_OCHLM1 ; // Modelling:
2026-03-17 08:31:01 -05:00
2026-04-17 17:57:30 -05:00
//---
2026-03-17 08:31:01 -05:00
sinput group " -- Telegram bot -- "
2026-03-26 09:51:33 -05:00
input string InpTelegramBotPath = EXPERT_TELEGRAM_PATH ; // Put the path of telegram (Full incluyed Experts\\)
2026-03-17 08:31:01 -05:00
2026-04-17 17:57:30 -05:00
//---
2026-03-21 06:15:18 -05:00
sinput group " -- Training (Py comunication files)-- "
2026-03-26 09:51:33 -05:00
sinput group " - Files comuniction - "
2026-04-01 13:21:12 -05:00
input string InpComment1 = " The files located here are relative to the common folder if 'Files EA output in common folder ?' is true " ; // -
input string InpComment2 = " Otherwise, they are relative to MQL5 \\ Files \\ " ; // -
2026-03-21 06:15:18 -05:00
input string InpTrainingPyComPathJson = " AiDataTaskRunner \\ Comunication \\ res.json " ; // Put the path of json
input string InpTrainingPyComPathBin = " AiDataTaskRunner \\ Comunication \\ lock.bin " ; // Put the path of bin file
2026-03-26 09:51:33 -05:00
2026-03-28 08:35:32 -05:00
sinput group " - Py interprete (only for execute .py) - "
input string InpTrainingPyInterpete = " python.exe " ; // Path to python interpreter (e.g. python.exe or C:\Python311\python.exe)
2026-03-28 10:58:12 -05:00
input string InpTrainingPyPath = " C: \\ Users \\ USER \\ AppData \\ Roaming \\ MetaQuotes \\ Terminal \\ D0E8209F77C8CF37AD8BF550E51FF075 \\ MQL5 \\ Shared Projects " ; // PYTHONPATH separated by ;
2026-03-28 08:35:32 -05:00
2026-03-26 09:51:33 -05:00
sinput group " - EA Launcher - "
input string InpTrainingPyLauncherEa = " Shared Projects \\ AiDataTaskRuner \\ Backend \\ Training \\ TrainingLauncher.ex5 " ; // Put the path of EA launcher (Relative at Experts\\)
2026-03-24 10:39:38 -05:00
2026-04-17 17:57:30 -05:00
//---
2026-04-08 07:46:28 -05:00
sinput group " -- Workflows -- "
input string InpWFEaRevPath = " Shared Projects \\ AiDataTaskRuner \\ Backend \\ Workflows \\ RunnerWF.ex5 " ; // Put the path of EA launcher (Relative at Experts\\)
2026-04-17 17:57:30 -05:00
//---
sinput group " -- MCP Server -- "
input string InpMcpServerExpPathFull = " Experts \\ Shared Projects \\ AiDataTaskRuner \\ Backend \\ Mcp \\ McpServ.ex5 " ; // Put the path of telegram (Full incluyed Experts\\)
2026-03-21 06:15:18 -05:00
2026-03-17 08:31:01 -05:00
//+------------------------------------------------------------------+
2026-03-25 22:18:55 -05:00
//| Global variables |
2026-03-17 08:31:01 -05:00
//+------------------------------------------------------------------+
2026-04-01 13:21:12 -05:00
// Fronted de la aplicacion
2026-03-17 08:31:01 -05:00
CProgram g_program ;
2026-04-01 13:21:12 -05:00
//---
// Backend (Ejecucion del tester para la generacion de datos)
CExecutionTester g_backend_executor_tester ;
// Comunicacion entre el Tab Ai y el telegram bot (Esto para modificar paraemtors del bot de telegram)
CChatTelegramAgentLLmBase * g_sender_to_telegram ;
// Backend Tab config (Esto para ir comunicandose con el py, se hace un pool de un archivo)
CTrainingTabConfig * g_backend_trainer_config ;
2026-04-08 07:46:28 -05:00
// Tab workflows (capturar eventos)
CTabWorkflows * g_tab_wf ;
2026-04-01 13:21:12 -05:00
//--- Api
// Esta es la encarga de ir recibiendo cualquier evento que le manden al panel y lo procesa
CAiDataTaskRunnerApiReciber g_api ;
2026-03-17 08:31:01 -05:00
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit ( )
{
2026-04-01 13:21:12 -05:00
//--- Configracion general del panel
2026-03-17 08:31:01 -05:00
g_aidatatask_runner_config_g . base_folder = InpGeneralBaseFolder ;
g_aidatatask_runner_config_g . comon_flag = InpGeneralCommonFolder ;
2026-04-11 17:18:45 -05:00
2026-04-01 13:21:12 -05:00
//--- Configraucion del backend
2026-03-17 08:31:01 -05:00
// Backend
2026-04-01 13:21:12 -05:00
g_backend_executor_tester . AddLogFlags ( InpLogLevelPanelBackend ) ;
2026-04-11 17:18:10 -05:00
g_backend_executor_tester .Set ( g_program . GetSecTaskRunerAiDGenPtr ( ) , InpBackendCommonIn , InpBackendCommonOut , InpBackendModeladoType ) ;
2026-03-17 08:31:01 -05:00
// Fronted
2026-04-01 13:21:12 -05:00
g_program . GetSecTaskRunerAiDGenPtr ( ) . SetRunner ( & g_backend_executor_tester ) ;
// Api
if ( ! g_api .Init ( ) )
{
FastLog ( FATAL_ERROR_TEXT , FUNCION_ACTUAL , " Fallo al inicar la api del panel " ) ;
return INIT_FAILED ;
}
g_api . SetDataGeneration ( & g_backend_executor_tester , g_program . GetSecTaskRunerAiDGenPtr ( ) ) ;
2026-03-17 16:50:48 -05:00
// Tab ai
2026-04-01 13:21:12 -05:00
g_sender_to_telegram = new CChatTelegramAgentLLmBase ( ) ;
2026-04-17 17:57:30 -05:00
g_program . GetSecAi ( ) . Initialize ( g_aidatatask_runner_config_g . base_folder , AIDATATASK_RUNNER_COMON_FLAG , g_sender_to_telegram , InpMcpServerExpPathFull ) ;
2026-04-01 13:21:12 -05:00
g_sender_to_telegram . RunEA ( InpTelegramBotPath ) ; // Corremos el EA (tlgm) esto es la comuncacion entre el panel que le dice que parameotrs cambiar a telegram bot
2026-03-17 16:50:48 -05:00
2026-04-08 07:46:28 -05:00
2026-03-17 08:31:01 -05:00
//---
2026-04-08 07:46:28 -05:00
// Tab wf
g_tab_wf = g_program . GetTabWF ( ) ;
g_tab_wf .Init ( InpWFEaRevPath ) ;
2026-04-08 20:35:41 -05:00
if ( ! g_tab_wf . RunEA ( ) )
{
return INIT_FAILED ;
}
2026-04-08 07:46:28 -05:00
2026-03-21 06:15:18 -05:00
// Config del training tab
TrainingTabConfig config ;
config . config_py_path_json_file = InpTrainingPyComPathJson ;
config . config_py_path_lock_bin_file = InpTrainingPyComPathBin ;
config . proyect_common_flag = InpBackendCommonOut ;
2026-03-24 10:39:38 -05:00
config . config_path_to_ea_launcher = InpTrainingPyLauncherEa ;
2026-03-28 10:22:11 -05:00
config . config_path_interpete_py = InpTrainingPyInterpete ;
2026-03-28 10:58:12 -05:00
config . config_path_py_env = InpTrainingPyPath ;
2026-04-01 13:21:12 -05:00
g_backend_trainer_config = g_program . GetTrainingTab ( ) . Config ( ) ;
2026-03-21 06:15:18 -05:00
2026-04-01 13:21:12 -05:00
//--- Creacion final de la GUI
2026-03-21 06:15:18 -05:00
g_program . CreateGUI ( 700 , 500 , InpLogLevelPanelFronted , config ) ;
2026-03-17 08:31:01 -05:00
//---
return ( INIT_SUCCEEDED ) ;
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit ( const int reason )
{
2026-04-01 13:21:12 -05:00
//--- Matamos al timer
EventKillTimer ( ) ;
//--- Deinit del panel
2026-03-17 08:31:01 -05:00
g_program . OnDeinitEvent ( reason ) ;
2026-04-01 13:21:12 -05:00
//--- Finalizamos la api
g_api . Deinit ( ) ;
//--- Deinit final del DSL
CAutoCleaner : : Deinit ( reason ) ; // lamamos para que elimine todo lo relaciion a las depndicas del dsl (esto del feature editor)
2026-03-17 08:31:01 -05:00
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick ( )
{
2026-04-01 13:21:12 -05:00
//--- Nada aqui
2026-03-17 08:31:01 -05:00
}
//+------------------------------------------------------------------+
//| Timer function |
//+------------------------------------------------------------------+
void OnTimer ( )
{
//---
2026-04-01 13:21:12 -05:00
g_backend_trainer_config . OnTimerEvent ( ) ;
2026-03-17 08:31:01 -05:00
g_program . OnTimerEvent ( ) ;
}
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent ( const int32_t id ,
const long & lparam ,
const double & dparam ,
const string & sparam )
{
//---
2026-04-01 13:21:12 -05:00
g_api . ChartEvent ( id , lparam , dparam , sparam ) ; // Api tiene prioridad
g_backend_executor_tester . ChartEvent ( id , lparam , dparam , sparam ) ; // Luego los eventos del tester ()
2026-04-08 20:35:41 -05:00
g_tab_wf . ChartEvent ( id , lparam , dparam , sparam ) ; // Eventos de wf
2026-04-01 13:21:12 -05:00
g_program . ChartEvent ( id , lparam , dparam , sparam ) ; // Por ultimo el renderizado de la GUI
2026-03-17 08:31:01 -05:00
}
//+------------------------------------------------------------------+