2026-03-31 13:12:02 -05:00 | | | //+------------------------------------------------------------------+
|
2026-03-18 12:10:52 -05:00 | | | //| Saver.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_BASES_SAVER_MQH
|
| | | #define AIDATATASKRUNNER_BACKEND_BASES_SAVER_MQH
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | #include "Defines.mqh"
|
| | |
|
| | |
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
| | | class CTaskSaver : public CLoggerBase
|
| | | {
|
| | | public:
|
| | | CTaskSaver(void) {}
|
| | | ~CTaskSaver(void) {}
|
| | |
|
| | | //---
|
2026-03-25 15:17:13 -05:00 | | | bool LoadC(const string& file_name, int fc, string& msg, string& progress, string& file_name_json, string& mainfolder, string& exp_path);
|
2026-03-18 12:10:52 -05:00 | | | bool SaveC(const string& file_name, int fc, string& msg, const string& progress,
|
2026-03-25 15:17:13 -05:00 | | | const string& file_name_json, const string& mainfolder, const string& exp_path);
|
2026-03-18 12:10:52 -05:00 | | |
|
| | | //---
|
| | | bool Load(const string& file_name, TaskTester& arr[], int& size, int file_common, string& msg);
|
| | | bool Save(const string& file_name, TaskTester& arr[], int size, int file_common, bool filter, string& msg);
|
| | | };
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-03-25 15:17:13 -05:00 | | | bool CTaskSaver::LoadC(const string &file_name, int fc, string &msg, string &progress, string &file_name_json, string &mainfolder, string &exp_path)
|
2026-03-18 12:10:52 -05:00 | | | {
|
| | | //---
|
| | | ::ResetLastError();
|
| | | const int fh = FileOpen(file_name, FILE_READ | FILE_TXT | fc);
|
| | | if(fh == INVALID_HANDLE)
|
| | | {
|
| | | msg = (StringFormat("Fallo al abrir el archivo = %s, ultimo error = %d", file_name, ::GetLastError()));
|
| | | return false;
|
| | | }
|
| | |
|
| | | //---
|
| | | progress = FileReadString(fh);
|
| | | mainfolder = FileReadString(fh);
|
| | | exp_path = FileReadString(fh);
|
2026-03-25 15:17:13 -05:00 | | | file_name_json = FileReadString(fh);
|
2026-03-18 12:10:52 -05:00 | | |
|
| | | //---
|
| | | FileClose(fh);
|
| | |
|
| | | //---
|
| | | return true;
|
| | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-03-25 15:17:13 -05:00 | | | bool CTaskSaver::SaveC(const string &file_name, int fc, string &msg, const string &progress, const string& file_name_json, const string &mainfolder, const string &exp_path)
|
2026-03-18 12:10:52 -05:00 | | | {
|
| | | //---
|
| | | ::ResetLastError();
|
| | | const int fh = FileOpen(file_name, FILE_WRITE | FILE_TXT | fc);
|
| | | if(fh == INVALID_HANDLE)
|
| | | {
|
| | | msg = (StringFormat("Fallo al abrir el archivo = %s, ultimo error = %d", file_name, ::GetLastError()));
|
| | | return false;
|
| | | }
|
| | |
|
| | | //---
|
| | | FileWrite(fh, progress);
|
| | | FileWrite(fh, mainfolder);
|
| | | FileWrite(fh, exp_path);
|
2026-03-25 15:17:13 -05:00 | | | FileWrite(fh, file_name_json);
|
2026-03-18 12:10:52 -05:00 | | |
|
| | | //---
|
| | | FileClose(fh);
|
| | |
|
| | | //---
|
| | | return true;
|
| | |
|
| | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
2026-03-31 13:01:36 -05:00 | | | //| Tareas |
|
2026-03-18 12:10:52 -05:00 | | | //+------------------------------------------------------------------+
|
2026-03-31 13:01:36 -05:00 | | | // Se usa | para las separciones dado que no se puede tener nombres de arhcivos con ese char
|
2026-03-18 12:10:52 -05:00 | | | bool CTaskSaver::Save(const string &file_name, TaskTester &arr[], int size, int file_common, bool filter, string& msg)
|
| | | {
|
| | | //---
|
| | | ::ResetLastError();
|
| | | const int fh = FileOpen(file_name, FILE_WRITE | FILE_CSV | file_common);
|
| | | if(fh == INVALID_HANDLE)
|
| | | {
|
| | | msg = (StringFormat("Fallo al abrir el archivo = %s, ultimo error = %d", file_name, ::GetLastError()));
|
| | | return false;
|
| | | }
|
| | | //---
|
2026-03-31 13:12:02 -05:00 | | | FileWrite(fh, "Timeframe|Symbol|SetFile|StartDate|EndDate|SymbolFolder|Label|LabelId");
|
2026-03-18 12:10:52 -05:00 | | |
|
| | | //---
|
| | | for(int i = 0; i < size; i++)
|
| | | {
|
| | | if(!filter || (arr[i].state == AIEXECUTOR_TASK_STATE_IN_PROCESS
|
| | | || arr[i].state == AIEXECUTOR_TASK_STATE_IN_QUEQE
|
| | | || arr[i].state == AIEXECUTOR_TASK_STATE_PENDIENTE))
|
| | | FileWrite(fh, arr[i].ToStringFile());
|
| | | }
|
| | |
|
| | | //---
|
| | | FileClose(fh);
|
| | | return true;
|
| | | }
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | bool CTaskSaver::Load(const string &file_name, TaskTester& arr[], int& size, int file_common, string& msg)
|
| | | {
|
| | | //---
|
2026-03-31 13:12:02 -05:00 | | | if(FileIsExist(file_name, file_common))
|
2026-03-18 12:10:52 -05:00 | | | {
|
| | | //---
|
| | | ::ResetLastError();
|
| | | const int fh = FileOpen(file_name, FILE_READ | FILE_CSV | file_common);
|
| | | if(fh == INVALID_HANDLE)
|
| | | {
|
| | | msg = (StringFormat("Fallo al abrir el archivo = %s, ultimo error = %d", file_name, ::GetLastError()));
|
| | | return false;
|
| | | }
|
| | |
|
| | | //---
|
| | | FileReadString(fh); // Cabezera
|
| | |
|
| | | //---
|
| | | size = ArrayResize(arr, 0);
|
| | |
|
| | | //---
|
| | | string arr_str[8];
|
2026-03-25 15:17:13 -05:00 | | | while(!FileIsEnding(fh))
|
2026-03-18 12:10:52 -05:00 | | | {
|
2026-03-31 13:01:36 -05:00 | | | if(StringSplit(FileReadString(fh), '|', arr_str) != 8)
|
2026-03-18 12:10:52 -05:00 | | | {
|
| | | LogWarning("Linea invalida omitida", FUNCION_ACTUAL);
|
| | | continue;
|
| | | }
|
| | |
|
| | | //---
|
| | | static TaskTester task;
|
| | | task.Assing(arr_str);
|
| | |
|
| | | //---
|
2026-03-31 13:12:02 -05:00 | | | // Quizas no hague falta?¿
|
| | | //if(task.state == AIEXECUTOR_TASK_STATE_FINISHED || task.state == AIEXECUTOR_TASK_STATE_FAILED)
|
| | | // continue;
|
2026-03-18 12:10:52 -05:00 | | |
|
| | | //---
|
| | | arr[ArrayResize(arr, (++size)) - 1] = task;
|
| | | }
|
| | |
|
| | |
|
| | | //---
|
| | | FileClose(fh);
|
| | | }
|
| | | else
|
| | | {
|
| | | LogWarning("No se enocnrro un archivo del cual cargar", FUNCION_ACTUAL);
|
| | | }
|
| | |
|
| | |
|
| | | //---
|
| | | return true;
|
| | | }
|
| | |
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | /*
|
| | | ExpertPath=ICTRaptor.ex5
|
| | | MainFolder=ICTKiller\\
|
| | | TemporalFIleName=none
|
| | | MoveFilesName=pred.csv,sl.csv,tp.csv,scaler_tp.csv,scaler_sl.csv,scaler_pred.csv
|
| | |
|
| | | */
|
| | |
|
| | | /*
|
| | | Timeframe,Symbol,SetFile,SymbolFolderName,Label,LabelId,StartDate,EndDate
|
| | | 1,XAUUSD,ICTKiller\\XAUUSD\\M1\\Best\\data.set,XAUUSD,Best,0,2025.01.01 10:10:10,2026.01.01
|
| | | */
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | #endif // AIDATATASKRUNNER_BACKEND_BASES_SAVER_MQH
|