I believe there's something wrong with the WHOLE_ARRAY constant in this case. The function doesn't work with it for me aswell and no error is thrown . It may be a bug or may be intended, because the documentation doesn't specify the usage of this constant for this function (usually this constant is specified as a default argument for the count parameter whenever it is allowed, which is not the case).
A possible workaround is calling the function with the maximum terminal bars:
int max_bars = TerminalInfoInteger(TERMINAL_MAXBARS); int iBarsCNT1 = CopySeries(sSymbol, PERIOD_M5, 0, max_bars, COPY_RATES_TIME|COPY_RATES_OPEN|COPY_RATES_HIGH|COPY_RATES_LOW|COPY_RATES_CLOSE, dtaTime, daOpen, daHigh, daLow, daClose);
You are not allowed to use WHOLE_ARRAY in such place. WHOLE ARRAY is defined as "-1".
int CopySeries( string symbol_name, // symbol name ENUM_TIMEFRAMES timeframe, // period int start_pos, // start position int count, // amount to copy ulong rates_mask, // combination of flags to specify the requested series void& array1[], // array to receive the data of the first copies timeseries void& array2[] // array to receive the data of the second copied timeseries ... );
You have to specify a positive value for count input parameter. (Something like 1000)
You are not allowed to use WHOLE_ARRAY in such place. WHOLE ARRAY is defined as "-1".
You have to specify a positive value for count input parameter. (Something like 1000)
Emanuel and Yashar, incredible. You're right. I never thought of that because I always use WHOLE_ARRAY with the data copy functions. Works everywhere else. Yet another undocumented "feature" I guess.
That did the trick, thanks guys!

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I created a script to show the error. When I tried to run it in the original script, it gave me:
Error: <4113> [CHART_WINDOW_NOT_FOUND]
... even if I hard-coded the symbol "USDJPY" (which appears as the first in the list in my Market Watch window in the terminal), and used "_Period" as the timeframe.
Since I put it in the example script (below), it doesn't give me that bizarre error, in fact it gives no error at all...
But neither does it give me any data.
Here's the output:
Can't I use CopySeries in a script? I thought that's exactly why the function exists: to give access to rate series data in scripts.
PS. it was ironic when it threw the 4113 error when (as you can see) my error message Print() statements include the chart ID.