2026-03-18 12:10:52 -05:00
//+------------------------------------------------------------------+
//| Tools.mqh |
//| Copyright 2025, Niquel Mendoza. |
//| https://www.mql5.com/es/users/nique_372 |
//+------------------------------------------------------------------+
# property copyright " Copyright 2025, Niquel Mendoza. "
# property link " https://www.mql5.com/es/users/nique_372 "
# property strict
# ifndef AIDATATASKRUNNER_BACKEND_TLGM_TOOLS_TOOLS_MQH
# define AIDATATASKRUNNER_BACKEND_TLGM_TOOLS_TOOLS_MQH
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//--- Reciber
# include <TSN\\LLM\\TlgReciber.mqh>
//--- Protocolo de comunicacion con telegram
# include "..\\Protocol\\Def.mqh"
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CAiTaskRunnerToolGetTaskTotal : public CLlmTool
{
private :
2026-04-01 13:21:12 -05:00
const long m_panel_chart_id ;
2026-03-18 12:10:52 -05:00
const long m_bot_chart_id ;
public :
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolGetTaskTotal ( const long panel_chart_id , const long bot_chart_id )
2026-03-18 12:10:52 -05:00
: CLlmTool ( " Returns the total number of tasks in the table " , " aidatataskrunner_get_task_total " ) ,
2026-04-01 13:21:12 -05:00
m_panel_chart_id ( panel_chart_id ) , m_bot_chart_id ( bot_chart_id )
2026-03-18 12:10:52 -05:00
{
m_params_size = ArrayResize ( m_params , 0 ) ;
}
~ CAiTaskRunnerToolGetTaskTotal ( ) { }
//---
string Run ( CJsonNode & json_args , const string & id ) override final
{
2026-04-01 13:21:12 -05:00
if ( ! : : EventChartCustom ( m_panel_chart_id , AIDATATASKRUNER_API_ON_PARAM_CHANGE ,
m_bot_chart_id , double ( AIDATATASKRUNER_API_TASK_TOTAL ) ,
AiDataTaskRunnerEmpaquetar ( id , " " ) ) )
2026-03-18 12:10:52 -05:00
return " Error | Failed to dispatch get_task_total " ;
return " Queued | Result will appear in chat " ;
}
} ;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CAiTaskRunnerToolCleanAllTasks : public CLlmTool
{
private :
2026-04-01 13:21:12 -05:00
const long m_panel_chart_id ;
2026-03-18 12:10:52 -05:00
const long m_bot_chart_id ;
public :
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolCleanAllTasks ( const long panel_chart_id , const long bot_chart_id )
2026-03-18 12:10:52 -05:00
: CLlmTool ( " Cleans all tasks from the table that are not running or queued " , " aidatataskrunner_clean_all_tasks " ) ,
2026-04-01 13:21:12 -05:00
m_panel_chart_id ( panel_chart_id ) , m_bot_chart_id ( bot_chart_id )
2026-03-18 12:10:52 -05:00
{
m_params_size = ArrayResize ( m_params , 0 ) ;
}
~ CAiTaskRunnerToolCleanAllTasks ( ) { }
//---
string Run ( CJsonNode & json_args , const string & id ) override final
{
2026-04-01 13:21:12 -05:00
if ( ! : : EventChartCustom ( m_panel_chart_id , AIDATATASKRUNER_API_ON_PARAM_CHANGE ,
m_bot_chart_id , double ( AIDATATASKRUNER_API_CLEAN_ALL_TASK_OF_TABLE ) ,
AiDataTaskRunnerEmpaquetar ( id , " " ) ) )
2026-03-18 12:10:52 -05:00
return " Error | Failed to dispatch clean_all_tasks " ;
return " Queued | Cleaning tasks, result will appear in chat " ;
}
} ;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CAiTaskRunnerToolExecuteAllTasks : public CLlmTool
{
private :
2026-04-01 13:21:12 -05:00
const long m_panel_chart_id ;
2026-03-18 12:10:52 -05:00
const long m_bot_chart_id ;
public :
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolExecuteAllTasks ( const long panel_chart_id , const long bot_chart_id )
2026-03-18 12:10:52 -05:00
: CLlmTool ( " Executes all pending tasks in the table " , " aidatataskrunner_execute_all_tasks " ) ,
2026-04-01 13:21:12 -05:00
m_panel_chart_id ( panel_chart_id ) , m_bot_chart_id ( bot_chart_id )
2026-03-18 12:10:52 -05:00
{ m_params_size = ArrayResize ( m_params , 0 ) ; }
~ CAiTaskRunnerToolExecuteAllTasks ( ) { }
//---
string Run ( CJsonNode & json_args , const string & id ) override final
{
2026-04-01 13:21:12 -05:00
if ( ! : : EventChartCustom ( m_panel_chart_id , AIDATATASKRUNER_API_ON_PARAM_CHANGE ,
m_bot_chart_id , double ( AIDATATASKRUNER_API_EXECUTE_ALL_TASK_OF_TABLE ) ,
AiDataTaskRunnerEmpaquetar ( id , " " ) ) )
2026-03-18 12:10:52 -05:00
return " Error | Failed to dispatch execute_all_tasks " ;
return " Queued | Executing all tasks, result will appear in chat " ;
}
} ;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CAiTaskRunnerToolGetMainFolder : public CLlmTool
{
private :
2026-04-01 13:21:12 -05:00
const long m_panel_chart_id ;
2026-03-18 12:10:52 -05:00
const long m_bot_chart_id ;
public :
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolGetMainFolder ( const long panel_chart_id , const long bot_chart_id )
2026-04-10 15:42:04 -05:00
: CLlmTool ( " Returns the main base folder path used by AiDataTaskRunner app " , " aidatataskrunner_get_main_folder " ) ,
2026-04-01 13:21:12 -05:00
m_panel_chart_id ( panel_chart_id ) , m_bot_chart_id ( bot_chart_id )
2026-03-18 12:10:52 -05:00
{ m_params_size = ArrayResize ( m_params , 0 ) ; }
~ CAiTaskRunnerToolGetMainFolder ( ) { }
//---
string Run ( CJsonNode & json_args , const string & id ) override final
{
2026-04-01 13:21:12 -05:00
if ( ! : : EventChartCustom ( m_panel_chart_id , AIDATATASKRUNER_API_ON_PARAM_CHANGE ,
m_bot_chart_id , double ( AIDATATASKRUNER_API_MAIN_FOLDER ) ,
AiDataTaskRunnerEmpaquetar ( id , " " ) ) )
2026-03-18 12:10:52 -05:00
return " Error | Failed to dispatch get_main_folder " ;
return " Queued | Result will appear in chat " ;
}
} ;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CAiTaskRunnerToolGetTaskFolder : public CLlmTool
{
private :
2026-04-01 13:21:12 -05:00
const long m_panel_chart_id ;
2026-03-18 12:10:52 -05:00
const long m_bot_chart_id ;
public :
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolGetTaskFolder ( const long panel_chart_id , const long bot_chart_id )
2026-03-18 12:10:52 -05:00
: CLlmTool ( " Returns the tasks folder path used by AiDataTaskRunner " , " aidatataskrunner_get_task_folder " ) ,
2026-04-01 13:21:12 -05:00
m_panel_chart_id ( panel_chart_id ) , m_bot_chart_id ( bot_chart_id )
2026-03-18 12:10:52 -05:00
{ m_params_size = ArrayResize ( m_params , 0 ) ; }
~ CAiTaskRunnerToolGetTaskFolder ( ) { }
//---
string Run ( CJsonNode & json_args , const string & id ) override final
{
2026-04-01 13:21:12 -05:00
if ( ! : : EventChartCustom ( m_panel_chart_id , AIDATATASKRUNER_API_ON_PARAM_CHANGE ,
m_bot_chart_id , double ( AIDATATASKRUNER_API_TASK_FOLDER ) ,
AiDataTaskRunnerEmpaquetar ( id , " " ) ) )
2026-03-18 12:10:52 -05:00
return " Error | Failed to dispatch get_task_folder " ;
return " Queued | Result will appear in chat " ;
}
} ;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CAiTaskRunnerToolIsInCommonFolder : public CLlmTool
{
private :
2026-04-01 13:21:12 -05:00
const long m_panel_chart_id ;
2026-03-18 12:10:52 -05:00
const long m_bot_chart_id ;
public :
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolIsInCommonFolder ( const long panel_chart_id , const long bot_chart_id )
2026-03-18 12:10:52 -05:00
: CLlmTool ( " Returns whether AiDataTaskRunner is using the MT5 common folder " , " aidatataskrunner_is_in_commonfolder " ) ,
2026-04-01 13:21:12 -05:00
m_panel_chart_id ( panel_chart_id ) , m_bot_chart_id ( bot_chart_id )
2026-03-18 12:10:52 -05:00
{ m_params_size = ArrayResize ( m_params , 0 ) ; }
~ CAiTaskRunnerToolIsInCommonFolder ( ) { }
//---
string Run ( CJsonNode & json_args , const string & id ) override final
{
2026-04-01 13:21:12 -05:00
if ( ! : : EventChartCustom ( m_panel_chart_id , AIDATATASKRUNER_API_ON_PARAM_CHANGE ,
m_bot_chart_id , double ( AIDATATASKRUNER_API_IS_IN_COMMON_FOLDER ) ,
AiDataTaskRunnerEmpaquetar ( id , " " ) ) )
2026-03-18 12:10:52 -05:00
return " Error | Failed to dispatch is_in_commonfolder " ;
return " Queued | Result will appear in chat " ;
}
} ;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CAiTaskRunnerToolAddTask : public CLlmTool
{
private :
2026-04-01 13:21:12 -05:00
const long m_panel_chart_id ;
2026-03-18 12:10:52 -05:00
const long m_bot_chart_id ;
public :
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolAddTask ( const long panel_chart_id , const long bot_chart_id ) ;
2026-03-18 12:10:52 -05:00
~ CAiTaskRunnerToolAddTask ( void ) { }
string Run ( CJsonNode & json_args , const string & id ) override final ;
} ;
//+------------------------------------------------------------------+
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolAddTask : : CAiTaskRunnerToolAddTask ( const long panel_chart_id , const long bot_chart_id )
2026-03-18 12:10:52 -05:00
: CLlmTool ( " Adds a new backtest task to the AiDataTaskRunner table " , " aidatataskrunner_add_task " ) ,
2026-04-01 13:21:12 -05:00
m_panel_chart_id ( panel_chart_id ) , m_bot_chart_id ( bot_chart_id )
2026-03-18 12:10:52 -05:00
{
m_params_size = ArrayResize ( m_params , 8 ) ;
//---
m_params [ 0 ] . Name ( " symbol " ) ;
g_json_builder . Clear ( ) ;
g_json_builder . Obj ( ) ;
g_json_builder . Key ( " type " ) . Val ( " string " ) ;
g_json_builder . Key ( " description " ) . Val ( " Trading symbol e.g. EURUSD, XAUUSD " ) ;
g_json_builder . EndObj ( ) ;
m_params [ 0 ] . SaveJsonValue ( g_json_builder ) ;
//---
m_params [ 1 ] . Name ( " start_date " ) ;
g_json_builder . Clear ( ) ;
g_json_builder . Obj ( ) ;
g_json_builder . Key ( " type " ) . Val ( " string " ) ;
g_json_builder . Key ( " description " ) . Val ( " Start date in format YYYY.MM.DD HH:MM " ) ;
g_json_builder . EndObj ( ) ;
m_params [ 1 ] . SaveJsonValue ( g_json_builder ) ;
//---
m_params [ 2 ] . Name ( " end_date " ) ;
g_json_builder . Clear ( ) ;
g_json_builder . Obj ( ) ;
g_json_builder . Key ( " type " ) . Val ( " string " ) ;
g_json_builder . Key ( " description " ) . Val ( " End date in format YYYY.MM.DD HH:MM " ) ;
g_json_builder . EndObj ( ) ;
m_params [ 2 ] . SaveJsonValue ( g_json_builder ) ;
//---
m_params [ 3 ] . Name ( " timeframe " ) ;
g_json_builder . Clear ( ) ;
g_json_builder . Obj ( ) ;
g_json_builder . Key ( " type " ) . Val ( " string " ) ;
g_json_builder . Key ( " description " ) . Val ( " Timeframe of the backtest " ) ;
g_json_builder . Key ( " enum " ) . Arr ( ) ;
2026-04-10 15:42:04 -05:00
g_json_builder . Val ( " _Period " ) ;
2026-03-18 12:10:52 -05:00
g_json_builder . Val ( " M1 " ) ;
g_json_builder . Val ( " M2 " ) ;
g_json_builder . Val ( " M3 " ) ;
g_json_builder . Val ( " M4 " ) ;
g_json_builder . Val ( " M5 " ) ;
g_json_builder . Val ( " M6 " ) ;
g_json_builder . Val ( " M10 " ) ;
g_json_builder . Val ( " M12 " ) ;
g_json_builder . Val ( " M15 " ) ;
g_json_builder . Val ( " M20 " ) ;
g_json_builder . Val ( " M30 " ) ;
g_json_builder . Val ( " H1 " ) ;
g_json_builder . Val ( " H2 " ) ;
g_json_builder . Val ( " H3 " ) ;
g_json_builder . Val ( " H4 " ) ;
g_json_builder . Val ( " H6 " ) ;
g_json_builder . Val ( " H8 " ) ;
g_json_builder . Val ( " H12 " ) ;
g_json_builder . Val ( " D1 " ) ;
g_json_builder . Val ( " W1 " ) ;
g_json_builder . Val ( " MN1 " ) ;
g_json_builder . EndArr ( ) ;
g_json_builder . EndObj ( ) ;
m_params [ 3 ] . SaveJsonValue ( g_json_builder ) ;
//---
m_params [ 4 ] . Name ( " set_file " ) ;
g_json_builder . Clear ( ) ;
g_json_builder . Obj ( ) ;
g_json_builder . Key ( " type " ) . Val ( " string " ) ;
g_json_builder . Key ( " description " ) . Val ( " Optional .set file path for the EA parameters " ) ;
g_json_builder . EndObj ( ) ;
m_params [ 4 ] . SaveJsonValue ( g_json_builder ) ;
//---
m_params [ 5 ] . Name ( " symbol_folder " ) ;
g_json_builder . Clear ( ) ;
g_json_builder . Obj ( ) ;
g_json_builder . Key ( " type " ) . Val ( " string " ) ;
g_json_builder . Key ( " description " ) . Val ( " Optional subfolder name for grouping generated data e.g. XAUUSD or NAS100 " ) ;
g_json_builder . EndObj ( ) ;
m_params [ 5 ] . SaveJsonValue ( g_json_builder ) ;
//---
m_params [ 6 ] . Name ( " label " ) ;
g_json_builder . Clear ( ) ;
g_json_builder . Obj ( ) ;
g_json_builder . Key ( " type " ) . Val ( " string " ) ;
g_json_builder . Key ( " description " ) . Val ( " Optional strategy name used as folder prefix e.g. LiqSweep or BosChoch " ) ;
g_json_builder . EndObj ( ) ;
m_params [ 6 ] . SaveJsonValue ( g_json_builder ) ;
//---
m_params [ 7 ] . Name ( " label_id " ) ;
g_json_builder . Clear ( ) ;
g_json_builder . Obj ( ) ;
g_json_builder . Key ( " type " ) . Val ( " string " ) ;
g_json_builder . Key ( " description " ) . Val ( " Optional variant ID for the label, used to differentiate multiple models of the same strategy e.g. 0, 1, 2. Defaults to 0 " ) ;
g_json_builder . EndObj ( ) ;
m_params [ 7 ] . SaveJsonValue ( g_json_builder ) ;
//--- solo symbol, start_date y end_date son requeridos
string req [ ] = { " symbol " , " start_date " , " end_date " } ;
SetRequeridParameters ( req ) ;
}
//+------------------------------------------------------------------+
string CAiTaskRunnerToolAddTask : : Run ( CJsonNode & json_args , const string & id )
{
const string symbol = json_args [ " symbol " ] . ToString ( ) ;
const string start_date = json_args [ " start_date " ] . ToString ( ) ;
const string end_date = json_args [ " end_date " ] . ToString ( ) ;
2026-04-10 15:42:04 -05:00
const int timeframe = CEnumReg : : GetValueNoRef < int > ( json_args [ " timeframe " ] . ToString ( " _Period " ) , _Period ) ;
2026-04-01 13:21:12 -05:00
const string set_file = json_args [ " set_file " ] . ToString ( " " ) ;
2026-03-18 12:10:52 -05:00
const string symbol_folder = json_args [ " symbol_folder " ] . ToString ( " " ) ;
const string label = json_args [ " label " ] . ToString ( " " ) ;
2026-04-01 13:21:12 -05:00
const string label_id = json_args [ " label_id " ] . ToString ( " 0 " ) ;
2026-03-18 12:10:52 -05:00
//---
/*
//---
__forceinline string ToStringFile ( )
{
return StringFormat ( " %d|%s|%s|%s|%s|%s|%s|%d " ,
int ( timeframe ) , // [0]
symbol , // [1]
set_file , // [2]
TimeToString ( start_date ) , // [3]
TimeToString ( end_date ) , // [4]
symbol_folder , // [5]
label , // [6]
label_id ) ; // [7]
}
* /
//---
const string val = StringFormat ( " %d|%s|%s|%s|%s|%s|%s|%s " ,
timeframe , symbol , set_file ,
start_date , end_date ,
symbol_folder , label , label_id ) ;
//---
2026-04-01 13:21:12 -05:00
if ( ! : : EventChartCustom ( m_panel_chart_id , AIDATATASKRUNER_API_ON_PARAM_CHANGE ,
m_bot_chart_id , double ( AIDATATASKRUNER_API_ADD_TASK_TO_TABLE ) ,
AiDataTaskRunnerEmpaquetar ( id , val ) ) )
2026-03-18 12:10:52 -05:00
return " Error | Failed to dispatch add_task " ;
return " Queued | Task added to table " ;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CAiTaskRunnerToolSaveTasksToFile : public CLlmTool
{
private :
2026-04-01 13:21:12 -05:00
const long m_panel_chart_id ;
2026-03-18 12:10:52 -05:00
const long m_bot_chart_id ;
public :
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolSaveTasksToFile ( const long panel_chart_id , const long bot_chart_id ) ;
2026-03-18 12:10:52 -05:00
~ CAiTaskRunnerToolSaveTasksToFile ( void ) { }
string Run ( CJsonNode & json_args , const string & id ) override final ;
} ;
//+------------------------------------------------------------------+
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolSaveTasksToFile : : CAiTaskRunnerToolSaveTasksToFile ( const long panel_chart_id , const long bot_chart_id )
2026-03-18 12:10:52 -05:00
: CLlmTool ( " Saves all tasks to a CSV file. Can filter to save only unfinished tasks (pending, queued or in process) " , " aidatataskrunner_save_tasks_to_file " ) ,
2026-04-01 13:21:12 -05:00
m_panel_chart_id ( panel_chart_id ) , m_bot_chart_id ( bot_chart_id )
2026-03-18 12:10:52 -05:00
{
m_params_size = ArrayResize ( m_params , 2 ) ;
//---
m_params [ 0 ] . Name ( " file_name " ) ;
g_json_builder . Clear ( ) ;
g_json_builder . Obj ( ) ;
g_json_builder . Key ( " type " ) . Val ( " string " ) ;
2026-04-10 15:42:04 -05:00
g_json_builder . Key ( " description " ) . Val ( " Absolute path inside MT5 Files \\ \\ or Common \\ \\ Files \\ \\ , and file extension is .csv " ) ;
2026-03-18 12:10:52 -05:00
g_json_builder . EndObj ( ) ;
m_params [ 0 ] . SaveJsonValue ( g_json_builder ) ;
//---
m_params [ 1 ] . Name ( " only_unfinished " ) ;
g_json_builder . Clear ( ) ;
g_json_builder . Obj ( ) ;
g_json_builder . Key ( " type " ) . Val ( " boolean " ) ;
g_json_builder . Key ( " description " ) . Val ( " If true saves only pending queued or in-process tasks. If false saves all tasks including finished and failed ones " ) ;
g_json_builder . EndObj ( ) ;
m_params [ 1 ] . SaveJsonValue ( g_json_builder ) ;
//---
string req [ ] = { " file_name " , " only_unfinished " } ;
SetRequeridParameters ( req ) ;
}
//+------------------------------------------------------------------+
string CAiTaskRunnerToolSaveTasksToFile : : Run ( CJsonNode & json_args , const string & id )
{
const string file_name = json_args [ " file_name " ] . ToString ( ) ;
const bool only_unfinished = json_args [ " only_unfinished " ] . ToBool ( false ) ;
//---
const string val = StringFormat ( " %d|%s " , int ( only_unfinished ) , file_name ) ;
//---
2026-04-01 13:21:12 -05:00
if ( ! : : EventChartCustom ( m_panel_chart_id , AIDATATASKRUNER_API_ON_PARAM_CHANGE ,
m_bot_chart_id , double ( AIDATATASKRUNER_API_SAVE_TASK_IN_FILE ) ,
AiDataTaskRunnerEmpaquetar ( id , val ) ) )
2026-03-18 12:10:52 -05:00
return " Error | Failed to dispatch save_tasks_to_file " ;
return " Queued | Saving tasks to file " ;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CAiTaskRunnerToolLoadTasksFromFile : public CLlmTool
{
private :
2026-04-01 13:21:12 -05:00
const long m_panel_chart_id ;
2026-03-18 12:10:52 -05:00
const long m_bot_chart_id ;
public :
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolLoadTasksFromFile ( const long panel_chart_id , const long bot_chart_id ) ;
2026-03-18 12:10:52 -05:00
~ CAiTaskRunnerToolLoadTasksFromFile ( void ) { }
string Run ( CJsonNode & json_args , const string & id ) override final ;
} ;
//+------------------------------------------------------------------+
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolLoadTasksFromFile : : CAiTaskRunnerToolLoadTasksFromFile ( const long panel_chart_id , const long bot_chart_id )
2026-03-18 12:10:52 -05:00
: CLlmTool ( " Loads tasks from a CSV file into the table " , " aidatataskrunner_load_tasks_from_file " ) ,
2026-04-01 13:21:12 -05:00
m_panel_chart_id ( panel_chart_id ) , m_bot_chart_id ( bot_chart_id )
2026-03-18 12:10:52 -05:00
{
m_params_size = ArrayResize ( m_params , 1 ) ;
//---
m_params [ 0 ] . Name ( " file_name " ) ;
g_json_builder . Clear ( ) ;
g_json_builder . Obj ( ) ;
g_json_builder . Key ( " type " ) . Val ( " string " ) ;
2026-04-10 15:42:04 -05:00
g_json_builder . Key ( " description " ) . Val ( " Absolute path inside MT5 Files \\ \\ or Common \\ \\ Files \\ \\ , and file extension is .csv " ) ;
2026-03-18 12:10:52 -05:00
g_json_builder . EndObj ( ) ;
m_params [ 0 ] . SaveJsonValue ( g_json_builder ) ;
//---
string req [ ] = { " file_name " } ;
SetRequeridParameters ( req ) ;
}
//+------------------------------------------------------------------+
string CAiTaskRunnerToolLoadTasksFromFile : : Run ( CJsonNode & json_args , const string & id )
{
const string file_name = json_args [ " file_name " ] . ToString ( ) ;
//---
2026-04-01 13:21:12 -05:00
if ( ! : : EventChartCustom ( m_panel_chart_id , AIDATATASKRUNER_API_ON_PARAM_CHANGE ,
m_bot_chart_id , double ( AIDATATASKRUNER_API_LOAD_TASK_IN_FILE ) ,
AiDataTaskRunnerEmpaquetar ( id , file_name ) ) )
2026-03-18 12:10:52 -05:00
return " Error | Failed to dispatch load_tasks_from_file " ;
return " Queued | Loading tasks from file " ;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CAiTaskRunnerToolLoadConfig : public CLlmTool
{
private :
2026-04-01 13:21:12 -05:00
const long m_panel_chart_id ;
2026-03-18 12:10:52 -05:00
const long m_bot_chart_id ;
public :
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolLoadConfig ( const long panel_chart_id , const long bot_chart_id ) ;
2026-03-18 12:10:52 -05:00
~ CAiTaskRunnerToolLoadConfig ( void ) { }
string Run ( CJsonNode & json_args , const string & id ) override final ;
} ;
//+------------------------------------------------------------------+
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolLoadConfig : : CAiTaskRunnerToolLoadConfig ( const long panel_chart_id , const long bot_chart_id )
2026-03-18 12:10:52 -05:00
: CLlmTool ( " Loads the panel configuration from a file " , " aidatataskrunner_load_config " ) ,
2026-04-01 13:21:12 -05:00
m_panel_chart_id ( panel_chart_id ) , m_bot_chart_id ( bot_chart_id )
2026-03-18 12:10:52 -05:00
{
m_params_size = ArrayResize ( m_params , 1 ) ;
//---
m_params [ 0 ] . Name ( " file_name " ) ;
g_json_builder . Clear ( ) ;
g_json_builder . Obj ( ) ;
g_json_builder . Key ( " type " ) . Val ( " string " ) ;
2026-04-10 15:42:04 -05:00
g_json_builder . Key ( " description " ) . Val ( " Absolute path inside MT5 Files \\ \\ or Common \\ \\ Files \\ \\ , and file extension is .txt " ) ;
2026-03-18 12:10:52 -05:00
g_json_builder . EndObj ( ) ;
m_params [ 0 ] . SaveJsonValue ( g_json_builder ) ;
//---
string req [ ] = { " file_name " } ;
SetRequeridParameters ( req ) ;
}
//+------------------------------------------------------------------+
string CAiTaskRunnerToolLoadConfig : : Run ( CJsonNode & json_args , const string & id )
{
const string file_name = json_args [ " file_name " ] . ToString ( ) ;
//---
2026-04-01 13:21:12 -05:00
if ( ! : : EventChartCustom ( m_panel_chart_id , AIDATATASKRUNER_API_ON_PARAM_CHANGE ,
m_bot_chart_id , double ( AIDATATASKRUNER_API_LOAD_CONFIG_IN_FILE ) ,
AiDataTaskRunnerEmpaquetar ( id , file_name ) ) )
2026-03-18 12:10:52 -05:00
return " Error | Failed to dispatch load_config " ;
return " Queued | Loading config from file " ;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CAiTaskRunnerToolSaveConfig : public CLlmTool
{
private :
2026-04-01 13:21:12 -05:00
const long m_panel_chart_id ;
2026-03-18 12:10:52 -05:00
const long m_bot_chart_id ;
public :
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolSaveConfig ( const long panel_chart_id , const long bot_chart_id ) ;
2026-03-18 12:10:52 -05:00
~ CAiTaskRunnerToolSaveConfig ( void ) { }
string Run ( CJsonNode & json_args , const string & id ) override final ;
} ;
//+------------------------------------------------------------------+
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolSaveConfig : : CAiTaskRunnerToolSaveConfig ( const long panel_chart_id , const long bot_chart_id )
2026-03-18 12:10:52 -05:00
: CLlmTool ( " Saves the current panel configuration to a file " , " aidatataskrunner_save_config " ) ,
2026-04-01 13:21:12 -05:00
m_panel_chart_id ( panel_chart_id ) , m_bot_chart_id ( bot_chart_id )
2026-03-18 12:10:52 -05:00
{
m_params_size = ArrayResize ( m_params , 1 ) ;
//---
m_params [ 0 ] . Name ( " file_name " ) ;
g_json_builder . Clear ( ) ;
g_json_builder . Obj ( ) ;
g_json_builder . Key ( " type " ) . Val ( " string " ) ;
2026-04-10 15:42:04 -05:00
g_json_builder . Key ( " description " ) . Val ( " Absolute path inside MT5 Files \\ \\ or Common \\ \\ Files \\ \\ , and file extension is .txt " ) ;
2026-03-18 12:10:52 -05:00
g_json_builder . EndObj ( ) ;
m_params [ 0 ] . SaveJsonValue ( g_json_builder ) ;
//---
string req [ ] = { " file_name " } ;
SetRequeridParameters ( req ) ;
}
//+------------------------------------------------------------------+
string CAiTaskRunnerToolSaveConfig : : Run ( CJsonNode & json_args , const string & id )
{
const string file_name = json_args [ " file_name " ] . ToString ( ) ;
//---
2026-04-01 13:21:12 -05:00
if ( ! : : EventChartCustom ( m_panel_chart_id , AIDATATASKRUNER_API_ON_PARAM_CHANGE ,
m_bot_chart_id , double ( AIDATATASKRUNER_API_SAVE_CONFIG_IN_FILE ) ,
AiDataTaskRunnerEmpaquetar ( id , file_name ) ) )
2026-03-18 12:10:52 -05:00
return " Error | Failed to dispatch save_config " ;
return " Queued | Saving config to file " ;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CAiTaskRunnerToolGetTaskByIndex : public CLlmTool
{
private :
2026-04-01 13:21:12 -05:00
const long m_panel_chart_id ;
2026-03-18 12:10:52 -05:00
const long m_bot_chart_id ;
public :
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolGetTaskByIndex ( const long panel_chart_id , const long bot_chart_id ) ;
2026-03-18 12:10:52 -05:00
~ CAiTaskRunnerToolGetTaskByIndex ( void ) { }
string Run ( CJsonNode & json_args , const string & id ) override final ;
} ;
//+------------------------------------------------------------------+
2026-04-01 13:21:12 -05:00
CAiTaskRunnerToolGetTaskByIndex : : CAiTaskRunnerToolGetTaskByIndex ( const long panel_chart_id , const long bot_chart_id )
2026-03-18 12:10:52 -05:00
: CLlmTool ( " Returns the details of a task by its index in the table " , " aidatataskrunner_get_task_by_index " ) ,
2026-04-01 13:21:12 -05:00
m_panel_chart_id ( panel_chart_id ) , m_bot_chart_id ( bot_chart_id )
2026-03-18 12:10:52 -05:00
{
m_params_size = ArrayResize ( m_params , 1 ) ;
//---
m_params [ 0 ] . Name ( " index " ) ;
g_json_builder . Clear ( ) ;
g_json_builder . Obj ( ) ;
g_json_builder . Key ( " type " ) . Val ( " integer " ) ;
g_json_builder . Key ( " description " ) . Val ( " Zero-based index of the task in the table. Use aidatataskrunner_get_task_total to know the total number of tasks " ) ;
g_json_builder . EndObj ( ) ;
m_params [ 0 ] . SaveJsonValue ( g_json_builder ) ;
//---
string req [ ] = { " index " } ;
SetRequeridParameters ( req ) ;
}
//+------------------------------------------------------------------+
string CAiTaskRunnerToolGetTaskByIndex : : Run ( CJsonNode & json_args , const string & id )
{
const string index = json_args [ " index " ] . ToString ( ) ;
//---
2026-04-01 13:21:12 -05:00
if ( ! : : EventChartCustom ( m_panel_chart_id , AIDATATASKRUNER_API_ON_PARAM_CHANGE ,
m_bot_chart_id , double ( AIDATATASKRUNER_API_GET_TASK_BY_INDEX ) ,
AiDataTaskRunnerEmpaquetar ( id , index ) ) )
2026-03-18 12:10:52 -05:00
return " Error | Failed to dispatch get_task_by_index " ;
return " Queued | Result will appear in chat " ;
}
//+------------------------------------------------------------------+
# endif // AIDATATASKRUNNER_BACKEND_TLGM_TOOLS_TOOLS_MQH