Hello,
There seems to be a bug with copy functions when we have two consecutive calls to eg CopyRate(), where we get different results compared to single calls..
Since the problem appears on consecutive call, in the example below, first a) run the first block (currday), b) comment out that and run the second block (prevday), c) finally uncomment all blocks
(I used eg MetaQuotes demo server, on symbol Indexes/US500M)
greets
What bug ? You didn't even say what the problem is.
I posted the code instead of doing the explanation, but here it is anyway:
a) If we call CopyRates() alone (and do some processing on the rates), for eg "today", we come up with some value "aval"
b) If we call CopyRates(), again alone but for eg "yesterday", we get some other value "bval"
c) But if we run both, one after another, then the new "bval" is different from the previous bval (of step "b"), although params have not changed
greets
PS It seems the code example was missing (maybe because I was doing some changes at the time :))// ** prevday ** rsum=0;
CopyRates(Symbol(), PERIOD_M2,
On MT5: Unless the current chart is that specific pair/TF, you must synchronize the terminal Data from the Server before accessing candle/indicator values.
Error 4806 while using CopyBuffer() - Expert Advisors and Automated Trading - MQL5 programming forum #10 (2020)
Is it mystical?! It is! - Withdraw - Technical Indicators - MQL5 programming forum (2019)
Timeseries and Indicators Access / Data Access - Reference on algorithmic/automated trading language for MetaTrader 5
Synchronize Server Data with Terminal Data - Symbols - General - MQL5 programming forum #2 (2018)
SymbolInfoInteger doesn't work - Symbols - General - MQL5 programming forum (2019)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
There seems to be a bug with copy functions when we have two consecutive calls to eg CopyRate(), where we get different results compared to single calls..
Since the problem appears on consecutive call, in the example below, first a) run the first block (currday), b) comment out that and run the second block (prevday), c) finally uncomment all blocks
(I used eg MetaQuotes demo server, on symbol Indexes/US500M)
greets