Errors, bugs, questions - page 1124

 
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
  struct ARGB
  {
    uchar blue;
    uchar green;
    uchar red;
    uchar alpha;
  };
  
  struct N
  {
    uint num;
  };
  
  N n={100288};
  ARGB c;
  c=n;         //так получаем предупреждение implicit struct cast       sample.mq5      22      4
  c=(ARGB)n;   //а так всё в порядке
}
Although both structures are the same size and copy into each other without loss, we still get a warning.
 
Fleder:
Although both structures are the same size and copy into each other without loss, we still get a warning.
Well, that's great. It's not so hard to make an explicit cast. But it's not so pleasant to try to figure out what has been assigned when bugs occur.
 
TheXpert:
So that's great. It's not that hard to make an obvious caste. And figuring out where to assign what when bugs start to creep in isn't very pleasant.
Looks like the compiler's motto: "Better safe than sorry!"
 

Copy from application to SR:

Ability to self-unload time series from RAM back to *.hc cache
Errors, MetaTrader 5 MQL, Opened, Started: 2014.04.12 06:04, #995430

Terminal version and bit

910 32 bit

Problem description

Hello, dear developers!

In MQL5 a number of system functions such asCopyRates,CopyTime,CopyOpen, etc. are intended to receive time series data.

When you call any of these functions, the requested timeseries is loaded to RAM within the "Max bars in chart" parameter.

However, the combination of factors such as:

1. Sufficiently deep history available on the symbol or fully loaded from the server.

2. Max bars in chart" parameter is "Unlimited".

3. Data of the smallest timeframe M1 is requested.

A very large amount of memory is being consumed.

The problem is exacerbated by the fact that the logic of the program running MQL5 (for example, if it is a multicurrency Expert Advisor or an indicator)

may be laid down for alternate access to data of low-level timeframes of several symbols (for example, single search).

As a result, RAM consumption increases many times over.

Получение данных нужного таймфрейма из промежуточных данных

Service files in the HCC format play the role of the data source for building the price data by the requested timeframes in the HC format. The data in the HC format are timeseries that are maximally prepared for quick access. They are created only at requests of a chart or mql5-program in the volume not exceeding the "Max bars in charts" parameter, and are saved for further use in files with the hc extension.

To save resources, the data on the timeframe are loaded and stored in the RAM only when required.In case of long absence of requests the data are unloaded from the RAM saving them into a file. Data for each timeframe are prepared independently from the ready data for other timeframes. The rules for data preparation and availability are the same for all timeframes. I.e., despite the fact that the unit of data storing in the HCC format is the minute bar, the availability of the data in the HCC format does not mean the availability and accessibility of the HC format data for the M1 timeframe in the same volume.

Receipt of new data from the server causes automatic updating of used price data in HC format for all timeframes and recalculation of all indicators, which explicitly use them as input data for calculation.

The timing of the process highlighted in yellow on the cited quote from the documentation is quite large: about half an hour (from my observations).

As a result, all the requested timeseries are "sitting" in "RAM" for no reason at all.

If the "RAM" is not "rubber And the "voracious" Expert Advisor/indicator demands more and more timeseries, the terminal has nothing else to do

except for an urgent "dumping" of excess timeseries back to the file (cache). So, in this emergency reset, the terminal may reset the timeseries to

a "broken cache", i.e. it will lose "a good half" of the data. And the next time this timeseries is accessed, the terminal loads this "broken cache" as a normal one.

As a result, the terminal chart displays the needed timeseries with a huge hole in the history.

Expected result

The MQL5 language tends to save resources of the execution environment. An example of this is as follows:

1. theArrayFree function

2.resourceFree function

3.delete operator

4. Max bars in charts" parameter

Is it possible to add a system function to the MQL5 language functionality that would force the terminal to perform operations with the timeseries no longer being used?

If there is no opened chart with this time series, at the end of the timing?

For example, a function:

bool SeriesFlush(
   string           symbol_name,       // имя символа
   ENUM_TIMEFRAMES  timeframe,         // период
   );

This would allow:

1. not worry about RAM overflow.

2. do not worry about "broken caches" that you can get rid of only by manually deleting *.hc files when the terminal is switched off.

3. You don't have to depend on the bit mode of your operating system and the size of RAM.

4. When developing a software product, do not use "crutches" that try to bypass the disadvantages described above.

 
Fleder:

Copy from application to SR:

Possibility to self-unload timeseries from RAM back to *.hc cache
Why, that's a great idea.
 
Can you tell me how to get data from an indicator that has a positive bias? I'm interested in data on -1 bar?
 
dentraf:
Can you tell me how to get indicator data with a positive offset? I am interested in data on -1 bar?

To do this you need to know the offset settings for the indicator line of interest. This is an example from theiAlligator technical indicator

//--- зададим смещение для каждой линии
   PlotIndexSetInteger(0,PLOT_SHIFT,jaw_shift);

This is an offset, not an indicator calculation for the future.

 

Copy from application to SD:

Incorrect operation of the IsStopped system function in indicators
Errors, MetaTrader 5 MQL, Opened, Started: 2014.04.12 07:59, #995480

Terminal version and bit mode

910 32 bit

Problem description

Hello, dear developers!

One of the recommendations to improve code quality when designing loops with a large number of iterations

is to embed verification of a forced stop of an MQL5 program using the system

IsStopped() system function;

However, in practice, this check doesn't work in indicators (it does in scripts and Expert Advisors)

Here is the indicator short code that shows the essence of the problem:

#property  indicator_plots 0
//=====================================================================
// Custom indicator initialization function
//=====================================================================
int OnInit()
{
  return(INIT_SUCCEEDED);
}
//=====================================================================
// Custom indicator iteration function
//=====================================================================
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[])
{
  long n=0;
  for(int i=0;i<1 e+10 && !IsStopped();i++) {n++;}
  Print("OnCalculate End");
  return(rates_total);
}

If you try to remove this indicator from the chart, the process of "calculating the indicator" will not stop as such,

though it should, because of the check of the stop flag of the program.

You can easily find this out by monitoring the terminal.exe process in Task Manager. On a quad core processor

it's about 25% of CPU load. Also, terminal load doesn't decrease at all over time until the

terminal shutdown. And even after terminal shutdown terminal.exe process still hangs in manager. And, it feels like,

that it is unloaded by the operating system as "hanging".


Expected result

Please, fix this problem.

 
barabashkakvn:

To do this you need to know the offset settings for the indicator line of interest. This is an example from theiAlligator technical indicator

This is an offset, not the calculation of the indicator for the future.

I have a future calculation, but I use an offset to render it, how do I calculate -1 bar from the Expert Advisor?

If someone needs it, use CopyBuffer(Handle_original,0,-2,10,Data_Ind )

 
dentraf:
Exactly, I have a calculation in the future, but to draw an offset, how do I read -1 bar from the Expert Advisor?
There is no quote for -1 bar. The offset is: the calculation for a bar that exists (e.g. bar number 2) and then this calculated value is plotted on bar 2 minus the offset. That is, if the offset is 5, the value calculated on bar 2 is drawn on bar "-3".
Reason: