I'm pleased to introduce this script in honor of the new array functions introduced to PineScript version 4.0. This update is a long time coming and opens the door to amazing scripting possibilities!
Named after Charles Spearman and denoted by the Greek letter ‘ ρ ’ (rho), the Spearman rank correlation coefficient is the nonparametric version of...
Volume is one piece of information that is often neglected, however, learning to interpret volume brings many advantages and could be of tremendous help when it comes to analyzing the markets. In addition to technicians, fundamental investors also take notice of the numbers of shares traded for a given security.
What is Volume?
The volume represents all the...
Portfolio Risk Metrics (Part I):
The beta coefficient can be interpreted as follows:
β =1 exactly as volatile as the market
β >1 more volatile than the market
β <1>0 less volatile than the market
β =0 uncorrelated to the market
β <0 negatively correlated to the market
excerpt from the Corporate Finance Institute
correlation coefficient 'ρxy'...
Fama-French 3 Factor Model
Extension of the Capital Asset Pricing Model (CAPM)
Ra = Rfr +
Ra = Return of the Asset
Rfr = Risk-Free Rate
βa = Beta Coefficient of the Asset
Rm - Rfr = Market Risk Premium
Fama-French 3 Factor
r = rf + β1*(rm - rf) + β2(smh) +β3(hml)
r = Expected rate of return
rf = Risk-free rate
ß = Factor’s coefficient...
Autocorrelation, also known as serial correlation, is the correlation of a signal with a delayed copy of itself as a function of delay.
This indicator displays autocorrelation based on lag number. The autocorrelation is not displayed based on time on the x-axis. It's based on the lag number which is from 1 to 50. The calculations can be done with "Log...
Pearson correlation coefficient measures the linear correlation between two variables. It has a value between +1 and −1, where 1 is total positive linear correlation, 0 is no linear correlation and −1 is total negative linear correlation. It’s often denoted by r for sample correlation and ρ for population correlation.
Note: Pearson Correlation only measures...
Hot off the press, I present this "Correlation Cycle, CorrelationAngle, and Market State" multicator employing PSv4.0, originally formulated by Dr. John Ehlers for TASC - June 2020 Traders Tips. Basically it's an all-in-one combination of three Ehlers' indicators. This power packed triplet indicator, being less than a 100 line implementation at initial release, is...
A good amount of users requested a text box showing various price statistics, the following script returns various of these stats in a user-selected range, and include classical ones such as a central tendency measurement (mean), dispersion (normalized range) and percent change, but also include less common statistics such as average traded volume and number of...
Display the correlation coefficient and/or Beta of an asset to a specified market.
- Specify market (S&P500 futures by default)
- Display one or other metrics
- Modify assessment period (200 bars by default)
- Calculate on price, returns or log-returns
Pinescript requires many of its built-in functions to use a simple int as their period length, which entails the period length cannot vary during the script's execution. These functions allow using a series int or series float for their period length, which means it can vary on each bar.
The functions shared in this script include:
Rolling sum: ...
This is my "Pine-based" correlation() function written in raw Pine Script. Other names applied to it are "Pearson Correlation", "Pearson's r", and one I can never remember being "Pearson Product-Moment Correlation Coefficient(PPMCC)". There is two basic ways to utilize this script. One is checking correlation with another asset such as the S&P 500 (provided as a...
This is a assortment of countries' inflation rates, sourced by Quandl. The countries are represented by their ISO 3166-1 alpha-3 codes in the options, and at the moment include:
ARG, AUS, CAN, CHE, DEU, EUR, FRA, GBR, ITA, JPN, NZL, RUS, USA
Included is a correlation to the current chart and the selected inflation rate. The correlation compares the monthly...
A tool to plot auto correlation of time series, this is useful in identifying periodicity in a time series or signal.
Due to the limits of Pine Script you'll need to add it multiple times if you want autocorrelation beyond 55 periods. I have added it 4 times here for 220 periods.
For more information on Autocorrelation see:...
Hot off the press, I present this "Correlation Trend Indicator" employing PSv4.0, originally formulated by Dr . John Ehlers for TASC - May 2020 Traders Tips. John Ehlers might describe it's characteristics as being a mean reverting trend identification oscillator range bound to +/-1.0 irregardless of any timeframe or asset. I could have finessed this indicator...
The Optimal Weighted Moving Average was created by Thomas Hutchinson and Peter G. Zhang, Ph.D. (Stocks & Commodities V. 11:12 (500-505)) and it is very similar to a classic weighted moving average but it uses the correlation between the input and the optimal weighted moving average output to use as the weights. Buy when the line turns green and sell when it turns...
In financial terms, 'correlation' is the numerical measure of the relationship between two variables (in this case, the variables are Forex pairs).
The range of the correlation coefficient is between -1 and +1. A correlation of +1 indicates that two currency pairs will flow in the same direction.
A correlation of -1 indicates that two currency pairs will move in...