Dow Factor Relative Strength IndexThis script was written to create a new, rapid relative strength index inspired by the Dow Theory.
More info about Dow Theory : www.investopedia.com
According to the Dow Theory, volume should confirm market trends.
The correlation coefficient between prices and volume is negative in weakening trends and negative trends , positive in strengthening or positive trends.a factor was formed based on the correlation coefficient between volume and prices.
This factor was added to the relative strength index.
Period 5 is selected because the volume is very volatile and can be slow.
You can use the period you want, but I recommend the period as a minimum of 5.
It is suitable for all instruments and timeframes and thanks to its design, it provides control over gradual buying and selling points.
I haven't fully tested it, it's open to updates. For now, just use it to create ideas.
If I find it necessary,
I'll update after the tests.
If you have suggestions on these issues,
Leave your comments in the comment window.
This code is open source under the MIT license. If you have any improvements or corrections to suggest, please send me a pull request via the github repository github.com
Stay tuned , best regards.
Correlation
Multistep AutocorrelationAutocorrelation, also known as serial correlation, is the correlation of a signal with a delayed copy of itself as a function of delay. Informally, it is the similarity between observations as a function of the time lag between them. The analysis of autocorrelation is a mathematical tool for finding repeating patterns, such as the presence of a periodic signal obscured by noise, or identifying the missing fundamental frequency in a signal implied by its harmonic frequencies. It is often used in signal processing for analyzing functions or series of values, such as time domain signals.
This multistep autocorrelation function calculates the correlation of roc (rate of change) between an asset at t and t-1 as well as the correlation of the same asset at t and t-4. The output is an average of the two.
If both outputs show a positive correlation, the color will be green.
If only one shows a positive correlation, the color will be yellow.
If neither show a positive correlation, the color will be red.
This indicator can be useful as a filter for strategy entry logic (only enter on strong correlation and the strategy entry condition), or as standalone confirmation of strength in a specific direction. It can also be used to filter chop.
Another potential usecase would be as a variable in regression applications.
Enjoy!
Function : Linear Regression Bands
Used with Pearson Correlation. It can be used to make sense of the trends. Very successful results can be obtained with a MACD style indicator and volume indicator that gives Buy and Sell orders.Open for adaptive and mutable variable periods of moving averages. Best regards!
Kaufman Adaptive Correlation OscillatorIntroduction
The correlation oscillator is a technical indicator that measure the linear relationship between the market closing price and a simple increasing line, the indicator is in a (-1,1) range and rise when price is up-trending and fall when price is down-trending. Another characteristic of the indicator is its inherent smoothing which provide a noise free (to some extent) oscillator.
Such indicator use simple moving averages as well as estimates of the standard deviation for its calculation, but we can easily make it adaptive, this is why i propose this new technical indicator that create an adaptive correlation oscillator based on the Kaufman adaptive moving average.
The Indicator
The length parameter control the period window of the moving average, larger periods return smoother results while having a low kurtosis, which mean that values will remain around 1 or -1 a longer period of time. Pre-filtering apply a Kaufman adaptive moving average to the input, which allow for a smoother output.
No pre-filtering in orange, pre-filtering in yellow, period = 100 for both oscillators.
If you are not aware of the Kaufman adaptive moving average, such moving average return more reactive results when price is trending and smoother results when price is ranging, this also apply for the proposed indicator.
Conclusion
Classical correlation coefficients could use this approach, therefore the linear relationships between any variables could be measured. The fact that the indicator is adaptive add a certain potential, however such combination make the indicator have the drawback of kama + the correlation oscillator, which might appear at certain points.
Thanks for reading !
Volatility / Kurtosis / Skewness / CorrelationCalculations for Historical Volatility, Kurtosis, Skewness and Historical Correlation between two assets.
--------------------------------------
If you find it useful please consider a tip/donation :
BTC - 3BMEXEDyWJ58eXUEALYPadbn1wwWKmf6sA
--------------------------------------
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
Motion Smoothness Index Introduction
Its holiday time for me, i have been working here a lot. But no leaving before publishing. Telling when market price is smooth or rough is not the easiest task, so today i present a trend metric indicator that allow you to give you this kind of information.
The Indicator
The indicator is in an approximate range of (0,1) with mean x̄ decaying for higher length's, when the indicator is below 0.5 the market is smooth, else rough, this is the simple interpretation. The indicator is simply the ratio of the price residual standard deviation and the price standard deviation.
Higher value of length will make the indicator less accurate when it comes to detect rough market price, you can still use the indicator direction or its running mean to give you insights but 0.5 is still the recommended detection threshold.
In More Depth
Even tho market is random by nature there can still be structures in the price (cycles and trends), the fractional BM model will tell you that market price is sometimes auto-correlated (trending) or non auto-correlated (ranging), knowing what is the current market state is therefore important, when price is rough it can means an excess in noise thus exhibiting an uncorrelated market at the contrary of a smoother price that can allow for auto-correlation.
Now, market is infected by noise, and thats really unfortunate but the noise posses various properties that can allow for all the structures we see in market price. So thinking about the market allowing for possible profits during auto-correlated states is encouraging.
Conclusion
Although the indicator measure smoothness/roughness it can still be interpreted as a trend/range state detector. I hope it provide to be useful.
I wish you all good holidays and see you next time ! Thanks for reading !
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
ck - Crypto Correlation IndicatorA simple Correlation Indicator initially configured for Crypto Trader use (but other markets can use this too).
It plots the correlation between the current chart (say BTCUSD ) versus 4 user-definable indices, currency pairs, stocks etc.
By default, the indicator is preconfigured for:
GOLD (Oz/$),
Dow Jones Index (DJI),
Standard & Poor 500 Index (SPX) ,
Dollar Index ( DXY )
You can set the period (currently 1D resolution) in the "Period" box in the settings, valid inputs are:
minutes (number), days (1D, 2D, 3D etc), weeks (1W, 2W etc), months (1M, 2M etc)
Length is the lagging period/smoothing applied - default is 14
When changing comparison instruments/tickers, you may find it useful to prefix the exchange with the instrument's ticker, for example:
Binance:BTCUSDT, NYSE:GOOG etc
*** Idea originally from the brilliant Backtest Rookies - backtest-rookies.com ***
Inverse Fisher Z-Score Introduction
The inverse fisher transform or hyperbolic tangent function is a type os sigmoid function (sometime called squashing function) , those types of functions can rescale a result in a certain range and are widely used in artificial intelligence. More in depth the fisher transform can make the correlation coefficient of a time series normally distributed, in practice if you apply the fisher transform to the correlation coefficient between a time series and a linear function you will end up with an estimate of the z-score of the time series. The inverse transform however can do the contrary, it can take the z-score and transform it into a rough estimate of the correlation coefficient, if your z-score is not smooth then you will have a non-smooth estimate of the correlation coefficient, that's quite nice no ?
The Indicator
The inverse fisher transform of the z-score will produce results in a range of 1/-1, here however i will rescale in a range of 100/0 because its a standard range for oscillators in technical analysis. Values over 80 indicate an overbought market, under 20 an oversold market. The smooth option in the indicator settings will make the indicator use a linearly weighted moving average as input thus resulting in a smoother result.
The indicator with smooth option.
Conclusion
I presented a new oscillator indicator who use the inverse fisher transform of a z-score. Using the fisher transform and its inverse can give a new shape to your indicator, make sure to control the scale of your indicator before applying the fisher transform, the inverse transform should be applied to values in range of 1/-1 but you can use higher limits (2/-2,3/-3...) , however remember that higher limits will approximate an heavy side step function (square shape) . I hope you will find an use to this indicator.
Thanks for reading !
Function To Candles - Another way to see indicatorsIntroduction
There are different and better way's to see price data, a candlestick chart is one of the best way to see the price since you have access to the open/high/low/close information, this is really efficient and can allow for naked non parametric trading strategies (candlesticks patterns) . But what about making candles out of indicators ? There are tons of studies about candlesticks patterns in price data but none (?) about candlestick patterns using indicator data, therefore i made this script in order to show candles from various indicators, i also made an heikin-ashi mode.
Rsi To Candles
All the indicators are use the open/high/low/close price as input in order to return candles. length control the indicator period.
Stochastic To Candles
The stochastic oscillator is restrained in a range of 0/100, therefore when equal to 0 or 100 the candles can be flat.
Rate Of Change To Candles
The rate of change don't distort price as heavily as other indicators since its based on differencing.
Center Of Gravity To Candles
The center of gravity (cog) is defined from tradingview as "an indicator based on statistics and the Fibonacci golden ratio", its not an indicator i'am familiar with and i don't know if its the same proposed by Elhers. The candles are smooth, high length can flatten the candles heavily making them hard to see.
Correlation Oscillator
In a range of -1/1 this indicator is quite smooth and can also flatten candles.
Patterns And Heikin-Ashi
There are tons of patterns that can be generated from candlesticks, they can be applied to this indicator as well.
The indicator can show an heikin-ashi mode, heikin-ashi candlestick use averaging to plot candles, this is why they appear smoother, some signals generated from heikin-ashi candles are :
Bullish body with no lower shadows = Strong Uptrend
Bearish body with no higher shadows = Strong Downtrend
High range and small body = Indecision/Risk of reversal
Conclusion
I made an indicator able to draw candles from other indicators, those candles contain various information that can generate decision from patterns. I hope you find a use to it, if its the case share your findings with me, maybe that you will even be able find a new candlestick pattern :)
Thanks for reading !
Japanese Correlation CoefficientIntroduction
This indicator was asked and named by a trading meetup participant in Sevilla. The original question was "How to estimate the correlation between the price and a line as easy as possible", a question who got little attention. I previously proposed a correlation estimate using a modification of the standard score (see at the end of the post) for the estimation of a Savitzky-Golay moving average (LSMA) of order 1, however something faster could maybe be done and this is why i accepted the challenge.
Japanese Correlation
Correlation is defined as the linear relationship between two variables x and y , if x and y follow the same direction then the correlation increase else decrease. The correlation coefficient is always equal or below 1 and equal or above -1, it also have to be taken into account that this coefficient is quite smooth. Smoothing is not a problem, scaling however require more attention, high price > closing price > low price, therefore scaling can be done. First we smooth the closing/high/low price with a simple moving average of period p/2 , then we take the difference of the smoothed close with the smoothed close p/2 bars back, this result is then divided by the difference between the highest smoothed high's with the lowest smoothed low's over period p/2 .
Since we use information provided by candlesticks (close/high/low) i have been asked to publish this estimator with the name Japanese correlation coefficient , this name don't imply the use of data from Japanese markets, "Japanese" is used because of the candlestick method coming from Japan.
Comparison
I compare this estimation with the correlation coefficient provided in pinescript by the correlation function.
The estimation in orange with the original correlation coefficient using n as independent variable in blue with both length = 50.
comparison with length = 200.
Conclusion
I have shown that it is possible to roughly estimate the correlation coefficient between price and a linear function by using different price information. Correlation can be further estimated by using homogeneous bridge OHLC volatility estimators thus making able the use of different independent variables. I really hope you like this indicator and thanks to the meetup participant asking the question, i had a lot of fun making the indicator.
An alternative method
Light LSMAEstimating the LSMA Without Classics Parameters
I already mentioned various methods in order to estimate the LSMA in the idea i published. The parameter who still appeared on both the previous estimation and the classic LSMA was the sample correlation coefficient. This indicator will use an estimate of the correlation coefficient using the standard score thus providing a totally different approach in the estimation of the LSMA. My motivation for such indicator was to provide a different way to estimate a LSMA.
Standardization
The standard score is a statistical tool used to measure at how many standard deviations o a data point is bellow or above its mean. It can also be used to rescale variables, this conversion process is called standardizing or normalizing and it will be the basis of our estimation.
Calculation : (x - x̄)/o where x̄ is the moving average of x and o the standard deviation.
Estimating the Correlation Coefficient
We will use standardization to estimate the correlation coefficient r . 1 > r > -1 so in (y - x̄)/o we want to find y such that y is always above or below 1 standard deviation of x̄ , i had for first idea to pass the price through a band-stop filter but i found it was better to just use a moving average of period/2 .
Estimating the LSMA
We finally rescale a line through the price like mentioned in my previous idea, for that we standardize a line and we multiply the result by our correlation estimation, next we multiply the previous calculation by the price standard deviation, then we sum this calculation to the price moving average.
Comparison of our estimate in white with a LSMA in red with both period 50 :
Working With Different Independents Variables
Here the independent variable is a line n (which represent the number of data point and thus create a straight line) but a classic LSMA can work with other independent variables, for exemple if a LSMA use the volume as independent variable we need to change our correlation estimate with (ȳ - x̄)/ô where ȳ is the moving average of period length/2 of y, y is equal to : change(close,length)*change(volume,length) , x̄ is the moving average of y of period length , and ô is the standard deviation of y. This is quite rudimentary and if our goal is to provide a easier way to calculate correlation then the product-moment correlation coefficient would be more adapted (but less reactive than the sample correlation) .
Conclusion
I showed a way to estimate the correlation coefficient, of course some tweaking could provide a better estimate but i find the result still quite close to the LSMA.
Synergy StatsSynergy Stats
This indicator is intended to complement the Synergy indicator. It provides the following statistics:
A percentage showing how often the two assets move in the opposite direction over a given lookback period.
Similarly, another percentage showing how often the two assets move in the same direction over the same lookback period.
Count the number of times (occurrences) when the two assets move in the same direction for more than 4 bars.
Count the number of times the alternative asset moves more than x%
Count the number of times that chart asset moved in the same direction of the alternative asset when the alternative asset moved more than x%
Both indicators were developed for use in an investigation/tutorial using Pine Script to analyse Gold and US Dollar Index correlation.
The full free post can be found here: backtest-rookies.com
SynergySynergy
This indicator was developed for use in an investigation/tutorial using Pine Script to analyse Gold and US Dollar Index correlation.
The first indicator shall measure the percentage change between the open and close of each bar and compare it to the same percentage change of an alternative asset. Additionally, we shall color the background when the two assets move in the same direction. This should allow us to more easily see when the two assets move together and spot trends in their moment.
The yellow bars show use the percentage change in the price of gold. The blue bars show the percentage change in the price of the US Dollar index. If the bar is above zero, it means that the asset closed up. Conversely, if it is below zero, it means the asset closed down. Finally, the grey bars show bars in which the two assets closed in the same direction.
It can be used in conjunction with a second indicator (to be published soon) that provides statistics generated from this indicator.
The full free post can be found here: backtest-rookies.com
Partial CorrelationComputes the partial correlation between 2 symbols while removing the influence of a third.
Ex.:
Computes the correlation between AAPL and AMZN while removing the influence of SPX.
Crypto Correlation Matrix Series [SHK]Hi everyone, Although everything's clear from the title but I should describe some basic points.
Currency Correlation is a statistical measure of how two securities move in relation to each other.
So this script is used to show if current pair (alt-coins) is moving in the same direction of bitcoin (or ethereum) or not. Consider that in crypto market most of alt-coins have correlation of +0.7 with bitcoin, So temporary changes in correlation may signal a reversal or sharp continuation for the alt-coin.
"1" : The alt coin is moving in same direction of Bitcoin (Or Ethereum).
"0" : The alt coin is moving in random direction compared to Bitcoin. (No movement relation)
"-1" : The alt coin is moving in opposite direction of Bitcoin.
Important Note: By default average of 15 bars back is measured to calculate the correlation by this script. Please test other periods and share the best options with us.
Comments are welcomed :)
Flunki Ticker CorrelationCan't take credit for this, I found it somewhere, no idea where...
It correlates 6 tickers... enjoy.
Asset Correlation Tool v2Correlation amongst assets is the degree to which they move in tandem. This indicator measures correlation between different assets. Why is that important?
To any investor diversification is a very important technique for reducing risk. The problem is that most misunderstand it. Most people tend to think diversification is achieved simply by investing in a variety of assets instead of just a few.
This is wrong.
The whole point of diversification is to be invested in assets with different growth drivers. A portfolio consisting of +20 highly correlated assets (Your cryptobags, probably) is the OPPOSITE of diversification. This is taking on risk without being compensated for it. Which is contradictory to the fundamental reason for why you do invest in assets.
Proper diversification is achieved when you reduce the correlation between the assets in your portfolio.
HOW TO USE
To use this tool, add it to your favorites and then add it to your chart. It will by default only show the correlation between an altcoin index and the current chart symbol.
If you go to its settings you can add its correlation to the stock market, gold and you can also easily customize it to any security you want.
0.5 to 1.0: Strong positive correlation
Around 0: Little to no correlation
-0.5 to -1.0: Strong negative correlation
Took a few hours to build this one. It would be super helpful if you can take a look at the index I used - I'm convinced there are better and more accurate methods to this one. But best I could come up with
Later I will evolve this one to an oscillator that measures the relation between cross coin correlations and volatility. Inspired by some great work by @cryptorae
If you have any requests or ideas please shoot
Updates v0.2
- Added altcoin index
- Changed some calculations
- Restructed code
Asset Correlation ToolCorrelation amongst assets is the degree to which they move in tandem.
Diversification is a technique for reducing risk. Most people tend to think this is achieved simply by investing in a variety of assets instead of just a few. This is wrong.
Proper diversification is achieved when you reduce the correlation between the assets in your portfolio.
0.5 to 1.0: Strong positive correlation
Around 0: Little to no correlation
-0.5 to -1.0: Strong negative correlation
Took a few hours to build this one. Later I will add an index for crypto (large cap) and I'll play around with different ways of presenting the data.
If you have any requests or ideas please shoot
U.S. Stocks & Options CVI to Bitcoin Correlation [NeoButane]Conceptual indicator based on trying to find an inverse correlation between bitcoin and traditional markets due to bitcoin's usefulness as a hedge against economic downturns.
How to use this script: you look at it and see if there is a correlation or not between bitcoin/Ethereum price and either U.S. stock CVi, buy volume, sell volume, calls, puts, or the call/put ratio.
Kendall Rank Correlation CoefficientKendall Rank Correlation Coefficient script.
This way to measure the ordinal association between two measured quantities described by Maurice Kendall (1938, Biometrika, 30 (1–2): 81–89, "A New Measure of Rank Correlation").
In this script I compare Kendall Coefficient and Pearson Coefficient (using built-in "correlation" function).
Multiple Majors Currency Basket Power Oscillatorthis script by RichardoSantos
description
--
Power oscillator to discern what currency's are stronger/weaker.
added option to use a smoothed source(close) for pooling the change, giving longer term directional bias, note that this causes lag in the results as MA's turn slower than price.
--
I added currency labels and changed line color only.