Welcome to the forums! A few thoughts come to mind on this one.
But first I'd like to take a step back and ask about that "duplicate as many as 20 times" comment.
This raises a red flag for me because of the "don't copy & paste" concept we cover in the second half of this video about building maintainable code:
(The concepts in this video apply even if you don't have any OptoScript.)
Consider this: suppose you build these 20 nearly identical charts, then down the road you find a bug or want to make a small change.
You'd have to do it 20 times.
Also, perhaps today you're doing it 20 times but in the future you want to expand to 40 or 100! You could hit the limit of how many simultaneous charts you can have running on the particular PAC you're using.
Do all these need to run at once? Or can you loop through each one in turn? How many variables are unique to each "chart" currently? What types of variables are they? (Ints, floats, float tables?)
Here's an example of what I'm getting at. Say now you have:
Chart 1 calls a subroutine with Variable1
Chart 2 calls the same sub with Variable2
Chart 3 calls the same sub with Variable3
Instead just have:
Table of Variables loaded w/the values in Variable1, Variable2, & Variable3
ChartA loops and calls the sub passing: table element 0, table element 1, table element 2 in turn.
Does that make sense? Most likely you'd need several tables (one for each of the variables you currently re-name in each chart). You might even need a pointer table. But ultimately, the little extra setup could save you a lot of effort down the road.
Also, by decreasing the number of charts you're running at once, you could improve your overall system performance/throughput, as we discuss in this form 1776.
Hope that helps.