How to use ARRAYS in Pine Script V4 to calculate CORRELATION & COVARIANCE
The Art of Trading
Pine Script Mastery Course: https://courses.theartoftrading.com/courses/pine-script-mastery FREE Pine Script Basics Course: https://courses.theartoftrading.com/courses/pine-script-basics-course Source Code: https://courses.theartoftrading.com/pages/pine-script-mastery-source-code#correlation
Lesson Resources: TradingView Array Blog: https://www.tradingview.com/blog/en/arrays-are-now-available-in-pine-script-20052/ TradingView Array Documentation: https://www.tradingview.com/pine-script-docs/en/v4/essential/Arrays.html#introduction Array Diagram: https://media.geeksforgeeks.org/wp-content/uploads/C-Arrays.jpg FIFO/Stack Diagram: https://4cawmi2va33i3w6dek1d7y1m-wpengine.netdna-ssl.com/wp-content/uploads/2018/07/Computer-science-fundamentals_6.1.png Covariance Definition: https://www.investopedia.com/terms/c/covariance.asp Correlation Definition: https://www.investopedia.com/terms/c/correlationcoefficient.asp
My Indicators: https://zenandtheartoftrading.com/indicators/ Create Your FREE TradingView Account: https://www.tradingview.com/gopro/?offer_id=10&aff_id=15271
Want to learn Pine Script? Look no further. I have you covered!
This lesson demonstrates how to use array functions in Pine Script to calculate the correlation coefficient (and covariance) of two different markets.
With over 15 years of coding experience and 4+ years of trading experience, I specialize in TradingView's Pine Script programming language and I'm here to pass on everything I've learned about both trading and coding.
If you want more information about who I am and what I do, head over to https://zenandtheartoftrading.com/about.
▼Timestamps▼ 00:00 - Intro 04:30 - What Are Arrays? 06:35 - Get User Input 08:40 - Calculate % Change of Markets 12:55 - Declaring A Float Array 16:45 - FIFO vs Stack Arrays 17:57 - Adding Data to an Array 20:20 - What is Covariance? 21:10 - Calculating Array Covariance 24:56 - What is the Correlation Coefficient? 27:10 - Getting Array's Standard Deviation 28:19 - Calculating Array Correlation 29:33 - Summary & Analysis 35:08 - PineScriptMastery.com
#PineScript #TradingView #Indicator ... https://www.youtube.com/watch?v=kbW7XO-2LnY
168334877 Bytes