Init() and DeInit() execution sequence - page 18

 
Alexey Kozitsyn:
I.e. using crutches? Can I give you an example?

You cannot add an indicator via ChartIndicatorAdd() to a chart that has a different symbol or TF. An error will be shown.

https://www.mql5.com/ru/docs/chart_operations/chartindicatoradd

ChartIndicatorAdd

Adds an indicator with the specified handle to the specified chart window.The indicator and the chart must be drawn on the same symbol and timeframe.

This is the restriction now. It will not be in Services.
Документация по MQL5: Операции с графиками / ChartIndicatorAdd
Документация по MQL5: Операции с графиками / ChartIndicatorAdd
  • www.mql5.com
Операции с графиками / ChartIndicatorAdd - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
A little tip of the hat, almost on the subject of subj.

Forum on trading, automated trading systems and trading strategy testing

Bugs, bugs, questions

fxsaber, 2016.09.23 10:48

  1. We set the indicator on a NONE chart with our hands
    #property indicator_separate_window
    #property indicator_buffers 1
    #property indicator_plots   1
    
    double Buffer[];
    
    int handle = INVALID_HANDLE;
    
    void OnInit()
    {
      ::SetIndexBuffer(0, Buffer, INDICATOR_DATA);
      
      handle = ChartIndicatorGet(0, 1, ChartIndicatorName(0, 1, 0));  
    }
    
    #define  TOSTRING(A) #A + " = " + (string)A + "\n"
    
    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[] )
    {
      if (handle != INVALID_HANDLE)
      {
        Buffer[rates_total - 1] = MathRand();
        
        double BufferCopy[];
        
        if (CopyBuffer(handle, 0, 0, 1, BufferCopy) > 0)
          Print(TOSTRING(BufferCopy[0]) + TOSTRING(Buffer[rates_total - 1]));
      }
      
      return(rates_total);
    }
  2. Removing the indicator from the chart by hand.
  3. In the log we see that the indicator continues to run. You can close all the charts in the terminal, but it will still be executing. And it won't help, of course,
    void OnDeinit( const int Reason )
    {
      if (handle != INVALID_HANDLE)  
        IndicatorRelease(handle);
      
      return;
    }
  4. Rebooting the terminal stops the execution of the indicator.
  5. How many indicators can be executed like this in idle, and we don't know anything about them! There is no control at all.
Without any complaint to the developers.
 
fxsaber:
This is a restriction now. It will not be in Services.

That's not what I was talking about at all. Not adding an indicator from an EA, but creating an indicator using an EA.

Regarding this:

Than Services or the ability to run multiple EAs on a single chart can't completely cover the trabs being discussed?

If there is no possibility to create indicators using services, the problem of creating an indicator with data from a file will not disappear. If the sequence OnDeinit() -> OnInit() is not controlled. The change of TF is a user action, and the response to this action (OnDeit()) will occur when this is not necessary (after OnInit() or maybe even following OnCalculate()?

That is, if the indicator records data into a file and plots a graph series based on this data, and the data is not written "consecutively", the correct display of all data will not occur.

But if the service was a global program (like GPT, but the whole program) and it could create indicator buffers, and the calculations were not interrupted by users actions like TFs change / chart closing - then the problem would not exist. But in the meantime, the indicators are castrated, as usual.

 
Alexey Kozitsyn:

That's not what I was talking about at all. Not adding an indicator from an EA, but creating an indicator using an EA.

I don't understand the terminology.

 
fxsaber:

I don't understand the terminology.

Calculating and displaying data with writing it in indicator buffers, not just displaying the data.
 
Slawa:

No solution to OnChartEvent yet

What do you mean, there is no solution? What kind of service would it be without the ability to access the mouse? And I'd like to handle user events as well.
 
Alexey Kozitsyn:
Calculation and displaying data with writing it in indicator buffers, not just displaying the data.

They complain that the data calculated by the indicator cannot be reliably and logically transferred to another copy of this indicator during the change of the TF.

This is easily done through Services if the Service will do the calculation part and the indicator will display it.

In all other cases, that do not fall under the highlighted in bold, you can continue to write the indicators as the classical ones.

 
fxsaber:

They complain that the data calculated by the indicator cannot be reliably and logically transferred to another copy of this indicator during the change of the TF.

This is easily done through Services, if the Service will do the calculation part and the indicator will display it.

In all other cases, which do not fall under the highlighted in bold, you can continue to write indicators in the classic way.

Ok, well, we'll see what we get. When will the beta be?
 
Alexey Kozitsyn:
OK, well, we'll see what happens. When's the beta?
If I give the go-ahead, it'll be tonight.
 
Nikolai Semko:
What do you mean, no solution? What kind of service would it be without the ability to access the mouse? And I'd like to handle user events, too.

No solution means "not yet known how to solve", not "won't"

And there's no problem at all with custom events

Reason: