Is the limit to the number of series a global limit, or is it a per function limit? Could I increase the limit?

More importantly, what is the limit? How many series can I have?

Here is why I need lots of series.

I am experimenting with recording data for machine learning https://robotwealth.com/machine-learning-financial-prediction-david-aronson/.

To help with this I wrote a function to add the value of the indicator, the change in value, and the reciprocal of the time since the last peak or valley to the output. The code is here...

Code:
var addWithDeltaAndPeaks(string column_header, vars data)
{
	vars peakTime = series(0,2);
	if(peak(data))
		peakTime[0] = 1;
	else if(valley(data))
		peakTime[0] = -1;
	else
		peakTime[0] = peakTime[1] + sign(peakTime[1]);
	
	vars inversePeakTime = series(0, TargetLookahead+1);
	if(peakTime[0] != 0)
		inversePeakTime[0] = 1 / peakTime[0];
	
	if(is(INITRUN)) strcat(header, strf(",%s,d_%s,p_%s",column_header,column_header,column_header));
	strcat(line, strf(",%.5f,%.5f,%.5f",
		data[TargetLookahead],
		100.*(data[TargetLookahead] - data[TargetLookahead+1]),
		inversePeakTime[TargetLookahead]
		));
}



Obviously this function creates two series for every series that I use it on, and I end up with a whole lot of series, and probably too much data. But I don't yet know which bits are going to be useful.