Saving price zones

 

I'm trying to save supply&demand zones, now i'm not sure how to do it.

I was considering 2 options (but if there's better ways let me know).

OnTick(): Loop through the past x amount of bars, and draw in all the zones, fill it in a 2d array or something, clear again at every tick.

OnTick(): Just check if a zone has been created, and store it locally in script again, will need a OnStart(): function to get all earlier zones first.

Is it fine to save them in-script, or should i maybe export them to a file? Note: They need to be removed aswell when hit.