You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The same error still got thrown even after I made that change, sorry.
Download each file separately from the Russian version of the codebase.
Hello,
Please help me, I am stuck on one point. I made 2 EAs, one saves data, the other reads it. I have a problem with resource discovery.
This code saves the data and from it I can access it and read it:
#include "ResourceData.mqh" // https://www.mql5.com/en/code/22166
#define PRINT(A) Print(#A + " = " + (string)(A));
struct ExampleStruct
{
string ea_name;
string symbol;
string direction;
string time_for_command;
};
ExampleStruct qexamplestruct[2];
int OnInit(void)
{
EventSetTimer(1);
return(INIT_SUCCEEDED);
}
void OnTimer()
{
// Произвольные данные для примера
string Str[] = {"123", "Hello World!"};
qexamplestruct[0].direction="buy";
qexamplestruct[0].ea_name="TestEAname";
qexamplestruct[0].symbol="EURUSD";
qexamplestruct[0].time_for_command="01.01.2021";
string stringtosend = Serialize(qexamplestruct[0]);
const RESOURCEDATA<uint> Resource("::ResoC"); // Ресурс для обмена данными
CONTAINER<uint> Container; // Создаем контейнер - все будет храниться в массиве простого типа (в примере выбран uint)
Container[0] = Str;
Container[1] = stringtosend;
const string NameOut = StringSubstr(MQLInfoString(MQL_PROGRAM_PATH), StringLen(TerminalInfoString(TERMINAL_PATH)) + 5) + "::ResoC";
Print(NameOut); // Вывели полное имя ресурса.
Resource = Container.Data; // Отправили данные на обмен
//---
}
string Serialize(const ExampleStruct &s)
{
return s.ea_name + "\n" + s.symbol + "\n" + s.direction + "\n" + s.time_for_command;
}
ExampleStruct Deserialize(const string &line)
{
string parts[];
StringSplit(line, '\n', parts);
ExampleStruct s;
if(ArraySize(parts) > 0) s.ea_name = parts[0];
if(ArraySize(parts) > 1) s.symbol = parts[1];
if(ArraySize(parts) > 2) s.direction = parts[2];
if(ArraySize(parts) > 3) s.time_for_command = parts[3];
return s;
}
And this code reads the data and every time writes that there is nothing:
#include "ResourceData.mqh" // https://www.mql5.com/en/code/22166
#define PRINT(A) Print(#A + " = " + (string)(A));
int OnInit(void){return(INIT_SUCCEEDED);}
void OnTick()
{
const RESOURCEDATA<uint> Resource("\Terminal\99A739E3DB06068691C851DE1765F329\MQL5\Experts\ZC\Conections\Draft4.ex5::ResoC"); // Ресурс для доступа к данным (только для чтения) из другой программы
CONTAINER<uint> Container4; // Сюда будем получать данные
Resource.Get(Container4.Data); // Считали данные из ресурса.
for (int i = 0; i < Container4.GetAmount(); i++)
Print("i==",i);
string Str4;
Container4[0].Get(Str4); // Получили массив
Print("Test!!!"+Str4);
Print(Str4);
//---
}
I seem to be doing everything by analogy, but for some reason I don't see any information from the one I wrote, neither an array of string type, nor a single string that I get from my structure
I seem to do everything by analogy, but for some reason no information is displayed from the one I wrote, neither an array of string type, nor a single string that I get from my structure.
I haven't run it, but I assume that this is the case.
Try it this way.
Haven't run it, but I'm assuming that' s the case.
Try this for yourself.
Hello, thank you for writing
Tried it straight away, as it has been written about here before. I went through the options of fixing both in the name to address, also corrected in "ResourceData.mqh". Unfortunately did not help. I have not found the cause yet
I've made some more progress -
When using ResourceReadImage(FullNameCorrect,Arr,width,height)) directly, I can accept data from a resource created by another EA, everything works correctly. When accessing the same resource name via library functions (similar to the one attached above) - the data is not accepted.
I will report further when I find what the problem was.
I'm creating a resource:
a - through the library
b - manually (ResourceCreate)
I access the resource data from another EA using the same resource name:
a - through the library
b - manually(ResourceReadImage)
Result:
The resource created through the library is not found either manually or through the library
A resource created manually is found and read manually, but is not found through the library.
A resource created through the library is not found either manually or through the library
A manually created resource is located and read manually, but is not located through the library.
It works through the library.
I don't know why your original example doesn't work yet.
Why your original example doesn't work - I don't know yet.
If everything else is correctly written, it will help.
Forum on trading, automated trading systems and testing trading strategies.
Libraries: TradeTransactions
Alexander, 2025.09.15 21:09
You created an object on each input to OnTimer and, accordingly, killed it - on the output. Therefore, the resource lived for microseconds and was not on the side.
static
What an obvious point, which I looked past for 2 days without noticing it)
Thank you very much!
Everything works perfectly, the ability to exchange custom structures between algorithms using your library is a huge help for my trading, hats off to you!