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

 
fxsaber:

It turns out that Services will have almost all On-functions: OnInit, OnDeinit, OnTick(string),OnTimer,OnTrade,OnTradeTransaction, OnTester, OnTesterInit, OnTesterPass, OnTesterDeinit, OnBookEvent, OnChartEvent(long ChartID, ...), OnCalculate, ...


And if you don't need indicator buffers and don't want to face the crutches of indicators/advisors, write in a new type of program - Services - that doesn't suffer from (stretching from the previous versions of MT) limitations.

Exactly.

There will be no OnCalculate.

No solution with OnChartEvent yet

 
Slawa:

That's right.

These crutches must be annoying for many people

Forum on trading, automated trading systems and testing trading strategies

I can't get indicator data from high TF

Sergey Dzyublik, 2017.04.14 10:55

The user had an indicator that measured the "strength" of the market.
The indicator worked on the current timeframe and currency pair.

The task was to show the results of 8 popular currencies on one chart with an opportunity of selecting an independent TF to be displayed.
It does not matter what TF the user is in - it should show the results from the one that has been set in parameters.

The problem of loading traffic from other currencies by the required TF was solved with the following crutch:

   for (int i = ArraySize(symbols_load) - 1; i >= 0; --i){
      int counter = 0;
      int max_count = 10;
      while(counter < max_count){
         RefreshRates();
         double tmp_arr[];
         int res = CopyClose(symbols_load[i] + Suffix, int(TF), 0, 3, tmp_arr);
         if (res == 3)
            break;
         RefreshRates();
         ++counter;
      }
   }

where:

symbols_load- list of currencies needed to load
Suffix- possible prefix to the name of currency pairs
TF- required time frame

Is it possible to add a subscription/subscription to historical data (bars and ticks) for a given volume? So that there would always be a cache (of fresh bars and ticks) of a certain size at the Service for the given symbols.


How much easier it would be then to write, for example, market screens.

 
Slawa:

Indicators should be used for their intended purpose.

In other words, the sequence of OnInit and OnDeinit indicator's execution when changing thechart symbol-period should not bother anyone

This approach explains a lot.

So, we should accept it as it is, the main thing is to be aware of it.

 
Slawa:

No.

Read again what the indicators are. Akelis. Colby. Ask Yandex what market indicators are.

In MT3 when we introduced the concept of custom indicators we allowed to operate with objects on charts because there were only 2 indicator buffers.

Let's make a little history. At first there was FXCharts, I didn't catch it as I joined the company only in October 2002. Then there was MetaTrader. I joined the company to develop MQL II (FXCharts already had a trading strategies language). When we did MQL II and EAs, we changed the name to MetaTrader 2. When we allowed to write custom indicators, MetaTrader 3 became MetaTrader 3.

Then came MetaTrader 4 and MQL4. Custom indicators got the opportunity to operate with 8 indicator buffers. The possibility of working with objects on the chart was retained. But as the indicators were calculated in the interface thread, there were few people who abused the work with the objects.

And now we have MT5. The architecture is completely different, but we are hostages of MT4 in terms of abilities to operate with graphical objects on the chart. Yes, we are stakhanovites, we also added, as heroes, almost unlimited possibilities of chart management from indicators. We have arrived. The illustration - 16 pages of discussions about nothing.

Let's move on to services

The Services folder has appeared in the MQL5 Editor, but it is not yet clear how to use this tool. https://www.mql5.com/ru/forum/190129


Services , новый функциона в архитеркуте MT5, похороны MT4 не за горой.
Services , новый функциона в архитеркуте MT5, похороны MT4 не за горой.
  • www.mql5.com
Хотелось бы подробней с примерами использования обсудить новый функционал...
 
Slawa:

Indicators should be used for their intended purpose.

In other words, the sequence of OnInit and OnDeinit of the indicator when changing the symbol-period ofthe chart should not bother anyone

And why all the arguments have moved to the graphical objects? There are other global resources like global variables, files, etc. (can they be used in indicators according to their purpose?) that will be the source of errors, if"the order of OnInit and OnDeinit execution of the indicator at the change of thechart symbol-period shouldn't bother anyone". Once again, note that the kernel is now implemented in such a way that the order should worry the MQL programmer, to avoid the rake caused by the uncertainty of the sequence of OnInit/Deinit calls. In order not to worry MQL, you need a kernel that internally takes care of resolving the uncertainty.
 
Stanislav Korotky:
Why does the whole argument fall on graphical objects? There are other global resources like global variables, files, etc. (can they be used in indicators? (can they be used in indicators according to their purpose?) that will be the source of errors, if"the order of OnInit and OnDeinit execution of the indicator at the change of thechart symbol-period will not bother anyone". Once again, note that the kernel is now implemented in such a way that the order should worry the MQL-programmer, to avoid the rake caused by the uncertainty of the sequence of OnInit/Deinit calls. In order not to worry MQL, you need a kernel that internally takes care of resolving the uncertainty.
Here's a good question about files. If something needs to be reset on deinitialisation and read on subsequent initialisation, there could be some problems.
 
Stanislav Korotky:

How can Services or the ability to run multiple EAs on a single chart not completely cover the problems we are discussing?

Imagine that instead of the indicators mentioned in the thread, there would be a Service running which would contain a fully calculated part of the indicator. And it will put the indicator on the chart that will visualize the data, calculated by the Service in indicator buffers.


Indicators should be used according to their intended purpose and not make something universal out of them, just because there are several indicators to be launched in one chart. This way you can start complaining about the ban of OrderSend in indicators.

 
fxsaber:

How can Services or the ability to run multiple EAs on a single chart not completely cover the problems we are discussing?

Imagine that instead of the indicators mentioned in the thread, there would be a Service running which would contain a fully calculated part of the indicator. And it will put the indicator on the chart, which will visualize the data calculated by the Service in indicator buffers.

I.e. will it be possible to create an indicator through the Service?
 
Alexey Kozitsyn:
I.e. will it be possible to create an indicator through the service?
This is already possible from an EA (with some limitations).
 
fxsaber:
This is still possible from the EA (with some limitations).
You mean using crutches? Can I give you an example?
Reason: