I cannot comment on your optimization ideas, but your season modification looks syntactically ok. However I can imagine that it produces a slow and bad plot. It is just no good solution. For plotting any single minute, aside from speed issues, you would need data that really covers any minute. Forex M1 data has often missing minutes, and at those points you'll see nothing or single peaks in your plot. - If you want to do it faster, don't plot millions of bars, but collect the data really in an array, and remove minutes that are only represented by 1 or 2 samples. Then you won't get those peaks and gaps.