Can someone please advise me what function in this 2 step process I should use?

sprintf or strf for printing into string?

and then at the end of run()

if(is(EXITRUN))
print(TO_CSV,...); ?

I am asking since not sure how big string can be optimally used here. Remember 1min OHLC data have some 370000 rows with 5-6 columns. Most of them containing 5 decimal numbers.

Any guidance or modifying the above code would be highly appreciated.
It is all about how to create a CSV file in zorro in the fastest way.