How to access data arrays of a custom indicator from inside the EA?

 

Hello all,

I want to access data arrays of my custom indicator and write these data to a file for analysis.

The data array in the custom indicator is like:

//--- indicator buffers
double         profit[];

and within my EA, I want to get values of profit[] as well as its size ( ie. ArraySize(profit)  ).

Any help is sincerely appreciated.  :)

 
Shui Wang:

Hello all,

I want to access data arrays of my custom indicator and write these data to a file for analysis.

The data array in the custom indicator is like:

and within my EA, I want to get values of profit[] as well as its size ( ie. ArraySize(profit)  ).

Any help is sincerely appreciated.  :)


Just add required array to output buffers and retrieve this data as other data from indicators
 
Georgiy Liashchenko:

Just add required array to output buffers and retrieve this data as other data from indicators


Thanks for you kindly reply!

Although I'm not sure if I get your idea correctly, but I think you meant it should be done like this:

1. SetIndexBuffer() to set the array as an index buffer

2. SetIndexStyle() as DRAW_NONE

3.access its value with iCustom

the catch is: I don't know the array size, and I can't determine the start & end point of the data series that will be saved to file.

 
Shui Wang:


Thanks for you kindly reply!

Although I'm not sure if I get your idea correctly, but I think you meant it should be done like this:

1. SetIndexBuffer() to set the array as an index buffer

2. SetIndexStyle() as DRAW_NONE

3.access its value with iCustom

the catch is: I don't know the array size, and I can't determine the start & end point of the data series that will be saved to file.

Exactly. Array cannot go above total bars. Use this as a start point for calculation
 

New approach in MQL5:

1. get the handle of the custom indicator (using iCustom())

2. get the indicator value using CopyBuffer(); 


I might want to use ArraySetAsSeries() to set the destination buffer of CopyBuffer as "time series", this way I can access the buffer the same way I access the System defined indicators.

Reason: