Hello,
I'd like to create a script global object, like a singleton, which is only created once but available across all ExpertAdvisors.
Say, new myClass : public CObject...
Then use a pointer to the only instance of this object in all ExpertAdvisor.
I tried to accomplish this by a DLL. Unfortunately, unfortunately, MQL5 seems not to allow to pass pointers to DLL (where i could save this pointer).
Also, it seems not to be possible to cast a pointer into a long (or int), to save it as integer type.
Is this possible at all ? Anyone has an idea ?
Thank you
In my opinion you have to create this singleton in your DLL, then access it from each EA. I don't think there is a way to create it with mql5 and access it from mql5 in other thread. Not sure though.
Thank you angevoyageur.
It seems. My hope was to create this object in MQL5, save pointer in DLL, access this pointer in other Experts by getting it from DLL.
This way i could stay in MQL5.
GetPointer(instance) returns a CObject*. But it seems you can't pass this pointer to a DLL function. You get a compiler error.
Thank you angevoyageur.
It seems. My hope was to create this object in MQL5, save pointer in DLL, access this pointer in other Experts by getting it from DLL.
This way i could stay in MQL5.
GetPointer(instance) returns a CObject*. But it seems you can't pass this pointer to a DLL function. You get a compiler error.
Yes, mql5 pointer aren't like C++ pointer, this is why I don't see a way to do what you want.
Again, unlike C++, the variable hobject from the example above is not a pointer to the memory, it is a descriptor of the object.
This article can give some ideas too.
- 2010.01.15
- Алексей
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I'd like to create a script global object, like a singleton, which is only created once but available across all ExpertAdvisors.
Say, new myClass : public CObject...
Then use a pointer to the only instance of this object in all ExpertAdvisor.
I tried to accomplish this by a DLL. Unfortunately, unfortunately, MQL5 seems not to allow to pass pointers to DLL (where i could save this pointer).
Also, it seems not to be possible to cast a pointer into a long (or int), to save it as integer type.
Is this possible at all ? Anyone has an idea ?
Thank you