How can I share an object between indicator and EA? - page 2

 
codeidea:
indicator create the object , let EA to use it.

Of course you can, as long as you know the name of the object, or as long as it is the only object in the chart of any given type.

You just have to read the price property using ObjectGetDouble().

 
angevoyageur:

mql5 is not general language as delphi or c++. It's intended for trading program.

Anyway, why don't you reply to question if you need help ? I can't see a good reason to share an object, so I repeat my question : why do you need to use it in your EA ?

why do you need to use it in your EA ?

if I create a wave object by the indicator, and let EA use this wave object.

the define like this:

struct APoint
  {
   double            price;
   datetime          time;
   int               Bar_ID;
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class AWave :public CObject
  {
public:
   APoint            A;
   APoint            B;
   APoint            C;
   APoint            D;
   ABCD_TREND        Dir;
   short             GroupId;
  };

 
codeidea:

why do you need to use it in your EA ?

if I create a wave object by the indicator, and let EA use this wave object.

the define like this:

struct APoint
  {
   double            price;
   datetime          time;
   int               Bar_ID;
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
class AWave :public CObject
  {
public:
   APoint            A;
   APoint            B;
   APoint            C;
   APoint            D;
   ABCD_TREND        Dir;
   short             GroupId;
  };

graphical objects? I think you can as long as you know the object name?
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Properties - Documentation on MQL5
 
doshur:
graphical objects? I think you can as long as you know the object name?
yes, I know the object name, it is stored in a LIST,   how to let EA know and use it?
 
doshur:
graphical objects? I think you can as long as you know the object name?

you are talking about chart Objects rather than . . .

codeidea:
yes, I know the object name, it is stored in a LIST,   how to let EA know and use it?

objects in terms of Object Oriented programming . . . 

If you want to communicate efficiently be very clear about your terms especially where there is scope for misunderstanding,  i.e.  Objects vs objects,  Global variables vs globally declared variables, etc.

 
RaptorUK:

you are talking about chart Objects rather than . . .

objects in terms of Object Oriented programming . . . 

If you want to communicate efficiently be very clear about your terms especially where there is scope for misunderstanding,  i.e.  Objects vs objects,  Global variables vs globally declared variables, etc.

easy to understand:


I define this variabl in indicator:

string abc='ddddddd';

How to let EA use it?

 

It's not easy for an EA and an Indicator to share the in-memory object (instance of a complex type).

You'll have to use some workaround, for example:

1. The indicator writes object's information to a file and the EA read info from the file. Or

2. The indicator writes objects' information to an indicator buffer and EA read info from that buffer. This approach could be more complex.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Indicators Lines
Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Indicators Lines
  • www.mql5.com
Standard Constants, Enumerations and Structures / Indicator Constants / Indicators Lines - Documentation on MQL5
 
forex2start:

It's not easy for an EA and an Indicator to share the in-memory object (instance of a complex type).

You'll have to use some workaround, for example:

1. The indicator writes object's information to a file and the EA read info from the file. Or

2. The indicator writes objects' information to an indicator buffer and EA read info from that buffer. This approach could be more complex.

Yes, I think these 2 ways is one choice.thanks
 

Maybe you can make export function in indicator there that creates the wave object and the passes the pointer (descriptor) of this object to the EA for its use.

Good luck.

 
Candles:

Maybe you can make export function in indicator there that creates the wave object and the passes the pointer (descriptor) of this object to the EA for its use.

Good luck.

thanks candles, it is really an easy way.
Reason: