Comprehensive Correlation Meter with Multiple MarketsThe Comprehensive Correlation Meter is designed to provide traders and investors with insights into the relationships between multiple financial instruments. This script expands upon an existing idea on TradingView about correlation by introducing the ability to analyze the correlation between three markets, offering deeper insights into market relationships. It helps users understand how these markets move in relation to each other, aiding in risk management and portfolio diversification.
Key Features:
Multiple Market Analysis: This script allows you to analyze the correlation between your primary market and two other selected markets.
Customizable Inputs: Users can select any symbols for the reference and third markets, and these selections must be confirmed before use.
Correlation Coefficients: Calculates and plots the correlation coefficients for:
Current Market vs. Reference Market
Third Market vs. Reference Market
Current Market vs. Third Market
An average correlation of all three markets combined.
Visual Aids: Plots reference lines at +1, 0, and -1 to indicate maximum positive correlation, no correlation, and maximum negative correlation.
How It Works:
Input Symbols: Select the symbols for the reference and third markets. The current market is based on the chart you are viewing.
Data Collection: The script collects the closing prices of the selected markets and calculates the percentage changes.
Correlation Calculation: Using the collected data, the script computes the covariance and standard deviations to determine the correlation coefficients.
Visualization: The correlation coefficients and covariances are plotted for visual analysis.
How to Use:
Select Symbols:
Use the input fields to specify the reference and third market symbols. Confirm your selections to proceed.
Customize Display:
Choose whether to display the covariance, reference market, current market, and third market.
Select which correlation coefficients to display.
Interpret Results:
A correlation coefficient close to +1 indicates a strong positive correlation.
A coefficient close to -1 indicates a strong negative correlation.
A coefficient around 0 indicates little to no correlation.
Use these insights to manage risk and diversify your portfolio effectively.
Example Use Case:
Suppose you are trading the S&P 500 and want to understand its correlation with the NASDAQ 100 and a particular stock, such as Apple. By setting the S&P 500 as the reference market, the NASDAQ 100 as the third market, and observing the current market (Apple), you can see how these instruments move in relation to each other. This can help you decide on hedging strategies or identify opportunities for diversification. However this is Not a Financial advise
Correction
Pullback WarningThe Pullback Warning indicator is a simple indicator that highlights the potential for a market pullback, by measuring distances between certain key moving averages.
John Pocorobba recently shared in his general market updates, research showing that when the distance between the closing price and the 9 day exponential moving average is greater than the distance between the 9 day exponential moving average and the 20 day exponential moving average a pullback is likely.
While this condition occurs frequently, I added sensitivity options to try and filter out the noise. The sensitivity is based on the closing price’s extension from the 50 day simple moving average. Depending on your level of sensitivity, only signals that occur when price is extended either 5, 6, or 7 percent away from the 50 sma will be plotted.
Choose how to see the signal:
Highlight Background
Plot a symbol at desired location
Note this signal works best on indexes, not individual securities.
Correlation prix [SP500, TESLA, BTCBefore you see this post I want to thank all the TradingView team. Every day that passes I learn better and better to use Pine script and I owe this to all those who publish and to the philosophy of TradingView. Thanks from Amos
This trading indicator compares the prices of the S&P 500 Index (SP500), Tesla (TSLA), and Bitcoin (BTC) to find correlations between them. To make the prices of SP500 and Tesla comparable to the price of Bitcoin, the indicator multiplies the closing price of Tesla by 114 and the closing price of the S&P 500 Index by 5.6.
In this way we can superimpose the prices on the BTC chart and see what happens.
Average BTC price/ tesla price = 114, so if we multiply the tesla price by 114 times we can superimpose it on the BTC price
At average BTC/SPX price = 5.6, also in this case we multiply the price of SPX by 5.6 to overlay the graph and see any correlations.
The indicator then calculates the average price between SP500 and Tesla, using the formula (SP500 + Tesla) / 2. This calculation creates a new line on the chart that represents the average price between these two assets.
The BTC_SP_TE variable is then calculated as the average of the closing price of Bitcoin and the previously calculated average price of SP500 and Tesla, using the formula (Btc + SP_TE) / 2. This calculation creates another line on the chart that represents the average price between Bitcoin and the previously calculated average between SP500 and Tesla.
The idea behind calculating these averages is to find correlations and patterns between the prices of these assets, which can help identify potential trading opportunities. By comparing the average prices of different assets, the trader can look for trends and patterns that might not be apparent when looking at each asset individually.
The indicator plots these prices on a chart and fills the area between them with either green or fuchsia, depending on which one is higher. The strategy suggests buying Bitcoin when the average price of SP500 and Tesla is higher than the current price of Bitcoin, and selling when it is lower.
To add visual cues to the trading strategy, the indicator uses the plotchar function to display a small triangle below the chart when it detects a potential buying opportunity. This is done with the following parameters:
Value: BTC_SP_TE < Btc and Btc > Btc1 and Btc1 > Btc , which is a logical expression that checks whether the average price of SP500 and Tesla is less than the current price of Bitcoin (BTC_SP_TE < Btc), and whether the current price of Bitcoin is higher than the price 10 bars ago (Btc > Btc1 ) and higher than the price on the previous bar (Btc1 > Btc ).
Text: "Moyen BTC_SP_Te", which is the text to display inside the marker.
Symbol: "▲", which is the symbol to use for the marker. In this case, it is a small triangle pointing upwards.
Location: location.belowbar, which specifies that the marker should be placed below the bar.
I hope this is an example of how to create an indicator on TradingView, remember that correlations do not always last, it is possible that when you see the graph this correspondence no longer exists, do your studies and get inspired.
Market Crashes/Chart Timeframes HighlightThis extremely helpful indicator allows you to highlight 7 custom date-based timeframes on your charts.
The default dates selected are what I consider to be the most significant 7 most recent market declines, including and since the 87 flash crash.
Note: The default dates are approximate but good enough to highlight the key timeframes of these pullbacks/crashes/corrections.
It's simple to use and does exactly what it should.
I created this indicator to make it easier when looking at the overall story of a chart. I found it helpful to highlight these areas to see how a market or equity has responded during these significant market pullbacks.
The highlight alone I’ve found helpful, and it becomes more powerful if you combine it with your own trusted trade system.
Also, to get the most out of using the default dates it’s important to understand the narrative behind each pullback/crash. Here’s the list of what I consider significant pullbacks:
Black Monday - Oct 87
1990s Recession - Jul 90 to Mar 91
Dot Com Bubble - 2000 to 2002 or so
Real Estate 2008 Crisis - I choose 2007-2009 to cover full insider knowledge and aftermath
2016 - 2018 - This isn't seen as a pullback, but I have it as significant because in many markets and equities, this was an almost equal percentage pullback as 2008. See Notes below
2020 Crash - Covid-19 and related shenanigans pullback
April 2021 to August 2022 - I believe we are in a current SHORT cycle so I've highlighted April 2021 as the start of what might be the start of a major decline testing Dot Com or lower levels.
A few notes on the above.
You'll find on most of the pullbacks listed above most equities and related markets behave similarly or have similar patterns.
The 2016-18 pullback is the most difficult to track. For instance, GE in this timeframe had a -80% decline, whereas BA depending on how you want to measure it had a 50-110% gain.
Eurobond CurveABOUT
Dynamically plots 3 no. forward EUROBOND curves. When the curves converge (or worse crossover) there is higher risk of financial uncertainty and potential market correction.
The Eurobond Curves work in a similar way to treasury "yield curve inversion"; except the EUROBOND curves can signal much earlier than Treasuries therefore providing a leading indicator.
The indicator looks the the "near" (next year EUROBOND), "mid" (EUROBOND 2 years out) and "far" (EUROBOND 5 years out) to assess for crossovers.
When the "near" and "mid" curves crossover the "far" curve, concerning economic conditions are developing and it may be a good idea to reduce risk exposure to markets.
LIMITATIONS
The EUROBOND curve crossover events are rare, and this indicator uses data back to 2005 (using approximately 25 TradingView security functions). Given there are relatively few crossover events, the reliability of this indicator should be considered low. Nonetheless, there is decent alignment with treasury yield curve inversions in the 20 year period assessed. Given treasury yield curve inversions have predicted every recession for the last 70 years, we still think the EUROBOND Curves are a useful datapoint to monitor into the future and provide confluence to other risk management strategies.
Price Target Pullback Correction or BearPrice Target percent drop is an indicator that allows you to set default percentage down from the 52 week high.
A pullback, correction, bear and a bear market is marked as a 5%, 10%, 20% or 40% drop from the 52 week highest price, so this will show the target price to buy at if these thresholds are hit.
You can change the default values of 5%, 10%, 20% and 40% to any percentage and the price will reflect the change of the default value. Furthermore, the default to use 52 weeks can be changed to find the highest price from the last 26 weeks or 104 weeks.
Swing ComparatorHere I bring you an array of methods to compare the swings and consistency between assets.
This indicator is excellent for swing traders and scalpers looking to maximize their profits by examining which of two closely related pairs provides greater price fluctuation during given period.
This indicator works against two assets, which are to be configured in settings.
This indicator has 5 particular plots for you to examine, each which can be considered for you to contemplate which pair for you to next perform a trade on.
First off, let's start with the blue.
The blue is simply a pearson correlation coefficient, thankfully now included in tradingview. This provides a value of 1 as values show to be close correlation, 0 showing no correlation, and -1 showing negative correlation - meaning an increase in one pair correlates to a decrease in another pair. This will turn green when greater than 0.975, showing a very strong relationship between the two pairs, and red when below -0.975. This is the only plot to be interpreted on a scale from -1 to +1.
Next, we have the purple and yellow background plots, followed by the white and green moving averages. Though similar, these are all slightly different.
For each of these 4 plots, a value greater than 0 indicates greater price swings for your Symbol #1, while a value less than 0 indicates greater price swings for Symbol #2.
These calculations are performed on a per bar basis, meaning you're likely going to be examining bars longer than what you'll normally be trading on. Use confluence, as well as your own judgement for this.
For example, if symbol #1 provides a bar with an open value 1% greater or less than close, providing a 1% swing on a given bar, but symbol #2 provides 2%, the indicator will fall down toward the negative, as Symbol #2 had the greater swing.
First, yellow focuses on only open/close bar values, and thus the body of the candlestick.
Purple, on the other hand, focuses on the wicks of the candle - thus, the high/low values. I've opted to make these two different values as a wick focuses on the embodiment within the time period, and body focuses on the open/close instant.
Next, the green is an extended EMA of the purple - High/Low ratio. This is important to examine trend overtime, and reduce unneeded noise.
Lastly, the white is simply difference in the standard deviation of the particular bars, between the two symbols you have selected. The tends to usually tie up with the green pretty well.
Considering this is going to by nature be very noisy datasets, I have included in settings the option to extend an EMA for everything. They have their default settings, but if you'd like to examine the trend without an EMA, feel free to set it to 1 to eliminate its effects.
I have additionally added the ability to introduce clipping, as well as scale the correlation coefficient to remain visible when examining very short term time scales. In the future, I hope to properly normalize all plots to remain within a -1 to +1 basis. Please be patient as I have multiple projects ongoing.
Suggestions and constructive criticism are very well encouraged.
Anyone is welcome to utilize this in their code, as well, i just ask you provide credit.
As you reduce to time frames less than a day, you will likely have to reduce the coefficient min/max closer to 0.025, or just hide it entirely.
TODO:
Make it look better. Sorry, folks.
Introduce latency between pairs.
Examine significance of a coefficient of determination
Remove static weights and introduce z-score and linear normalization.
Consider adding room for a 3rd pair. This could get ugly, however.
Ehlers Error Correcting Exponential Moving Average [CC]The Error Correcting Exponential Moving Average was created by John Ehlers and Ric Way (Stocks & Commodities V. 28:11 (30-35)) and this is an excellent moving average that accurately identifies the trend and sticks with the price during trends or choppy periods pretty well. It looks back to find the best gain setting for each day that returns the smallest difference between the current price and the ema based on the gain setting and uses that day's info in it's total calculations and if there is a zero gain for the day then it is just a classic ema. I have included strong buy and sell signals in addition to normal ones so lighter colors are normal and darker colors are strong. Buy when the line turns green and sell when it turns red.
Let me know if there are any other indicators you would like to see me publish!
Relative StrengthPowerful tool to calculate and display the strength of a security compared to another security.
Some Main purposes are:
- finding new leadership in a market correction
- comparing a market leader with a top competitor
- tracking rotation in the market
.. and so much more!
This tool is highly configurable, you can especially change:
- The reference symbol (SPY, QQQ, BTCUSD, ...)
- The time span to indicate a new High or Low in a certain time-frame
- Factorize your RS-Chart to make it fit to the original chart. (Moves the chart up or down)
- Option to repaint your candles / bars when a new RS High occurs in the given timeframe.
Enjoy and have a great day!
Powerful_Trading
Cyclic Smoothed RSI with Motive-Corrective Wave Indicator
This indicator uses the cyclic smoothed Relative Strength Index (cRSI) instead of the traditional Relative Strength Index (RSI). See below for more info on the benefits to the cRSI.
My key contributions
1) A Weighted Moving Average (WMA) to track the general trend of the cRSI signal. This is very helpful in determining when the equity switches from bullish to bearish, which can be used to determine buy/sell points. This is then is used to color the region between the upper and lower cRSI bands (green above, red below).
2) An attempt to detect the motive (impulse) and corrective and waves. Corrective waves are indicated A, B, C, D, E, F, G. F and G waves are not technically Elliot Waves, but the way I detect waves it is really hard to always get it right. Once and a while you could actually see G and F a second time. Motive waves are identified as s (strong) and w (weak). Strong waves have a peak above the cRSI upper band and weak waves have a peak below the upper band.
3) My own divergence indicator for bull, hidden bull, bear, and hidden bear. I was not able to replicate the TradingView style of drawing a line from peak to peak, but for this indicator I think in the end it makes the chart cleaner.
There is a latency issue with an indicator that is based on moving averages. That means they tend to trigger right after key events. Perfect timing is not possible strictly with these indicators, but they do work very well "on average." However, my implementation has minimal latency as peaks (tops/bottoms) only require one bar to detect.
As a bit of an Easter Egg, this code can be tweaked and run as a strategy to get buy/sell signals. I use this code for both my indicator and for trading strategy. Just copy and past it into a new strategy script and just change it from study to a strategy, something like this:
strategy("cRSI + Waves Strategy with VWMA overlay", overlay=overlay)
The buy/sell code is at the end and just needs to be uncommented. I make no promises or guarantees about how good it is as a strategy, but it gives you some code and ideas to work with.
Tuning
1) Volume Weighted Moving Average (VWMA): This is a “hidden strategy” feature implemented that will display the high-low bands of the VWMA on the price chart if run the code using “overlay = true”.
- If the equity does not have volume, then the VWMA will not show up. Uncheck this box and it will use the regular WMA (no volume).
- defines how far back the WMA averages price.
2) cRSI (Black line in the indicator)
- Increase to length that amount of time a band (upper/lower) stays high/low after a peak. Reduce the value to shorten the time. Just increment it up/down to see the effect.
- defines how far back the SMA averages the cRSI. This affects the purple line in the indicator.
- defines how many bars back the peak detector looks to determine if a peak has occurred. For example, a top is detected like this: current-bar down relative to the 1-bar-back, 1-bar-back up relative to 2-bars-back (look back = 1), c) 2-bars-back up relative to 3-bars-back (lookback = 2), and d) 3-bars-back up relative to 4-bars-back (lookback = 3). I hope that makes sense. There are only 2 options for this setting: 2 or 3 bars. 2 bars will be able to detect small peaks but create more “false” peaks that may not be meaningful. 3 bars will be more robust but can miss short duration peaks.
3) Waves
- The check boxes are self explanatory for which labels they turn on and off on the plot.
4) Divergence Indicators
- The check boxes are self explanatory for which labels they turn on and off on the plot.
Hints
- The most common parameter to change is the . Different stocks will have different levels of strength in their peaks. A setting of 2 may generate too many corrective waves.
- Different times scales will give you different wave counts. This is to be expected. A counter impulse wave inside a corrective wave may actually go above the cRSI WMA on a smaller time frame. You may need to increase it one or two levels to see large waves.
- Just because you see divergence (bear or hidden bear) does not mean a price is going to go down. Often price continues to rise through bears, so take note and that is normal. Bulls are usually pretty good indicators especially if you see them on C,E,G waves.
----------------------------------------------------------------------------------------------------------------------------
cyclic smoothed RSI (cRSI) indicator
----------------------------------------------------------------------------------------------------------------------------
The “core” code for the cyclic smoothed RSI (cRSI) indicator was written by Lars von Theinen and is subject to the terms of the Mozilla Public License 2.0 at mozilla.org Copyright (C) 2017 CC BY, whentotrade / Lars von Thienen. For more details on the cRSI Indicator:
The cyclic smoothed RSI indicator is an enhancement of the classic RSI, adding
1) additional smoothing according to the market vibration,
2) adaptive upper and lower bands according to the cyclic memory and
3) using the current dominant cycle length as input for the indicator.
It is much more responsive to market moves than the basic RSI. The indicator uses the dominant cycle as input to optimize signal, smoothing, and cyclic memory. To get more in-depth information on the cyclic-smoothed RSI indicator, please read Decoding The Hidden Market Rhythm - Part 1: Dynamic Cycles (2017), Chapter 4: "Fine-tuning technical indicators." You need to derive the dominant cycle as input parameter for the cycle length as described in chapter 4.
Hope this helps and good luck.
Correction Percent and Days SinceS
Use this script to see the depths of corrections and also to see how long it has been since a correction.
I published this script because the last time the SNP has gone this long without a 5% correction was 1996 excluding bear markets of course.
NOTE: This script is a 2 in 1. In order to see correction depth only use the first 3 plot settings as visible.
In order to see the days since a correction use the last two plot settings.