This script isn't about creating a correlation script with labels, there is a perfect working example of Mango2Juice (Correlation Matrix, which was inspired by Daveatt's Correlation Matrix)
The intention was making it with the use of as less code as possible, looping through array's
The Pine correlation function doesn't work consistently in a local scope (loop), so I had to work around it