Investing - Correlation Table This correlation tables idea is nothing new, many sites provides it.
However, I couldn't find any simple correlation indicator on TradingView despite how simple this indicator is.
This indicator works as its called. Calculating the correlation between 2 projects (can be used in stocks as well) using the 'ta.correlation' feature built into pinescript.
When it comes to investing, we do not want our stocks / crypto project to be heavily correlated to each other.
If they are heavily correlated to each other, then there isn't much point in diversifying.
That being said, it can be useful for traders who trade multiple pairs.
-----------------------------------------------------------------------------------------------------------------------------------------------------------
In this indicator, consist of 5 primary input and 15 secondary input (Symbol List).
Correlation Source:
This input options allow you to change how the correlation is calculated. By default, it uses 'close'.
Correlation Percentage(%):
This input options allows you configure how many (%) of correlation is considered as 'decoupled'.
This correlation will only move between -100% ~ 100%.
100% refers to it moving together.
-100% refers to it moving the opposite direction.
For example, Project A rises in Price, what is the possibility of Project B following:
A 100% correlation between Project A and Project B, refers to Project B will follow Project A movement.
A 50% correlation between Project A and Project B, refers to there is only 50% chance for Project B to follow Project A movement.
A -20% correlation between Project A and Project B, refers to there is a 20% chance of Project B moving the opposite direction of Project A
(Refers to the table on chart above to better understand what the numbers means. DOT/USD has a 100% correlation to DOT/USD. However. MXCUSDT has a -37.2% correlation to DOT/USD.)
Amounts Bars To Check:
This input options will check the amount of bars since the last bar in the chart.
If you want to know the correlation of the past 100 days in a daily chart, you will enter '100' into this options and it will check only the past 100 days.
Symbol List
This will allow you to input all the project symbol ticker ID to add into the correlation table.
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Originally, I wish to use for loop to go through the symbol list to reduce the amount of code required. However, due to limitation of 'request.security' feature, I had to abandon that idea and use hard-coded for requesting security and use a while loop to identify the symbol correlation value in the array set then set the table value accordingly.
If there is any script writer could improve this or any unclear explanation, feel free to drop a comment below.
Correlation
Multiple Frequency Volatility CorrelationThis is a complex indicator that looks to provide some insight into the correlation between volume and price volatility.
Rising volatility is depicted with the color green while falling volatility is depicted with purple.
Lightness of the color is used to depict the length of the window used, darker == shorter in the 2 -> 512 window range.
Price-Filtered Spearman Rank Correl. w/ Floating Levels [Loxx]Price-Filtered Spearman Rank Correl. w/ Floating Levels is a Spearman Rank Correlation indicator with optional source filtering and floating levels.
What is Spearman rank correlation?
Spearman rank correlation, also known as Spearman coefficient is a formula used to identify the strength of the link between two datasets. This coefficient is a method that can be used to assess the strength of a relationship apart from the direction it takes. The formula, named after Charles Spearman, a mathematician, can only be used in circumstances where data can be categorized or put in order, for instance, the highest to the lowest.
For a better understanding of Spearman coefficient, it helps to get a sense of what monotonic function means. There’s a monotonic relationship under these circumstances:
– When the variable values rise together.
– When one variable value rises the other variable value lowers.
– The rate of movement of the variables need not necessarily be constant.
The Spearman correlation coefficient or rs, between +1 and -1, where +1 indicates a perfect strength between variables, while zero shows no association and -1 shows a perfect negative strength.
Spearman rank correlation theory:
A nonparametric (distribution-free) rank statistic proposed by Spearman in 1904 as a measure of the strength of the associations between two variables (Lehmann and D'Abrera 1998). The Spearman rank correlation coefficient can be used to give an R-estimate, and is a measure of monotone association that is used when the distribution of the data make Pearson's correlation coefficient undesirable or misleading.
Included:
Zero-line and signal cross options for bar coloring, signals, and alerts
Alerts
3 Signal types
Loxx's Expanded Source Types
Swing Trading SPX CorrelationThis is a long timeframe script designed to benefit from the correlation with the Percentage of stocks Above 200 moving average from SPX
At the same time with this percentage we are creating a weighted moving average to smooth its accuracy.
The rules are simple :
If the moving average is increasing its a long signal/short exit
If the moving average is decreased its a short signal/long exit.
Curently the strategy has been adapted for long only entries.
If you have any questions let me know !
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.
Overlay Mini Plot(s) of Correlated Asset(s)Overlay a small plot of a correlated asset of your choosing. Shrink/expand, Set vertical and horizontal position, plot multiple mini-plots via duplicate indicators with varied settings.
Plots the last X bars of any asset; including the live candle currently painting
Useful for low time frame trading when you want to see correlated asset price movement right alongside the price movement you're watching.
Useful for quick and simple comparisons; when you don't want the clutter of split screen or multi-pane view.
Useful for backtesting.
Price scale agnostic; just plots the shape of the recent price action, with several optional labels: Asset+timeframe | Live Price | Highest price over X bars | Lowest price over X bars.
Works fine with all the assets i've tested it on.
~~User inputs~~
-number of bars to paint.
-horizontal offset: plot to right X bars or to left X bars
-vertical offset: shift up or down, shrink or expand; by using 2 'spacer' inputs
-color/transparancy of candles and price labels.
-width (pixels) of candle bodies.
-choose to display price labels or not
-choose to display asset label or not
~~Tips~~
--Add several of these indicators; changing the vertical 'Shift/Shrink' settings on each to visually separate them.
--In the above chart or EurUsd, there are three indicators =>> three mini-plots overlaid: DXY, EurGbp and GbpUsd. Using the following settings for Space Above:Space Below: DXY- 0.1:4.5 | EurGbp- 1.8:1.8 | GbpUsd- 4.5:0.1
--the more you add, the more you'll have to vertically shrink the plots
© twingall
Adaptive Supertrend w/ Floating Levels [Loxx]Adaptive Supertrend w/ Floating Levels is a Supertrend indicator made adaptive by comparing the coefficient of determination / average of the least squares. The basic concept is this: use correlation with an r-squared line to adapt the period of the indicator, thereby resulting in a more versatile Supertrend. This adaptive formula makes the Supertrend more reactive to small fluctuation in the market while still doing what it's supposed to do: track trend. In addition, floating levels are drawn above or below the Supertrend which are calculated with percentage of the highest and lowest values of the Supertrend within the last “lookback” period. These floating levels act as filter to detect / prevent false trend reversals. T
What is the Supertrend?
Supertrend indicator was created by Olivier Seban to work on different time frames. It works for futures, forex, and equities. It is used in 15 minutes, hourly, weekly, and daily charts. Based on the parameters of multiplier and period, the indicator normally uses 3 for multiplier and 7 for the ATR period as default values. Average True Range is represented by the number of days while the multiplier is the value by which the range is multiplied.
Included
-Toggle on/off bar coloring
-Toggle on/off adaptivity
-Toggle on/off fill coloring
Asset CorrelationThis indicator shows correlation strength between the source asset plotted in the main chart and a user-input asset in the indicator panel. For example, if the main chart panel is displaying BTCUSD and the correlation indicator is NDX, then the correlation strength is plotted as the relationship between the two. A strong positive correlation target is set at 0.80 but can be changed. A strong negative correlation target is set at -0.80 and can also be changed.
The indicator also has an option for a plot of the ta.correlation() function for a reference line.
RSI correlation with cryptoindices [strategy version]Dear TV'ers,
Hereby the strategy script where the RSI of an altcoin can be compared to one of the selected cryptocap indices. Included are:
-total market cap
-total market cap minus bitcoin
-total market cap others
-total market cap usdt
-cix100 index
-btc dominance
-btc total cap
If the signal crosses over 1, then the altcoin is undervalued compared to the crypto index (and considered a buying signal here). If the signal crosses under 1, then the altcoin is overvalued compared to the selected crypto-index and a short signal is produced.
!!Please note that the selected timeframe for the reference pair should be a higher time of the chart in order to prevent repainting!!!
Macro EMA Correlation
This script is useful to see correlation between macroeconomic assets, displayed in different ema line shown in percentage to compare these assets on the same basis. Percentage will depend on the time frame selection. In the higher timeframe you will see higher variation and in small timeframe smaller variation.
You can select the timeframe who suit your trading style. The 1h and 4h fit well for longer trend swing trade and the lower time frame 15m, 5m, 1m are good for scalping or daily trading.
The following asset are available:
Bitcoin
Ethereum
Gold
Crypto total market cap excluding bitcoin (total2)
United state 10-year government bond (US10Y)
Usdt dominance show the concentration of usdt hold. For example, when trader are fearful they sell their crypto position to keep more usdt in their portfolio (USDT.D)
The USD/JPY pair the dollar usd versus the Japanese Yen one of the most forex traded pair.
You can clic on parameter to select the asset you want to analyse.
The main correlation observed are:
bitcoin negatively correlated with the usdt dominance.
bitcoin negatively correlated with the usd/jpy pair
bitcoin is positively correlated to eth, total2 (altcoin)
bitcoin positively correlated with gold
bitcoin is mostly negatively correlated to us10y
The basis of correlation is that positively correlated asset goes in the same direction and that the negatively correlated goes in opposite direction.
So, the idea is to use these information to see trend reversing.
Example 1: when bitcoin and usdt dominance are extended in opposite direction we look for a possible retracement toward 1% wich is the middle base.
Example 2 : when bitcoin make a move we look for ethereum and total 2 to follow
US Stock Market Sectors Overview Table [By MUQWISHI]US Market Overview Table will identify the bullish and bearish sectors of a day by tracking the SPDR sectors funds.
It's possible to add a ticker symbol for correlation compared to each sector.
Overview Indicator
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.
SARCThis 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
Correlation Leader : If there is a correlation , it indicates which asset follows the other (Current Asset Follows Base | Base Follows Current Asset)
Correlation bars : if the box (Show Correlation Candles) on the settings was True, it will show GREEN lines above candles which have direct correlation and RED lines above candles which have inverse correlation
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.
Correlation Factor : how stronger the correlation should be to include the candle(E.g. if set to 50, if any candle correlation was less than 50 it will be ignored), If you are confused leave it as its default.
Base Asset : The base asset to calculate the current asset correlation with.
Show Correlation Candles : (True | false) explained above on the main features.
Note: this indicator uses every single candle and compare it to the base same time candle, after some time I will post another similar indicator, BUT the new one will use the whole direction of the assets instead of each candle alone, I hope one of them can help you.
For any notes on the indicator to be edited, or for another indicator ideas please comment.
Adaptive Trend Cipher loxx]Adaptive Trend Cipher
Highly experimental!
Features:
-Implements 5 different Dominant Adaptive Cycle Measures to determine optimal inputs for correlation functions. These cycle calculations include the following: **
* Ehler's Autocorrelation Dominant Cycle
* Ehler's Instantaneous Dominant Cycle
* Ehler's Band-pass Dominant Cycle
* Ehler's Hilbert Period Dominant Cycle
* Ehler's Dual Differentiator Dominant Cycle
**additional cycle measures to be added in future releases
-Uses price to time correlation with look-back periods determined by the dominant cycle measures
-Allows users to manipulate the range of Dominant Cycle inputs, also allows the user to change the size % of the the output Dominant cycle to be used to determine correlation lengths
-Bars are colored according to correlation extremes. Green bars are uptrend, Red bars are downtrend; Yellow bars are high correlation, Fuchsia bars are low correlation
Uses
-Trend cipher is a novel approach to teasing out macro trends in the market. This version is geared to be used on the daily time frame only
-Reversals at yellow and fuchsia bars when they appear, it shows price exhaustion using
Warning: This may not work on certain assets due to the high processing power required to calculate cycle dominance. This also uses a custom correlation function since the data being input intot he correlation function is not constant but variable based on cycle dominance at every bar. To correct this in most circumstances you must change the max_bars_back constant in the indicator method call
If you use parts of the code, please let me know, I would love to hear what you do with it.
Happy trading!
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.
Racer Correlation [racer8]This indicator gauges correlation between 2 markets using my own method I invented. It is far superior to the correlation coefficient in that it maintains steady correlation values, meaning less false signals regarding correlation. Yet, the indicator's calculation is very simple in fact...
It simply calculates the percentage of moves in the same direction as the other market. So if MSFT moved in the same direction as SPX 80% of the time, then the indicator would show you a value of 80. Unlike correlation coefficient, you can calculate exactly how many of MSFT's bars moved in the same direction as SPX's bars. Everytime MSFT moves in the same direction as SPX, it is included in the percentage of positively correlated moves.
Closing prices are used solely in the indicator's calculations. All indicator values represent a percentage. Also, I recommend a length of at least 100 periods.
Values between 0% and 25% indicate strong negative correlation. (bright red)
Values between 25% and 33% indicate moderate negative correlation. (red)
Values between 33% and 50% indicate weak negative correlation. (dark red)
Values between 50% and 67% indicate weak positive correlation. (dark green)
Values between 67% and 75% indicate moderate positive correlation. (green)
Values between 75% and 100% indicate strong positive correlation. (bright green)........Enjoy :)
Correlation IndexShows how often and how much the underlying security deviates from the base stock.
Indices that help in the selection of securities:
Lst10 - last 10(long factor parameter) periods average
Aver - fulltime averaged
pwr - total deviation area from base
ust - unstability (drawdown index)
cor - percent of positive bars
cross - fulltime averaged deviation
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!
QuantAnna: Nifty VIX CorrelationNSE:NIFTY
Simple correlation indicator which oscillates around zero
Shows default correlation with NSE:IndiaVix
You can use it to check correlation with any other trading symbol or indices by simply selecting it in the settings.
Crypto swing correlation RSI and SMAThis is a crypto swing strategy, designed for long term periods and correlated pairs with crypto market total(or other coins used as correlation, however I recommend total of crypto or btc)
Its components are:
RSI with a very length
Correlation candles
SMA 9
Rules for entry:
For long : RSI is above 51 level and going higher and close of the candle is above the SMA
For short :RSI is below 49 and going lower and close of the candle is below the SMA
Rules for exit:
We exit when we encountered an opposite condition than the entry one, or based on take profit/stop loss levels.
If you have any questions let me know !
RSI CCI Correlating Oscillator (RCCO) by empowerTRCCO is pronounced "ree-koh" or "rico".
The RCCO is simply the plot of the values of both the RSI and CCI added together.
The RCCO makes some adjustments though, so that both the RSI and the CCI will fit correctly on the same scale - and so that these adjustments for scale allow reversals to be detected at crossings.
When the CCI crosses from underneath to up above the RSI, this is usually a bullish reversal. Alternatively, when the CCI crosses from above to back under the RSI, that usually signals a bearish trend. Look for the widest swings you can find to ensure good momentum. The larger the volume, the clearer and more decisive the trends. Low volume will lead to ranging and lazy momentum. High volume will create clear and forceful trends. The lowest negative RCCO in a timeframe, and then add some high volume... and you have yourself a good setup for a successful trade.
Because the RSI and CCI are adjusted, you may not recognize their values from having used the respective indicators on their own. The RSI and CCI values are less important. What matters with this indicator are the crossings and the RCCO value. The RCCO value should be negative, preferably, a deeply negative value. Look at the historical chart for the target per your selected timeframe and decide what values work for you.
I hope you enjoy the RCCO and that it can help you become a little más RICO!
BTC Sentiment analysis RSI 2xEMAThis is a CRYPTO correlation strategy, which is using BTC sentiment with BITFINEX long and short ratios.
WIth them we are making from one side 2 RSI, one for long and another for short. And from another side, we are going to make multiple EMA's, using the ratios for long and short.
Rules for entry
For this scenario I created a long only strategy.
The long entry condition is : we have a crossover of the rsi long ratio with rsi short ratio and long ratio from BITFINEX is above the long EMA and short ratio from BITFINEX is below short EMA.
We exit when we get the opposite condition, in this case we have a crossunder of the rsi long ratio with rsi short ratio and long ratio from BITFINEX is below the long EMA and short ratio from BITFINEX is above short EMA.
If you have any questions, let me know !
Alferow_2active_correlationAn indicator showing the coefficient of linear correlation between two assets for the selected period. As the initial data, the following are set: the indicator of the candle, according to which the calculation is made (maximum, minimum, closing or opening); the period for analysis; two assets between which the correlation is considered. The output is a label with the value of the correlation coefficient.