CopySpread is not the same as ASK-BID... Am I missing something? - page 2

 

The spread in the rates is the minimal spread during the bar (it happened to be 0 in your case), not a specific tick's spread.

For reading indicator buffers it's advisable to use time-series ordering, so before accessing spread[0] you should call ArraySetAsSeries(spread, true). In your code you output a spread of most outdated bar.

 
Stanislav Korotky #:

The spread in the rates is the minimal spread during the bar (it happened to be 0 in your case), not a specific tick's spread.

Dear Stanislav,

Thank you so much for this explanation! Do you belong to the MetaQuotes team? I ask, because, if you are: could you please insert this information (this is the minimum spread, not the maximum or the average...) in the documentation, within the function specifications? I think this would facilitate life a lot when programming. And I could not find it elsewhere.

 
Fab #:

Dear Stanislav,

Thank you so much for this explanation! Do you belong to the MetaQuotes team? I ask, because, if you are: could you please insert this information (this is the minimum spread, not the maximum or the average...) in the documentation, within the function specifications? I think this would facilitate life a lot when programming. And I could not find it elsewhere.

No, I'm just a user. I'm not sure where this info is presented in the docs, but it is in the algotrading book.

As an example, let's try to obtain a more or less realistic estimate of the spread size for each bar. The minimum spread value is stored in the quotes, which can cause unreasonably high expectations when designing trading strategies. To obtain absolutely accurate values of the average, median or maximum spread per bar, it would be necessary to analyze real ticks, but we have not yet learned how to work with them. And besides, it would be a very resource-intensive process. A more rational approach is to analyze spreads on the lower M1 timeframe: for bars of higher timeframes, it is enough to look for the maximum spread in the inside bars of M1. Of course, strictly speaking, it will not be the maximum, but the maximum of the minimum values, but given the transience of minute readings, we may hope to detect characteristic spread expansions at least on some M1 bars, and this is enough to get an acceptable ratio of analysis accuracy and speed.

MQL5 Book: Creating application programs / Timeseries / Reading price, volume, spread, and time by bar index
MQL5 Book: Creating application programs / Timeseries / Reading price, volume, spread, and time by bar index
  • www.mql5.com
Sometimes you need to find out information not about a sequence of bars but only about one bar. In theory, this can be done by using the previously...
 
Stanislav Korotky #:

No, I'm just a user. I'm not sure where this info is presented in the docs, but it is in the algotrading book.

Thank you so much! I normally use the Doc as a reference when programming. I never read the book, since it was published much later than when I started programming...