Reading indicator buffers set to chart - page 2

 
Yuriy Asaulenko:
It is strange. I read somewhere in the help that if an indicator is already running, no copy is created. I do not understand it.

I must have misunderstood something. I checked this hypothesis, made an indicator with two buffers, one is filled from OnCalculate() and the other from OnTimer(), script, Expert Advisor... I used iCustom() to print the value of the buffer filled in OnCalculate() and empty value is deduced from OnTimer(). At the same time the indicator is in the chart where I place the script or EA.

Conclusion: when calling the indicator by iCustom(), the OnTimer() event is not executed in the indicator.

Maybe this is the reason why it is written in documentation

Function OnTimer() is called when an event occurs Timer, which is generated by the system timer only for Expert Advisors and indicators - you can not use it in scripts.

And it doesn't mention indicators in any way.

Apparently, there are some useful undocumented features in mql, as well as undocumented complications...

События клиентского терминала - Программы MQL4 - Справочник MQL4
События клиентского терминала - Программы MQL4 - Справочник MQL4
  • docs.mql4.com
События клиентского терминала - Программы MQL4 - Справочник MQL4
 
comp:

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?

It can be read and written and DLL is not needed.
 
pako:
Reads and writes and does not need a DLL
Well, where is an example?
 
Alexey Viktorov:
Well, where is the example?
Where is the indicator?
 
comp:

Unfortunately, in this case

is not going to help.

Why won't it help?
 
pako:
Where is the indicator?
Dmitry Fedoseev:
Why doesn't it help?

Subject:

#property strict

#property indicator_separate_window
#property indicator_buffers 1
#property  indicator_type1 DRAW_LINE
#property  indicator_color1 clrRed

#define  PAUSE 100

input double EMA = 0.1;      // Коэффициент экспоненциального сглаживания
input int Amount = 100;      // Сколько раз применить до "сброса"

double Buffer[];

int OnCalculate( const int rates_total,
                 const int prev_calculated,
                 const datetime &time[],
                 const double &open[],
                 const double &high[],
                 const double &low[],
                 const double &close[],
                 const long &tick_volume[],
                 const long &volume[],
                 const int &spread[] )
{
  return(rates_total);
}

void OnInit( void )
{
  SetIndexBuffer(0, Buffer);

  EventSetMillisecondTimer(PAUSE);

  return;
}

void OnDeinit( const int reason )
{
  EventKillTimer();

  return;
}

void SetBuffer( const bool Random )
{
  const int Size = ArraySize(Buffer);

  if (Random)
  {
    MathSrand((int)TimeLocal());

    for (int i = 0; i < Size; i++)
      Buffer[i] = MathRand();
  }
  else
    for (int i = 1; i < Size; i++)
      Buffer[i] += (Buffer[i - 1] - Buffer[i]) * EMA;

  return;
}

void OnTimer( void )
{
  static int Count = 0;

  SetBuffer(Count % Amount == 0);
  ChartRedraw();

  Count++;

  return;
}
 
Yuriy Asaulenko:
Strange. I read somewhere in the help that if the indicator is already running, a copy is not created. Maybe I'm missing something.

Recently I posted an indicator, it just displays a text string. And when calling it through iCustom the indicator lines on the chart and iCustom interfered with each other, I had to make only one output programmatically.

Maybe, a copy of the code is not created in the memory, but the recalculation goes with its parameters

https://www.mql5.com/ru/code/14737/83151#!tab=code

 
comp:

Subject:

So what?
 
Alexey Volchanskiy:

Recently I posted an indicator, it just displays a text string. And when calling it through iCustom the indicator lines on the chart and iCustom interfered with each other, I had to make only one output programmatically.

Maybe, a copy of the code is not created in the memory, but the recalculation goes with its parametersCopy

https://www.mql5.com/ru/code/14737/83151#!tab=code

A copy of the code cannot not be created because it is a dynamic load.
 
Алексей Тарабанов:
The code copy can't not be created, because it's a dynamic load.

Verbal assertion, or are you an MQ developer? :))

Although, I think so myself, by analogy with DLL, where program code is in one instance, and data instances are created for clients.

In short, the practical point is that if there is an index on a chart, iCustom takes data not from it, but from a separately created instance.

Reason: