"Nothing unexpected" ?
I get three different values - for "Max bars in chart"(?): 371232, 100000, 101440 - that does not look like a valid maximum.
Beside that it is not obvious that chart-limitations are valid for a function like CopyRates!
Well for the others a way to deal with the internal limit of CopyRates - it may save you some time:
int nR,nB = iBars(_Symbol, PERIOD_M1), mxB = TerminalInfoInteger(TERMINAL_MAXBARS); Print(__LINE__," nB: ",nB," TERMINAL_MAXBARS: ",mxB," ",err(_LastError));ResetLastError(); nR = CopyRates(_Symbol, PERIOD_M1,0,mxB+2,r); Print(__LINE__," 0, xB, nR: ",nR," ",nR<=0?"":_t2s(r[0].time)," - ",nR<=0?"":_t2s(r[nR-1].time)," ",err(_LastError));ResetLastError(); nR = CopyRates(_Symbol, PERIOD_M1,mxB,mxB+2,r); Print(__LINE__," xB, xB, nR: ",nR," ",nR<=0?"":_t2s(r[0].time)," - ",nR<=0?"":_t2s(r[nR-1].time)," ",err(_LastError));ResetLastError(); nR = CopyRates(_Symbol, PERIOD_M1,mxB*2,mxB+2,r); Print(__LINE__," 2xB, xB, nR: ",nR," ",nR<=0?"":_t2s(r[0].time)," - ",nR<=0?"":_t2s(r[nR-1].time)," ",err(_LastError));ResetLastError(); nR = CopyRates(_Symbol, PERIOD_M1,mxB*3,mxB+2,r); Print(__LINE__," 3xB, xB, nR: ",nR," ",nR<=0?"":_t2s(r[0].time)," - ",nR<=0?"":_t2s(r[nR-1].time)," ",err(_LastError));ResetLastError(); nR = CopyRates(_Symbol, PERIOD_M1,mxB*4,mxB+2,r); Print(__LINE__," 4xB, xB, nR: ",nR," ",nR<=0?"":_t2s(r[0].time)," - ",nR<=0?"":_t2s(r[nR-1].time)," ",err(_LastError));ResetLastError();
I get:
98 nB: 371153 TERMINAL_MAXBARS: 100000 Err[0] No error! The operation completed successfully 105 0, xB, nR: 100002 2018.03.28 23:13 - 2018.07.04 11:10 Err[0] No error! The operation completed successfully 107 xB, xB, nR: 100002 2017.12.19 03:00 - 2018.03.28 23:14 Err[0] No error! The operation completed successfully 109 2xB, xB, nR: 100002 2017.09.12 13:12 - 2017.12.19 03:01 Err[0] No error! The operation completed successfully 111 3xB, xB, nR: 71153 2017.07.04 00:01 - 2017.09.12 13:13 Err[0] No error! The operation completed successfully 113 4xB, xB, nR: -1 - Err[4401] Requested history not found
Well maybe it's unexpected for you, but it's how it works.
But not documented!! And I don't have your crystal-ball. :(
Where did you get it?
But not documented!! And I don't have your crystal-ball. :(
Where did you get it?
It's documented that Bars returns total number of bars in the history (371232), and CopyRates works within TERMINAL_MAXBARS limit in a chart (100000). As for 101440, it's apparent that 100000 is initial limit, and then when new bars are formed the number grows and most outdated bars are not removed (they're kept in memory to prevent fragmentation and eliminate unnecessary copy operations in the core), hence the number increases. Citation from documentation:
Older bars are not removed immediately from the data cache when the new ones appear. This allows not to recalculate an indicator at each new bar, but calculate its values for new bars instead.
![Platform Settings - Getting Started - MetaTrader 5 Platform Settings - Getting Started - MetaTrader 5](https://c.mql5.com/36/19/platform-settings-getting-started.png)
- www.metatrader5.com
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
This little piece of code:
causes this: