Reading indicator buffers set to chart

 

An indicator is placed on the chart. It is redrawn by Timer, ChartEvent and Calculate events.

I need a script to read the current values of its indicator buffers(INDICATOR_DATA) which can be seen by CTRL+D. Is it possible to do this in MT4?

 

The solution via DLL is given in the article"Data transfer between indicators - a simple solution of this problem". But you have to add the call of externalGetPtr to the indicator source code, which is not always possible.

Without DLL is it possible to perform only reading (without writing, which is also done in the article) of buffers? Has anything changed on this topic since the time the article was written (2010)?

 
iCustom() will help.
iCustom - Технические индикаторы - Справочник MQL4
iCustom - Технические индикаторы - Справочник MQL4
  • docs.mql4.com
iCustom - Технические индикаторы - Справочник MQL4
 
Alexey Viktorov:
iCustom() will help.

Unfortunately, in this case

redraw by Timer, ChartEvent and Calculateevents.

will not help.

 
How many values do you need? Let the indicator itself save duplicates of these values in the global variables of the terminal, in the properties of objects on the chart, in the files
 
Alexander Puzanov:
How many values do you need? Let the indicator itself save the duplicates of these values in global variables of the terminal, in properties of objects in the chart, in files

I need a script to get the values of buffers (at least one) of an indicator on a chart. Dumping buffers from an indicator to a file is not a script reading buffers.

In the article above, there is a nice solution via pointers that allows you to not only read, but even overwrite the buffers of other indicators on the charts. This is what is called a buffer read. But it is a DLL.

You see, we can implement the following scheme

  • the indicator waits for a global variable to write its buffers to the file.
  • The script creates such variable at runtime and receives the corresponding files.
But this is not even a crutch. It's not reading buffers.

Judging by the silence, more than seven years since this problem was announced publicly on the fourth forum (google remembers), the developers have not created a functional.

For some reason they still can't do a human readout of the indicator data from the chart! Sounds delusional, but it is.

 
comp:

Unfortunately, in this case

is not going to help.

Why not? iCustom() reads the indicator buffer regardless of how this buffer is filled. After all, the buffer is declared at the level of global variables in any case.
 
Alexey Viktorov:
Why not? iCustom() reads the indicator buffer, regardless of how this buffer is filled. After all, the buffer is declared at the level of global variables in any case.

Because iCustom knows nothing about Timer and ChartEvent events.

For example, the indicator on the chart every second (Timer event) fills its only buffer with random numbers (or applies EMA to previous buffer values). This is quite a few lines of code. iCustom in this case will never return what you will see on the chart.

 
comp:

Because iCustom knows nothing about Timer and ChartEvent events.

For example, the indicator on the chart every second (Timer event) fills its only buffer with random numbers (or applies EMA to previous buffer values). This is quite a few lines of code. iCustom will then never return what you will see on the chart.

I understand my misconception, thank you.
 
Alexey Viktorov:
Why not? iCustom() reads the indicator buffer, regardless of how this buffer is filled. After all, the buffer is declared at the level of global variables in any case.

iCustom doesn't read buffers from the indicator on the chart, it creates its own copy of the indicator in the memory and reads from it, just the buffer copies are not displayed on the chart. But if the indicator draws something on the chart independently, it will be drawn when called via iCustom that creates problems, by the way

For example, if the indicator has the following code, it will be drawn when calling iCustom, and the text will overlay the text of the indicator on the chart

ObjectSetString(0, ShortName, OBJPROP_TEXT, "какой-то текст");
ChartRedraw();
 
Alexey Volchanskiy:

iCustom doesn't read buffers from the indicator on the chart, it creates its own copy of the indicator in the memory and reads from it, just the buffer copies are not displayed on the chart. But if the indicator draws something on the chart independently, it will be drawn when called via iCustom that creates problems, by the way

For example, if the indicator has the following code, it will be drawn when calling iCustom, and the text will overlay the text of the indicator on the chart

It is strange. I have read somewhere in the guide that if the indicator is already launched, no copy is created. Maybe I don't understand something.
Reason: