OPEN-SOURCE SCRIPT
TTP Pair Slope/Hedge

Pair slope/hedge uses linear regression to calculate the hedge ratio (slope) between the two assets within a period.
It allows you to specify a "from" and a "to" candle.
Example:
"A regression from 1000 candles back in time and ignore the last 100 candles. This would result in making a regression of 900 candles in total."
The formula used to perform the regression with the assts X and Y is:
Hedge =
mean( (X-mean(X))^2 )
——————————————————
mean( (X-mean(X)) * (Y-mean(Y)) )
You can later use the hedge in a chart of X - Hedge * Y
(Confirm with 1 / hedge )
If the plot is stationary the period tested should look like stationary.
If you cross an imaginary horizontal line across all the values in the period used it should look like a flat channel with values crossing above and below the line.
The purpose of this indicator is to help finding the linear regression test used for conintegration analysis. Conintegration assets is one of the requirements to consider assets for pair and hedge trading.
It allows you to specify a "from" and a "to" candle.
Example:
"A regression from 1000 candles back in time and ignore the last 100 candles. This would result in making a regression of 900 candles in total."
The formula used to perform the regression with the assts X and Y is:
Hedge =
mean( (X-mean(X))^2 )
——————————————————
mean( (X-mean(X)) * (Y-mean(Y)) )
You can later use the hedge in a chart of X - Hedge * Y
(Confirm with 1 / hedge )
If the plot is stationary the period tested should look like stationary.
If you cross an imaginary horizontal line across all the values in the period used it should look like a flat channel with values crossing above and below the line.
The purpose of this indicator is to help finding the linear regression test used for conintegration analysis. Conintegration assets is one of the requirements to consider assets for pair and hedge trading.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Join our membership to gain access to the private scripts.
patreon.com/c/thetradingparrot
patreon.com/c/thetradingparrot
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Join our membership to gain access to the private scripts.
patreon.com/c/thetradingparrot
patreon.com/c/thetradingparrot
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.