Exporting Real Time Data to CSV

Hello,

I want to know if there is way to export the Ask,Bid,AskSize,BidSize to a CSV file from when the market session starts till it ends?

Thanks.

Save the data in static vars and at the end of the period export them