Discussion of article "MQL5 Cookbook: Development of a Multi-Symbol Indicator to Analyze Price Divergence"
Is it just a typo or should it be?
No matter how many times I've tried, all the functions from the "Copy squad" never return zero, only -1 or >0.
//+------------------------------------------------------------------+ //| Checks the number of available data for all characters || //+------------------------------------------------------------------+ bool CheckAvailableData() { int attempts=100; //--- for(int s=0; s<SYMBOLS_COUNT; s++) { //--- If there is such a character if(symbol_names[s]!=empty_symbol) { datetime time[]; // Array to check the number of bars int total_period_bars =0; // Number of bars of the current period datetime terminal_first_date =NULL; // First date of available data of the current period in the terminal //--- Get the first date of the current period data in the terminal terminal_first_date=(datetime)SeriesInfoInteger(symbol_names[s],Period(),SERIES_TERMINAL_FIRSTDATE); //--- Get the number of available bars from the specified date total_period_bars=Bars(symbol_names[s],Period(),terminal_first_date,TimeCurrent()); //--- Check the readiness of these bars for(int i=0; i<attempts; i++) { //--- Copy the specified amount of data if(CopyTime(symbol_names[s],Period(),0,total_period_bars,time)) { //--- If the required amount is copied, stop the loop if(ArraySize(time)>=total_period_bars) break; } } //--- If less data is copied, then another attempt must be made. if(ArraySize(time)==0 || ArraySize(time)<total_period_bars) { msg_last=msg_prepare_data; ShowCanvasMessage(msg_prepare_data); OC_prev_calculated=0; return(false); } } } //--- If in vertical line mode for the starting point of price difference, exit if(StartPriceDivergence==VERTICAL_LINE) return(true); else { datetime time[]; // Array to check the number of bars int total_period_bars =0; // Number of bars of the current period datetime terminal_first_date =NULL; // First date of available data of the current period in the terminal //--- Get the first date of the current period data in the terminal for(int i=0; i<attempts; i++) if((terminal_first_date=(datetime)SeriesInfoInteger(Symbol(),Period(),SERIES_FIRSTDATE))>0) break; //--- Get the number of available bars from the specified date for(int i=0; i<attempts; i++) if((total_period_bars=(int)SeriesInfoInteger(Symbol(),timeframe_start_point,SERIES_BARS_COUNT))>0) break; //--- Check the readiness of these bars for(int i=0; i<attempts; i++) //--- Copy the specified amount of data if(CopyTime(Symbol(),timeframe_start_point, terminal_first_date+PeriodSeconds(timeframe_start_point),TimeCurrent(),time)>0) break; //--- If less data is copied, then another attempt must be made. if(ArraySize(time)<=0 || total_period_bars<=0) { msg_last=msg_prepare_data; ShowCanvasMessage(msg_prepare_data); OC_prev_calculated=0; return(false); } } //--- return(true); }
Is it just a typo or should it be?
No matter how many times I tried it, all the functions from the "Copy squad" never return zero, only -1 or >0.
In general, you should do >0. But in this case, subsequent checks allow you not to do it.
But this expression will always be true:
if(CopyTime(symbol_names[s],Period(),0,total_period_bars,time))
But this expression will always be true:
You could remove the if at all. In this case it is not critical.
In general, the loading of historical data on a symbol does not happen the way it is written in the help.
In fact, it turns out like this:
if from mql5 programme there is a request for data of some time series using, for example, function CopyTime
and this data is not in the terminal (not loaded yet), the terminal will download this data from the server not in the requested amount (in the help example it is 100 bars),
but as many bars of the required time series as the parameter "Max bars in chart" allows to "place" in RAM.
It is enough to request only one bar of a higher period, say PERIOD_W1, as the whole history will be downloaded from the server.
In general, the loading of historical data on a symbol does not happen the way it is written in the help.
In fact, it turns out like this:
if from mql5 programme there is a request for data of some time series using, for example, function CopyTime
and this data is not in the terminal (not loaded yet), the terminal will download this data from the server not in the requested amount (in the help example it is 100 bars),
but as many bars of the required time series as the parameter "Max bars in chart" allows to "place" in RAM.
It is enough to request only one bar of a higher period, say PERIOD_W1, andthe whole history will be downloaded from the server.
The help may say anything you want. You are free to do it as you see fit. ;)
The example from the help was discussed in another article: How to prepare MetaTrader 5 quotes for other programmes >>>.
The certificate can say anything you want it to say. You're free to do as you see fit. ;)
The example from the help was discussed in another article: How to prepare MetaTrader 5 quotes for other programmes >>>.
That's what I did. I just saw the calculation of the remaining "unloaded bars" from the server in your code.
And I thought - the terminal doesn't care, it pumps as much as it needs to form.
At the end of your article you wrote:"This indicator can be unlimitedly developed for the better".
In my opinion, contemplation of price divergence is of little use to the human eye. A human is not a robot!
But it is an interesting topic for a robot.
You have suggested several rendering options:
1. from the line.
2. "day."
I am currently working on something similar, only in "week" mode.
At the end of your article you wrote:"This indicator can be unlimitedly developed for the better".
In my opinion, contemplation of price divergence is of little use to the human eye. A human is not a robot!
But it is an interesting topic for a robot.
You have suggested several rendering options:
1. from the line.
2. "day."
I'm currently working on something similar, only in "week" mode.
I'm not sure if I'll be able to write anything else anytime soon, as I'm dealing with other issues. But according to this article the development was supposed to be still in multi-currency calculations and visualisation of these calculations on the canvas.
Yes, man is not a robot, but sometimes you need to look at the subject of study in some other way to get an idea. ;)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
New article MQL5 Cookbook: Development of a Multi-Symbol Indicator to Analyze Price Divergence has been published:
In this article, we will consider the development of a multi-symbol indicator to analyze price divergence in a specified period of time. The core topics have been already discussed in the previous article on the programming of multi-currency indicators MQL5 Cookbook: Developing a Multi-Symbol Volatility Indicator in MQL5. So this time we will dwell only on those new features and functions that have been changed dramatically. If you are new to the programming of multi-currency indicators, I recommend you to first read the previous article.
In this article we'll consider the following questions:
Author: Anatoli Kazharski