Cross Correlation [Kioseff Trading]Hello!
This script "Cross Correlation" calculates up to ~10,000 lag-symbol pair cross correlation values simultaneously!
Cross correlation calculation for 20 symbols simultaneously
+/- Lag Range is theoretically infinite (configurable min/max)
Practically, calculate up to 10000 lag-symbol pairs
Results can be sorted by greatest absolute difference or greatest sum
Ability to "isolate" the symbol on your chart and check for cross correlation against a list of symbols
Script defaults to stock pairs when on a stock, Forex pairs when on a Forex pair, crypto when on a crypto coin, futures when on a futures contract.
A custom symbol list can be used for cross correlation checking
Can check any number of available historical data points for cross correlation
Practical Assessment
Ideally, we can calculate cross correlation to determine if, in a list of assets, any of the assets frequently lead or lag one another.
Example
Say we are comparing the log returns for the previous 10 days for SPY and XLU.
*A single time-interval corresponds to the timeframe of your chart i.e. 1-minute chart = 1-minute time interval. We're using days for this example.
(Example Results)
A lag value (k) +/-3 is used.
The cross correlation (normalized) for k = +3 is -0.787
The cross correlation (normalized) for k = -3 is 0.216
A positive "k" value indicates the correlation when Asset A (SPY) leads Asset B (XLU)
A negative "k" value indicates the correlation when Asset B (XLU) leads Asset A (SPY)
A normalized cross correlation of -0.787 for k = +3 indicates an "adequately strong" negative relationship when SPY leads XLU by 3 days.
When SPY increases or decreases - XLU frequently moves in the opposite direction 3 days later.
A cross correlation value of 0.216 at k = −3 indicates a "weak" positive correlation when XLU leads SPY by 3 days.
There's a slight tendency for SPY to move in the same direction as XLU 3 days later.
After the cross-correlation score is normalized it will fall between -1 and 1.
A cross-correlation score of 1 indicates a perfect directional relationship between asset A and asset B at the corresponding lag (k).
A cross correlation of -1 indicates a perfect inverse relationship between asset A and asset B at the corresponding lag (k).
A cross correlation of 0 indicates no correlation at the corresponding lag (k).
The image above shows the primary usage for the script!
The image above further explains the data points located in the table!
The image above shows the script "isolating" the symbol on my chart and checking the cross correlation between the symbol and a list of symbols!
Wrapping Up
With this information, hopefully you can find some meaningful lead-lag relationships amongst assets!
Thank you for checking this out (:
Correlations
CE - 42MACRO Equity Factor Table This is Part 1 of 2 from the 42MACRO Recreation Series
The CE - 42MACRO Equity Factor Table is a whole toolbox packaged in a single indicator.
It aims to provide a probabilistic insight into the market realized GRID Macro Regime, use a multiplex of important Assets and Indices to form a high probability Implied Correlation expectation and allows to derive extra market insights by showing the most important aggregates and their performance over multiple timeframes... and what that might mean for the whole market direction, as well as the underlying asset.
WARNING
By the nature of the macro regimes, the outcomes are more accurate over longer Chart Timeframes (Week to Months).
However, it is also a valuable tool to form a proper,
market realized, short to medium term bias.
NOTE
This Indicator is intended to be used alongside the 2nd part "CE - 42MACRO Yield and Macro"
for a more wholistic approach and higher accuracy.
Due to coding limitations they can not be merged into one Indicator.
Methodology:
The Equity Factor Table tracks specifically chosen Assets to identify their performance and add the combined performances together to visualize 42MACRO's GRID Equity Model.
For this it uses the below Assets, with more to come:
Dividend Compounders ( AMEX:SPHD )
Mid Caps ( AMEX:VO )
Emerging Markets ( AMEX:EEM )
Small Caps ( AMEX:IWM )
Mega Cap Growth ( NASDAQ:QQQ )
Brazil ( AMEX:EWZ )
United Kingdom ( AMEX:EWU )
Growth ( AMEX:IWF )
United States ( AMEX:SPY )
Japan ( AMEX:DXJ )
Momentum ( AMEX:MTUM )
China ( AMEX:FXI )
Low Beta ( AMEX:SPLV )
International ex-US ( NASDAQ:ACWX )
India ( AMEX:INDA )
Eurozone ( AMEX:EZU )
Quality ( AMEX:QUAL )
Size ( AMEX:OEF )
Functionalities:
1. Correlations
Takes a measure of Cross Market Correlations
2. Implied Trend
Calculates the trend for each Asset and uses the Correlation to obtain the Implied Trend for the underlying Asset
There are multiple functionalities to enhance Signal Speed and precision...
Reading a signal only over a certain threshold, otherwise being colored in gray to signal noise or unclear market behavior
Normalization of Signal
Double Normalization of Signal for more Speed... ideal for the Crypto Market
Using an additional Hull Moving Average to enhance Signal Speed
Additional simple Background coloring to get a Signal from the HMA
Barcoloring based on the Implied Correlation
3. Equity Factor Table
Shows market realized Asset performance
Provides the approximate realized GRID market regimes
Informs about "Risk ON" and "Risk OFF" market states
Now into the juicy stuff...
Visuals:
There is a variety of options to change visual settings of what is plotted and where
+ additional considerations.
Everything that is relevant in the underlying logic which can improve comprehension can be visualized with these options.
More to come
Market Correlation:
The Market Correlation Table takes the Correlation of all the Assets to the Asset on the Chart,
it furthermore uses the Normalized KAMA Oscillator by IkkeOmar to analyse the current trend of every single Asset.
(To enhance the Signal you can apply the mentioned Indicator on the relevant Assets to find your target Asset movements that you intend to capture...
and then change the length of the Indicator in here)
It then Implies a Correlation based on the Trend and the Correlation to give a probabilistically adjusted expectation for the future Chart Asset Movement.
This is strengthened by taking the average of all Implied Trends.
Thus the Correlation Table provides valuable insights about probabilistically likely Movement of the Asset over the defined time duration,
providing alpha for Traders and Investors alike.
Equity Factors:
The table provides valuable information about the current market environment (whether it's risk on or risk off),
the rough GRID models from 42MACRO and the actual market performance.
This allows you to obtain a deeper understanding of how the market works and makes it simple to identify the actual market direction,
makes it possible to derive overall market Health and shows market strength or weakness.
Utility:
The Equity Factor Table is divided in 4 Sections which are the GRID regimes:
Economic Growth:
Goldilocks
Reflation
Economic Contraction:
Inflation
Deflation
Top 5 Equity Factors:
Are the values green for a specific Column?
If so then the market reflects the corresponding GRID behavior.
Bottom 5 Equity Factors:
Are the values red for a specific Column?
If so then the market reflects the corresponding GRID behavior.
So if we have Goldilocks as current regime we would see green values in the Top 5 Goldilocks Cells and red values in the Bottom 5 Goldilocks Cells.
You will find that Reflation will look similar, as it is also a sign of Economic Growth.
Same is the case for the two Contraction regimes.
This whole Indicator, as well as the second part, is based to a majority on 42MACRO's models.
I only brought them into TV and added things on top of it.
If you have questions or need a more in-depth guide DM me.
Will make a guide to all functionalities if necessity becomes apparent.
GM
Correlation TrackerCorrelation Tracker Indicator
The Correlation Tracker indicator calculates and visualizes the correlation between two symbols on a chart. It helps traders and investors understand the relationship and strength of correlation between the selected symbol and another symbol of their choice.
Indicator Features:
- Correlation Calculation: The indicator calculates the correlation between two symbols based on the provided lookback period.
- Correlation Scale: The correlation value is normalized to a scale ranging from 0 to 1 for easy interpretation.
- Table Display: A table is displayed on the chart showing the correlation value and a descriptive label indicating the strength of the correlation.
- Customization Options: Users can customize the text color, table background color, and choose whether to display the Pearson correlation value.
- The Correlation Tracker indicator utilizes a logarithmic scale calculation, making it particularly suitable for longer timeframes such as weekly charts, thereby providing a more accurate and balanced measure of correlations across a wide range of values.
How to Use:
1. Select the symbol for which you want to track the correlation (default symbol is "SPX").
2. Adjust the lookback period to define the historical data range for correlation calculation.
3. Customize the text color and table background color according to your preference.
4. Choose whether to display the Pearson correlation value or a descriptive label for correlation strength.
5. Observe the correlation line on the chart, which changes color based on the strength of the correlation.
6. Refer to the correlation table for the exact correlation value or the descriptive label indicating the correlation strength.
Note: The indicator can be applied to any time frame chart and is not limited to logarithmic scale.
Correlation Coefficient - DXY & XAUPublishing my first indicator on TradingView. Essentially a modification of the Correlation Coefficient indicator, that displays a 2 ticker symbols' correlation coefficient vs, the chart presently loaded.. You can modify the symbols, but the default uses DXY and XAU, which have been displaying strong negative correlation.
As with the built-in CC (Correlation Coefficient) indicator, readings are taken the same way:
Positive Correlation = anything above 0 | stronger as it moves up towards 1 | weaker as it moves back down towards 0
Negative Correlation = anything below 0 | stronger moving down towards -1 | weaker moving back up towards 0
This is primarily created to work with the Bitcoin weekly chart, for comparing DXY and Gold (XAU) price correlations (in advance, when possible). If you change the chart timeframe to something other than weekly, consider playing with the Length input, which is set to 35 by default where I think it best represents correlations with Bitcoin's weekly timeframe for DXY and Gold.
The intention is that you might be able to determine future direction of Bitcoin based on positive or negative correlations of Gold and/or the US Dollar Index. DXY has been making peaks and valleys prior to Bitcoin since after March 2020 black swan event, where it peaked just after instead. In the future, it may flip over again and Bitcoin may hit major highs or lows prior to DXY, again. So, keep an eye on the charts for all 3, as well as the indicator correlations.
Currently, we've moved back into negative correlation between Bitcoin and DXY, and positive correlation with Bitcoin and Gold:
Negative Correlation b/w Bitcoin and DXY - if DXY moves up, Bitcoin likely moves down, or if DXY moves down, Bitcoin likely moves up (or if Bitcoin were to move first before DXY, as it did on March 2020, instead)
Positive Correlation b/w Bitcoin and Gold - Bitcoin and Gold will likely move up or down with each other.
DXY is represented by the green histogram and label, Gold is represented by the yellow histogram and label. Again, you can modify the tickers you want to check against, and you can modify the colors for their histograms / labels.
The inspiration from came from noticing areas of same date or delayed negative correlation between Bitcoin and DXY, here is one of my most recent posts about that:
Please let me know if you have any questions, or would like to see updates to the indicator to make it easier to use or add more useful features to it.
I hope this becomes useful to you in some way. Thank you for your support!
Cheers,
dudebruhwhoa :)
Bull Bear Correlation Tracker PaneThe Bull Bear Correlation Tracker is a versatile indicator designed to help traders identify the direction and strength of market trends by comparing the price action of multiple assets. It is particularly useful for those who are familiar with the carry trade principle, as it can detect when positively or negatively correlated assets move in favor or against the asset being traded. This indicator can be used for various markets, including crypto and forex, by simply adjusting the default options.
Key features of the Bull Bear Correlation Tracker include:
Multiple methods for determining trend direction: Supertrend, Pivot Point SuperTrend by LonesomeTheBlue, MACD - Zero Cross, and MACD - Grow/Shrink. These methods help traders identify the primary trend direction and potential trade opportunities.
Optional slow trend display for additional insights into market trends, allowing traders to analyze both short-term and long-term trends simultaneously.
Supports up to three symbols, enabling traders to analyze multiple assets simultaneously and better understand their correlation.
Assumed correlation settings to test traders' hypotheses about asset relationships, allowing traders to make informed decisions about potential correlations between different assets.
Customizable correlation period and smoothing settings to fine-tune the indicator's performance, providing traders with the ability to optimize the indicator based on their preferred trading style and market conditions.
Market hours filter to focus on specific trading hours, ensuring that the indicator only displays data during the hours specified.
Customizable color settings for easy visualization of trends, helping traders quickly identify the direction and strength of market trends.
Correlation histogram display to visualize asset relationships, providing traders with a clear visual representation of how different assets are correlated.
This indicator can be used to either force the correlation to be assumed positive or negative if the trader knows the correlation, or to use the actual data calculated between the traded asset and other assets if the correlation is broken often. This flexibility makes the Bull Bear Correlation Tracker suitable for trading various assets, including cryptocurrencies and forex, as well as for traders with different levels of experience.
By utilizing the Bull Bear Correlation Tracker, traders can gain valuable insights into market trends and correlations between different assets, helping them make more informed decisions and improve their trading strategies.
Note: I used back-testing for fine tuning do not base your trades on signals from the testing framework.
Negative Correlation SignalsThank you to Hendrik Fuchs who coded this for me - I highly recommend you...
The AUDUSD/EURUSD has a negative correlation with the DXY as does the GBPJPY/USDJPY have with the JPYX. This indicator is very simple and uses opposite candle pinbars (pinbar/doji structure can be set by you) of the two instruments on the chart whilst the stochastic RSI should be above 80 for overbought on the one but below 20 on the other for oversold (or vice versa) to generate a signal.
This indicator works as follow:
1. Choose an instrument that has an opposing negatively correlated instrument (EURUSD & DXY, GBPJPY & JPYX, US100 & VIX, etc.)
2. Add indicator to the chart and open settings.
3. Open the settings and add the correct instruments (default is set to GBPJPY & JPYX).
4. Enter your desired Stochastic RSI & candle formation settings.
You will see buy and sell signals appear on the charts. Alerts are possible (Any alert() function call). Does not repaint after close of candle. Better on higher timeframes but can also be used for scalping. Best used as confluence or as part of a trend trading system.
There are obviously many many variations that I have not even thought off - please let us know in the comment section if you find settings/timeframes/instruments that work particularly well.
Bitcoin Correlation MapHello everyone,
This indicator shows the correlation coefficients of altcoins with bitcoin in a table.
What is the correlation coefficient?
The correlation coefficient is a value that takes a value between 0 and 1 when a parity makes similar movements with the reference parity, and takes a value between 0 and -1 when it makes opposite movements.
In order to obtain more meaningful and real-time results in this indicator, the weighted average of the correlation values of the last 200bar was used. You can change the bar length as you wish. With the correlation value, you can see the parities that have similar movements with bitcoin and integrate them into your strategy.
You can change the coin list as you wish, and you can also calculate their correlation with etherium instead of bitcoin .
The indicator shows the correlation value of 36 altcoins at the moment.
The indicator indicates the color of the correlated parities as green and the color of the inversely correlated parities as red.
Cheers
Multi Delta-Agnostic Correlation Coefficient (tartigradia)Display three DACC plots simultaneously, to visualize both directional (up on top, down at bottom) and adirectional DACC (in the middle) simultaneously.
Delta Agnostic Correlation calculates a correlation between two symbols based only on the sign of their changes using a Sign Test (en.m.wikipedia.org), regardless of the amplitude of price change. Compared to a standard Pearson correlation (quantitative test), Sign Test correlations (discrete test) are highly sensitive to directional change with 0 lag, at the expense of lacking sensitivity to quantity correlation (ie, it does not matter if changes are big or small).
Hence, this Delta-Agnostic Correlation Coefficient (DCC or DACC) indicator is better used to detect early changes in correlations, and then confirmation with a typical Pearson correlation or a non-parametric Spearman test or Mutual Information (all three are quantitative tests, hence accounting for quantity and not just direction) can allow to be more sensitive to quantities too and hence be a robust combination to demonstrate strong correlations both in direction and amplitude.
Adequate statistical significance testing, using a two-sided binomial statistical test, is also implemented. Note however that one assumption of the sign test may here be violated: independence of observations for each symbol. If you assume the market is not acting on a random walk, then there is a temporal autocorrelation, and this biases the sign test. However, in practice, the test works well enough.
The directional variants of the test allow to test the correlation hypothesis only if the index symbol goes into one direction. For example, if we suspect that the index symbol is correlated with the current symbol but only when the index symbol is bullish, we can select "Up" to test this hypothesis. Note that given the specificities of how directional and adirectional tests differ in how they work, the default fill is different: zero-value fill for adirectional test to simulate how price action tend to lose momentum during market close periods, previous DCC_MA (= no change in DCC value) during both market close periods and when the direction is opposite for the directional variants of the test, so that while the market is moving opposite, we don't lose the statistical significance built up to now, otherwise it would be nonsensical (for the directional tests).
For more information on the theory behind, see the original DACC indicator, which is the same script but with only one plot:
Correlation ZonesThis indicator highlights zones with strong, weak and negative correlation. Unlike standard coefficient indicator it will help to filter out noise when analyzing dependencies between two assets.
With default input setting Correlation_Threshold=0.5:
- Zones with correlation above 0.5, will be colored in green (strong correlation)
- Zones with correlation from -0.5 to 0.5 will be colored grey (weak correlation)
- Zones with correlation below -0.5 will be colore red (strong negative correlation)
Input parameter "Correlation_Threshold" can be modified in settings.
Provided example demonstrates BTCUSD correlation with NASDAQ Composite . I advice to use weekly timeframe and set length to 26 week for this study
Kendall Rank Correlation Coefficient (alt)This is a non-parametric correlation statistical test, which is less sensitive to magnitude and more to direction, hence why some people call this a "concordance test".
This indicator was originally created by Alex Orekhov (everget), if you like this one, please show the original author some love:
This version is extended by tartigradia (2022) to make it more readily useable:
* Update to pinescript v5
* Default compare to current symbol (instead of only fixed symbols)
* Add 1.0, 0.0 and -1.0 correlation levels lines.
This indicator plots both the Kendall correlation in orange, and the more classical parametric Pearson correlation in purple for comparison. Either can be disabled in the Style tab.
Correlation with P-Value & Confidence Interval (alt)Shows the Pearson correlation between two symbols, including statistical significance test.
This is a fork of the original script by Balipour, with the addition of EMA that can be used instead of SMA in the Pearson correlation as an attempt to capture correlation trend changes more quickly, and conversion to pinescript v5. In the end, the EMA does not help much, for a faster capture of correlation trend changes, another kind of correlation is necessary, such as sign test correlation (another one of my indicators implement this idea).
Please show the original indicator's author some love if you appreciate this work:
Delta-Agnostic Correlation Coefficient (alt)Calculate a sort of correlation between two symbols based only on the sign of their changes, regardless of the amplitude of price change.
When positive, the two symbols tend to move together. When negative, the symbols move in opposite directions.
Since there is no significance calculation, and that the result is binary, keep in mind that correlation will always tend to go towards 1 or -1 even when there is no correlation. To reduce this issue, an EMA or SMA is applied to smooth out transitions: SMA smoothes over the selected length period but adds lag, whereas EMA smoothes amplitude without any additional lag. Hence, to know if the correlation is true or not, try to look at the amplitude and the number of consecutive days the correlation is maintained (both quantities are related), because when the correlation is spurious, it will tend to switch more or less alternatively between 1 and -1 and hence will hover around 0, whereas if the correlation is true, it will get further away from 0 and closer to 1 or -1.
In addition, since there is some time lag for the correlation to switch sign, the area is colored to know the current candle's correlation, regardless of past data's correlation: blue is a positive correlation (1), yellow is negative. The coloring can allow to know a trend reversal early on, but it's noisy.
Finally, symbols with closing days are better accounted for, with the correlation set to 0 on closed days (e.g., on week-ends), and the area is then colored in gray to signal that there is no new correlation data.
This is an improved fork over the original indicator by alexjvale, please show him some love if you like this work:
Correlation with Matrix TableCorrelation coefficient is a measure of the strength of the relationship between two values. It can be useful for market analysis, cryptocurrencies, forex and much more.
Since it "describes the degree to which two series tend to deviate from their moving average values" (1), first of all you have to set the length of these moving averages. You can also retrieve the values from another timeframe, and choose whether or not to ignore the gaps.
After selecting the reference ticker, which is not dependent from the chart you are on, you can choose up to eight other tickers to relate to it. The provided matrix table will then give you a deeper insight through all of the correlations between the chosen symbols.
Correlation values are scored on a scale from 1 to -1
A value of 1 means the correlation between the values is perfect.
A value of 0 means that there is no correlation at all.
A value of -1 indicates that the correlation is perfectly opposite.
For a better view at a glance, eight level colors are available and it is possible to modify them at will. You can even change level ranges by setting their threshold values. The background color of the matrix's cells will change accordingly to all of these choices.
The default threshold values, commonly used in statistics, are as follows:
None to weak correlation: 0 - 0.3
Weak to moderate correlation: 0.3 - 0.5
Moderate to high correlation: 0.5 - 0.7
High to perfect correlation: 0.7 - 1
Remember to be careful about spurious correlations, which are strong correlations without a real causal relationship.
(1) www.tradingview.com
Greater Currency Correlation Matrix (Forex)Other available matrixes I found have a limited number of forex symbols. Consequentially, you need to keep switching them if you want to do a proper analysis. As a result of that, I produced my own currency matrix.
Correlation studies relationships between different price charts.
High correlation may be completely random in the short term, but it may signify a fundamental relationship between the two symbols if calculated over the long term.
For example, the currency of an oil-producing country may rally along with oil, whereas the importer's currency may drop. This means that watching the oil price chart may be worth it for such pairs.
The script includes all Major and Minor pairs with the addition of Gold (XAUEUR) and two optional symbols.
▬▬▬▬
To avoid too frequent use of security(), I decided to calculate all symbol values from EUR pairs. It should improve performance and keep room for some additional symbols in the future.
Please report any bugs.
SARWThis indicator aims to indicate the correlation between two assets(Current and Base), it does NOT show entries or help your chart analysis directly.
The main features of this Correlation indicator is :
Correlation type : Direct Correlation | Inverse Correlation | No Correlation
Correlation Percentage : as its name, it calculate the Correlation Percentage between Current and base assets if exist
How to use: Chose the base asset (default: bitcoin) and open any other chart to be the other -Current- asset
inputs:
Max Lookback length : how many candles will be included in the scan.
Swing intensity : How many candle should be counted to confirm a Swing, If you are confused leave it as its default.
Base Asset : The base asset to calculate the current asset correlation with.
Important Notes:
As I promised, the previous correlation indicator used each candle alone, while this one uses waves and swings.
The Current asset has more power over the base, because it compares the Base to current, but not the opposite((E.g. if you want to check if some coin have correlation with bitcoin, it's better to use bitcoin and put the other coin name in the input field)).
For any notes on the indicator to be edited, or for another indicator ideas please comment.
US Sector CorrelationsA new and interesting way to look at Breadth. As for the usefulness of it, one would have to do some proper backtesting to get a full grasp of the capabilities. This is just a concept currently. But in general, SPX holding near ATHs with very low sector correlations can be a topping indicator. SPX selling off with Correlations all very positive across each sector...can be a sign of an impending bottom. But, needs the "full bake" of proper testing and analysis versus just guessing. I like the concept and want to explore it further, and I will. This is just the start.
Delta Agnostic Correlation CoefficientVisually see how well a symbol tracks another's movements, without taking price deltas into account.
For example, a 1% move on the index and a 5% move on the target will return a DCC value of 1. An index move of 0.5% on the index and a 10% move on the target will also return a DCC value of 1. The same happens for downward moves.
The SMA value can be set to smooth the curve. A larger value creates a smoother curve.
Correlation Mandate for Relational AnalysisThis indicator is engineered to make relational analysis much easier.
If you used another window for each symbol, you would have to resize them all one by one. You don't need another timescale.
There are three modes:
► Independent - selected symbol candles are colored on their own.
► Correlational - selected symbol candles are colored depending on their relation to the chart symbol. If it is correlational, 1st color is chosen (both have Close higher than Open). 2nd color will be used for the opposite.
► Anti-Correlational - the opposite of Correlational
To display my indicator, I chose USDCAD and Oil. Canada has the second-largest oil reserves in the world and naturally, they are their neighbor's supplier. If the oil price goes up, USDCAD should be tanking, unless a different major influence(s) happen to be stronger at a time.
Good luck!
Ehlers Spearman Rank Indicator [CC]The Spearman Rank Indicator was created by John Ehlers (Stocks and Commodities July 2020 pg 6) and this works well as a trend confirmation indicator. This is obviously his take on the Spearman Ranking Correlation and make sure to let me know what you think! Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators you want me to publish!
Spearman Rank Correlation CoefficientI'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!
Definition
Named after Charles Spearman and denoted by the Greek letter ‘ ρ ’ (rho), the Spearman rank correlation coefficient is the nonparametric version of the Pearson correlation coefficient . Use the Spearman rank correlation when you have two ranked variables, and you want to see whether the two variables covary. That is, as one variable increases/decreases, the other variable tends to increase/decrease respectively.
It is best used to discover if two variables (and in this first version of the indicator, two ticker symbols) increase and decrease together. There are advantages to using this version of correlation vs. the Pearson R.
Interpretation
The value oscillates between +1 and -1.
A value of +1 means the two variables are perfectly correlated, that is they are increasing and decreasing together in perfect harmony.
A value of -1 means the two variables exhibit a perfect negative correlation, that is they increase and decrease oppositely.
A value of zero means the two variables are not correlated at all (noise).
Correlation MATRIX (Flexible version)Hey folks
A quick unrelated but interesting foreword
Hope you're all good and well and tanned
Me? I'm preparing the opening of my website where we're going to offer the Algorithm Builder Single Trend, Multiple Trends, Multi-Timeframe and plenty of others across many platforms (TradingView, FXCM, MT4, PRT). While others are at the beach and tanning (Yes I'm jealous, so what !?!), we're working our a** off to deliver an amazing looking website and great indicators and strategies for you guys.
Today I worked in including the Trade Manager Pro version and the Risk/Reward Pro version into all our Algorithm Builders. Here's a teaser
We're going to have a few indicators/strategies packages and subscriptions will open very soon.
The website should open in a few weeks and we still have loads to do ... (#no #summer #holidays #for #dave)
I see every message asking me to allow access to my Algorithm Builders but with the website opening shortly, it will be better for me to manage the trials from there - otherwise, it's duplicated and I can't follow all those requests
As you can probably all understand, it becomes very challenging to publish once a day with all that workload so I'll probably slow down (just a bit) and maybe posting once every 2/3 days until the website will be over (please forgive me for failing you). But once it will open, the daily publishing will resume again :) (here's when you're supposed to be clapping guys....)
While I'm so honored by all the likes, private messages and comments encouraging me, you have to realize that a script always takes me about 2/3 hours of work (with research, coding, debugging) but I'm doing it because I like it. Only pushing the brake a bit because of other constraints
INDICATOR OF THE DAY
I made a more flexible version of my Correlation Matrix .
You can now select the symbols you want and the matrix will update automatically !!! Let me repeat it once more because this is very cool... You can now select the symbols you want and the matrix will update automatically :)
Actually, I have nothing more to say about it... that's all :) Ah yes, I added a condition to detect negative correlation and they're being flagged with a black dot
Definition : Negative correlation or inverse correlation is a relationship between two variables whereby they move in opposite directions.
A negative correlation is a key concept in portfolio construction, as it enables the creation of diversified portfolios that can better withstand portfolio volatility and smooth out returns.
Correlation between two variables can vary widely over time. Stocks and bonds generally have a negative correlation, but in the decade to 2018, their correlation has ranged from -0.8 to 0.2. (Source : www.investopedia.com
See you maybe tomorrow or in a few days for another script/idea.
Be sure to hit the thumbs up to cheer me up as your likes will be the only sunlight I'll get for the next weeks.... because working on building a great offer for you guys.
Dave
____________________________________________________________
- I'm an officially approved PineEditor/LUA/MT4 approved mentor on codementor. You can request a coaching with me if you want and I'll teach you how to build kick-ass indicators and strategies
Jump on a 1 to 1 coaching with me
- You can also hire for a custom dev of your indicator/strategy/bot/chrome extension/python
Correlation Matrix by DaveattHi everyone
A co-pinescripter friend told me this was impossible to do and we bet a free dinner tomorrow. Guess who's going to be invited to a very fancy restaurant tomorrow :) :) :) (hint: not him)
What's the today script is about?
This script is based on this MT4 correlation matrix
Asset correlation is a measure of how investments move in relation to one another and when. ... Under what is known as modern portfolio theory, you can reduce the overall risk in an investment portfolio and even boost your overall returns by investing in asset combinations that are not correlated.
I did it because it wasn't existing before with this format. What I discovered was only correlations shown as plot lines... #this #is #not #pretty
How does it work?
The correlation matrix will not be based on the current asset of the chart BUT will be based on the current timeframe (confusing? if yes, read it again until you'll get it)
- Numbers of bars back: numbers of bars used for the correlation calculation
- High correlation level: Correlation upper threshold. If above, then the correlation will be green
- Low correlation level: Correlation lower threshold. If below, then the correlation will be red
If the correlation is between the high and low levels, then it will be displayed in orange
- FOREX/INDEX: You can choose between displaying the correlation matrix between 3 FOREX or 3 INDEX assets
Also...
So far the scale doesn't respond too well to the matrix so you'll have to adapt the scale manually. I'll publish a V2 if I'll find a way to solve this issue from the code directly #new #challenge
A quick final note on why I'm sharing so much?
It challenges me to think out of the norm, get out of my bubble and explore areas of Pinescript that I still don't know. This "a script a day" challenge allows me to speed up my learning curve on Pinescript by a billion factor (and I get a few interesting gigs as well)
Let's bring this indicator to 100 LIKES guys !!!!! I think it deserves it, don't you think? :)
PS
Before all copy/pasters will add a version with crypto tomorrow, don't bother, I already did it and will post it in a few minutes for FREE :p
____________________________________________________________
Be sure to hit the thumbs up as it shows me that I'm not doing this for nothing and will motivate to deliver more quality content in the future.
- I'm an officially approved PineEditor/LUA/MT4 approved mentor on codementor. You can request a coaching with me if you want and I'll teach you how to build kick-ass indicators and strategies
Jump on a 1 to 1 coaching with me
- You can also hire for a custom dev of your indicator/strategy/bot/chrome extension/python
Asset Correlation Tool v3, improvedI found this useful tool among the indicators but it wasn't doing the correlation study correctly.
Everything in markets, with only a few exceptions, are rising in value over time and therefore trended to time. The simplest method I found is to use link relative or first difference detrending, before calculating a correlation between assets.
I also updated it to include more assets, to use the latest Cryptocap indices like BTC.D/ETH.D/TOTAL2 and the top 100 crypto index CIX100. I improved the colour schemes, too
Included in the source code are some other ideas like the FRED:M1 and FRED:M2 (only on daily charts), the Yuan/Yen/EUR/USD, etc. There's lots of scope for correlating unrelated markets.
I'll keep updating it as I use it to find truly correlated assets. Some kind of signal line of known correlations, to subtract from the baseline fuzz of market activity.
Any improvements are most welcome; I'm a novice at best at statistics and build on others' work.
- mabonyi