Historical Data of MqlRates

 
Hello everyone!

I searched the forum a little and didn't seem to find an answer to my question.

I use this code 

MqlRates rates[];

int copied = CopyRates(symbolTmp, PERIOD_H1, myTime, 24, rates);

double totalSpread = 0;
for(int i = 0; i < copied; i++) {
  totalSpread += rates[i].spread;
}
double averageSpread = totalSpread / copied;


So I am taking the data of H1 candles, starting at a time I want, taking the 24 last prices and taking the average spread.

My questions are.

Who determines the value of the data?

For example if we take the CurrentTime() as myTime on the M1 timeframe, the spread gives an average of 19 on GBPUSD, but it is clearly 24 if you watch the prices for a little bit. Why such a difference?

The spread changes 2-3 times a second if you watch it live. So the data given to a specific date, is , lets say a snapshot of the exact time? So it could be 18 or 25 at a few seconds change?

If a signal gave: myTime = 23:45:20, that means that we take the 23:00:00 as first candle, and go back 24 candles add the spread and take the average? That't how it works? 

I found out that at midnight the spread goes nuts, so taking the last 60 candles of M1 was not that good, that's why I take the last 24 Hours.

If anyone wants to know something more to clarify please ask.
If you have another approach to recommend, please do!
Thank you in advance!

 
Jordanelis:
Hello everyone!

I searched the forum a little and didn't seem to find an answer to my question.

I use this code 

MqlRates rates[];

int copied = CopyRates(symbolTmp, PERIOD_H1, myTime, 24, rates);

double totalSpread = 0;
for(int i = 0; i < copied; i++) {
  totalSpread += rates[i].spread;
}
double averageSpread = totalSpread / copied;


So I am taking the data of H1 candles, starting at a time I want, taking the 24 last prices and taking the average spread.

My questions are.

Who determines the value of the data?

For example if we take the CurrentTime() as myTime on the M1 timeframe, the spread gives an average of 19 on GBPUSD, but it is clearly 24 if you watch the prices for a little bit. Why such a difference?

The spread changes 2-3 times a second if you watch it live. So the data given to a specific date, is , lets say a snapshot of the exact time? So it could be 18 or 25 at a few seconds change?

If a signal gave: myTime = 23:45:20, that means that we take the 23:00:00 as first candle, and go back 24 candles add the spread and take the average? That't how it works? 

I found out that at midnight the spread goes nuts, so taking the last 60 candles of M1 was not that good, that's why I take the last 24 Hours.

If anyone wants to know something more to clarify please ask.
If you have another approach to recommend, please do!
Thank you in advance!

According to some tests users did the spread stored in rates is the minimum spread

Forum on trading, automated trading systems and testing trading strategies

Data for backtesting

Fernando Carreiro, 2022.12.21 21:09

The "spread" for bars is a timeseries as described in the documentation — Documentation on MQL5: Timeseries and Indicators Access

No official information is provided by MetaQuotes, but from tests done by a user here on the forum, the consensus is that it is the minimum spread of the bar.

Work with ticks if you are testing stuff.

Download tick history , construct your own rates and do your tests.

 
Lorentzos Roussos #:

According to some tests users did the spread stored in rates is the minimum spread

Work with ticks if you are testing stuff.

Download tick history , construct your own rates and do your tests.

Thank you very much! Ευχαριστώ!!
 
Jordanelis #:
Thank you very much! Ευχαριστώ!!

Parakalo (you are welcome)