628 lines
No EOL
25 KiB
MQL5
628 lines
No EOL
25 KiB
MQL5
//+------------------------------------------------------------------+
|
|
//| 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:
|
|
const long m_panel_chart_id;
|
|
const long m_bot_chart_id;
|
|
|
|
public:
|
|
CAiTaskRunnerToolGetTaskTotal(const long panel_chart_id, const long bot_chart_id)
|
|
: CLlmTool("Returns the total number of tasks in the table", "aidatataskrunner_get_task_total"),
|
|
m_panel_chart_id(panel_chart_id), m_bot_chart_id(bot_chart_id)
|
|
{
|
|
m_params_size = ArrayResize(m_params, 0);
|
|
}
|
|
~CAiTaskRunnerToolGetTaskTotal() {}
|
|
|
|
//---
|
|
string Run(CJsonNode &json_args, const string &id) override final
|
|
{
|
|
if(!::EventChartCustom(m_panel_chart_id, AIDATATASKRUNER_API_ON_PARAM_CHANGE,
|
|
m_bot_chart_id, double(AIDATATASKRUNER_API_TASK_TOTAL),
|
|
AiDataTaskRunnerEmpaquetar(id, "")))
|
|
return "Error | Failed to dispatch get_task_total";
|
|
|
|
return "Queued | Result will appear in chat";
|
|
}
|
|
};
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
class CAiTaskRunnerToolCleanAllTasks : public CLlmTool
|
|
{
|
|
private:
|
|
const long m_panel_chart_id;
|
|
const long m_bot_chart_id;
|
|
|
|
public:
|
|
CAiTaskRunnerToolCleanAllTasks(const long panel_chart_id, const long bot_chart_id)
|
|
: CLlmTool("Cleans all tasks from the table that are not running or queued", "aidatataskrunner_clean_all_tasks"),
|
|
m_panel_chart_id(panel_chart_id), m_bot_chart_id(bot_chart_id)
|
|
{
|
|
m_params_size = ArrayResize(m_params, 0);
|
|
}
|
|
~CAiTaskRunnerToolCleanAllTasks() {}
|
|
|
|
//---
|
|
string Run(CJsonNode &json_args, const string &id) override final
|
|
{
|
|
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, "")))
|
|
return "Error | Failed to dispatch clean_all_tasks";
|
|
|
|
return "Queued | Cleaning tasks, result will appear in chat";
|
|
}
|
|
};
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
class CAiTaskRunnerToolExecuteAllTasks : public CLlmTool
|
|
{
|
|
private:
|
|
const long m_panel_chart_id;
|
|
const long m_bot_chart_id;
|
|
|
|
public:
|
|
CAiTaskRunnerToolExecuteAllTasks(const long panel_chart_id, const long bot_chart_id)
|
|
: CLlmTool("Executes all pending tasks in the table", "aidatataskrunner_execute_all_tasks"),
|
|
m_panel_chart_id(panel_chart_id), m_bot_chart_id(bot_chart_id)
|
|
{ m_params_size = ArrayResize(m_params, 0); }
|
|
~CAiTaskRunnerToolExecuteAllTasks() {}
|
|
|
|
//---
|
|
string Run(CJsonNode &json_args, const string &id) override final
|
|
{
|
|
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, "")))
|
|
return "Error | Failed to dispatch execute_all_tasks";
|
|
|
|
return "Queued | Executing all tasks, result will appear in chat";
|
|
}
|
|
};
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
class CAiTaskRunnerToolGetMainFolder : public CLlmTool
|
|
{
|
|
private:
|
|
const long m_panel_chart_id;
|
|
const long m_bot_chart_id;
|
|
|
|
public:
|
|
CAiTaskRunnerToolGetMainFolder(const long panel_chart_id, const long bot_chart_id)
|
|
: CLlmTool("Returns the main base folder path used by AiDataTaskRunner app", "aidatataskrunner_get_main_folder"),
|
|
m_panel_chart_id(panel_chart_id), m_bot_chart_id(bot_chart_id)
|
|
{ m_params_size = ArrayResize(m_params, 0); }
|
|
~CAiTaskRunnerToolGetMainFolder() {}
|
|
|
|
//---
|
|
string Run(CJsonNode &json_args, const string &id) override final
|
|
{
|
|
if(!::EventChartCustom(m_panel_chart_id, AIDATATASKRUNER_API_ON_PARAM_CHANGE,
|
|
m_bot_chart_id, double(AIDATATASKRUNER_API_MAIN_FOLDER),
|
|
AiDataTaskRunnerEmpaquetar(id, "")))
|
|
return "Error | Failed to dispatch get_main_folder";
|
|
return "Queued | Result will appear in chat";
|
|
}
|
|
};
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
class CAiTaskRunnerToolGetTaskFolder : public CLlmTool
|
|
{
|
|
private:
|
|
const long m_panel_chart_id;
|
|
const long m_bot_chart_id;
|
|
|
|
public:
|
|
CAiTaskRunnerToolGetTaskFolder(const long panel_chart_id, const long bot_chart_id)
|
|
: CLlmTool("Returns the tasks folder path used by AiDataTaskRunner", "aidatataskrunner_get_task_folder"),
|
|
m_panel_chart_id(panel_chart_id), m_bot_chart_id(bot_chart_id)
|
|
{ m_params_size = ArrayResize(m_params, 0); }
|
|
~CAiTaskRunnerToolGetTaskFolder() {}
|
|
|
|
//---
|
|
string Run(CJsonNode &json_args, const string &id) override final
|
|
{
|
|
if(!::EventChartCustom(m_panel_chart_id, AIDATATASKRUNER_API_ON_PARAM_CHANGE,
|
|
m_bot_chart_id, double(AIDATATASKRUNER_API_TASK_FOLDER),
|
|
AiDataTaskRunnerEmpaquetar(id, "")))
|
|
return "Error | Failed to dispatch get_task_folder";
|
|
return "Queued | Result will appear in chat";
|
|
}
|
|
};
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
class CAiTaskRunnerToolIsInCommonFolder : public CLlmTool
|
|
{
|
|
private:
|
|
const long m_panel_chart_id;
|
|
const long m_bot_chart_id;
|
|
|
|
public:
|
|
CAiTaskRunnerToolIsInCommonFolder(const long panel_chart_id, const long bot_chart_id)
|
|
: CLlmTool("Returns whether AiDataTaskRunner is using the MT5 common folder", "aidatataskrunner_is_in_commonfolder"),
|
|
m_panel_chart_id(panel_chart_id), m_bot_chart_id(bot_chart_id)
|
|
{ m_params_size = ArrayResize(m_params, 0); }
|
|
~CAiTaskRunnerToolIsInCommonFolder() {}
|
|
|
|
//---
|
|
string Run(CJsonNode &json_args, const string &id) override final
|
|
{
|
|
if(!::EventChartCustom(m_panel_chart_id, AIDATATASKRUNER_API_ON_PARAM_CHANGE,
|
|
m_bot_chart_id, double(AIDATATASKRUNER_API_IS_IN_COMMON_FOLDER),
|
|
AiDataTaskRunnerEmpaquetar(id, "")))
|
|
return "Error | Failed to dispatch is_in_commonfolder";
|
|
return "Queued | Result will appear in chat";
|
|
}
|
|
};
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
class CAiTaskRunnerToolAddTask : public CLlmTool
|
|
{
|
|
private:
|
|
const long m_panel_chart_id;
|
|
const long m_bot_chart_id;
|
|
|
|
public:
|
|
CAiTaskRunnerToolAddTask(const long panel_chart_id, const long bot_chart_id);
|
|
~CAiTaskRunnerToolAddTask(void) {}
|
|
|
|
string Run(CJsonNode &json_args, const string &id) override final;
|
|
};
|
|
|
|
//+------------------------------------------------------------------+
|
|
CAiTaskRunnerToolAddTask::CAiTaskRunnerToolAddTask(const long panel_chart_id, const long bot_chart_id)
|
|
: CLlmTool("Adds a new backtest task to the AiDataTaskRunner table", "aidatataskrunner_add_task"),
|
|
m_panel_chart_id(panel_chart_id), m_bot_chart_id(bot_chart_id)
|
|
{
|
|
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();
|
|
g_json_builder.Val("_Period");
|
|
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();
|
|
const int timeframe = CEnumReg::GetValueNoRef<int>(json_args["timeframe"].ToString("_Period"),_Period);
|
|
const string set_file = json_args["set_file"].ToString("");
|
|
const string symbol_folder = json_args["symbol_folder"].ToString("");
|
|
const string label = json_args["label"].ToString("");
|
|
const string label_id = json_args["label_id"].ToString("0");
|
|
|
|
//---
|
|
/*
|
|
//---
|
|
__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);
|
|
|
|
//---
|
|
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)))
|
|
return "Error | Failed to dispatch add_task";
|
|
|
|
return "Queued | Task added to table";
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
class CAiTaskRunnerToolSaveTasksToFile : public CLlmTool
|
|
{
|
|
private:
|
|
const long m_panel_chart_id;
|
|
const long m_bot_chart_id;
|
|
|
|
public:
|
|
CAiTaskRunnerToolSaveTasksToFile(const long panel_chart_id, const long bot_chart_id);
|
|
~CAiTaskRunnerToolSaveTasksToFile(void) {}
|
|
|
|
string Run(CJsonNode &json_args, const string &id) override final;
|
|
};
|
|
|
|
//+------------------------------------------------------------------+
|
|
CAiTaskRunnerToolSaveTasksToFile::CAiTaskRunnerToolSaveTasksToFile(const long panel_chart_id, const long bot_chart_id)
|
|
: 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"),
|
|
m_panel_chart_id(panel_chart_id), m_bot_chart_id(bot_chart_id)
|
|
{
|
|
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");
|
|
g_json_builder.Key("description").Val("Absolute path inside MT5 Files\\\\ or Common\\\\Files\\\\, and file extension is .csv");
|
|
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);
|
|
|
|
//---
|
|
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)))
|
|
return "Error | Failed to dispatch save_tasks_to_file";
|
|
|
|
return "Queued | Saving tasks to file";
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
class CAiTaskRunnerToolLoadTasksFromFile : public CLlmTool
|
|
{
|
|
private:
|
|
const long m_panel_chart_id;
|
|
const long m_bot_chart_id;
|
|
|
|
public:
|
|
CAiTaskRunnerToolLoadTasksFromFile(const long panel_chart_id, const long bot_chart_id);
|
|
~CAiTaskRunnerToolLoadTasksFromFile(void) {}
|
|
|
|
string Run(CJsonNode &json_args, const string &id) override final;
|
|
};
|
|
|
|
//+------------------------------------------------------------------+
|
|
CAiTaskRunnerToolLoadTasksFromFile::CAiTaskRunnerToolLoadTasksFromFile(const long panel_chart_id, const long bot_chart_id)
|
|
: CLlmTool("Loads tasks from a CSV file into the table", "aidatataskrunner_load_tasks_from_file"),
|
|
m_panel_chart_id(panel_chart_id), m_bot_chart_id(bot_chart_id)
|
|
{
|
|
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");
|
|
g_json_builder.Key("description").Val("Absolute path inside MT5 Files\\\\ or Common\\\\Files\\\\, and file extension is .csv");
|
|
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();
|
|
|
|
//---
|
|
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)))
|
|
return "Error | Failed to dispatch load_tasks_from_file";
|
|
|
|
return "Queued | Loading tasks from file";
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
class CAiTaskRunnerToolLoadConfig : public CLlmTool
|
|
{
|
|
private:
|
|
const long m_panel_chart_id;
|
|
const long m_bot_chart_id;
|
|
|
|
public:
|
|
CAiTaskRunnerToolLoadConfig(const long panel_chart_id, const long bot_chart_id);
|
|
~CAiTaskRunnerToolLoadConfig(void) {}
|
|
|
|
string Run(CJsonNode &json_args, const string &id) override final;
|
|
};
|
|
|
|
//+------------------------------------------------------------------+
|
|
CAiTaskRunnerToolLoadConfig::CAiTaskRunnerToolLoadConfig(const long panel_chart_id, const long bot_chart_id)
|
|
: CLlmTool("Loads the panel configuration from a file", "aidatataskrunner_load_config"),
|
|
m_panel_chart_id(panel_chart_id), m_bot_chart_id(bot_chart_id)
|
|
{
|
|
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");
|
|
g_json_builder.Key("description").Val("Absolute path inside MT5 Files\\\\ or Common\\\\Files\\\\, and file extension is .txt");
|
|
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();
|
|
|
|
//---
|
|
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)))
|
|
return "Error | Failed to dispatch load_config";
|
|
|
|
return "Queued | Loading config from file";
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
class CAiTaskRunnerToolSaveConfig : public CLlmTool
|
|
{
|
|
private:
|
|
const long m_panel_chart_id;
|
|
const long m_bot_chart_id;
|
|
|
|
public:
|
|
CAiTaskRunnerToolSaveConfig(const long panel_chart_id, const long bot_chart_id);
|
|
~CAiTaskRunnerToolSaveConfig(void) {}
|
|
|
|
string Run(CJsonNode &json_args, const string &id) override final;
|
|
};
|
|
|
|
//+------------------------------------------------------------------+
|
|
CAiTaskRunnerToolSaveConfig::CAiTaskRunnerToolSaveConfig(const long panel_chart_id, const long bot_chart_id)
|
|
: CLlmTool("Saves the current panel configuration to a file", "aidatataskrunner_save_config"),
|
|
m_panel_chart_id(panel_chart_id), m_bot_chart_id(bot_chart_id)
|
|
{
|
|
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");
|
|
g_json_builder.Key("description").Val("Absolute path inside MT5 Files\\\\ or Common\\\\Files\\\\, and file extension is .txt");
|
|
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();
|
|
|
|
//---
|
|
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)))
|
|
return "Error | Failed to dispatch save_config";
|
|
|
|
return "Queued | Saving config to file";
|
|
}
|
|
|
|
//+------------------------------------------------------------------+
|
|
//| |
|
|
//+------------------------------------------------------------------+
|
|
class CAiTaskRunnerToolGetTaskByIndex : public CLlmTool
|
|
{
|
|
private:
|
|
const long m_panel_chart_id;
|
|
const long m_bot_chart_id;
|
|
|
|
public:
|
|
CAiTaskRunnerToolGetTaskByIndex(const long panel_chart_id, const long bot_chart_id);
|
|
~CAiTaskRunnerToolGetTaskByIndex(void) {}
|
|
|
|
string Run(CJsonNode &json_args, const string &id) override final;
|
|
};
|
|
|
|
//+------------------------------------------------------------------+
|
|
CAiTaskRunnerToolGetTaskByIndex::CAiTaskRunnerToolGetTaskByIndex(const long panel_chart_id, const long bot_chart_id)
|
|
: CLlmTool("Returns the details of a task by its index in the table", "aidatataskrunner_get_task_by_index"),
|
|
m_panel_chart_id(panel_chart_id), m_bot_chart_id(bot_chart_id)
|
|
{
|
|
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();
|
|
|
|
//---
|
|
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)))
|
|
return "Error | Failed to dispatch get_task_by_index";
|
|
|
|
return "Queued | Result will appear in chat";
|
|
}
|
|
//+------------------------------------------------------------------+
|
|
#endif // AIDATATASKRUNNER_BACKEND_TLGM_TOOLS_TOOLS_MQH |