TradingView
TheTradingParrot
11 ตุลา 2023 เวลา 16 นาฬิกา 54 นาที

TTP Pair Slope/Hedge 

REQUSDT.P/UNIUSDT.PBybit

คำอธิบาย

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.
ความคิดเห็น
A_Traders_Edge
Would you be willing to help me to better understand what you mean by these 2 statements:
1. 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.
2. You can later use the hedge in a chart of X - Hedge * Y (Confirm with 1 / hedge )
3. Not that its a big deal or anything but you have co-integration spelled con-integration. Thanks for your time.
TheTradingParrot
@A_Traders_Edge, the spelling mistake will have to stay like that since tradingview doesn't support editing the description of indicators after 15 mins published.
A_Traders_Edge
@TheTradingParrot, Right-O. Frustrating, though I can understand why. You really do great work BTW. If I may submit a critique...the descriptions in your scripts do not assist with understanding the script in general (and yes...I watch your videos about them as well). I'm intimately aware (bc i run into the issue myself) that the person building the script can easily overlook the fact that descriptions that assist in the understanding of the code can inherently not be ....descriptive enough....to an outsider trying to understand the functionalities within the logic bc to the author it might seem easy. What Im trying to say is quite a few of your indicators Ive wanted to work with but didnt have to the time to deeply analyze the code to be able to play with it and the desc just werent enough to help me to understand it all. But I must say....you do VERY good work. Do you ever collaborate with other users? Ive got some great scripts that would take them to the next level if a very skilled individual (such as yourself) would put their mind and eyes on them.
TheTradingParrot
@A_Traders_Edge, I love collaborating but suffer from taking too much and squeezing too little so I try to not be so passionate and end up committing when in fact I wont be able to deliver due to limited time.
A_Traders_Edge
@TheTradingParrot, Understand completely. Well, if you ever want to dig deeper into the pairs arbitrage trading come find me. Its too difficult for some to comprehend so havent been able to see if theres any kinks in the logic I have due to this.
A_Traders_Edge
@A_Traders_Edge, Not to mention...Ive got grrrreat idea for cointegration arbitrage between certain pairs while using leverage and staying market neutral...and without having to deal with moving funds back and forth between the 2 exchanges to stay balanced and not be liquidated. Ie. staying "market neutral" is great bc even if the price tanks(and you are Long) against your trade direction during a trade (so, you end up being down on that exchange)...obviously the "neutral" aspect being that on the other exchange you are up since you were short there. Well, here you are market neutral BUT now your close to liquidation on the exchange you went long on thus would have to cash out your gains on the short exchange and transfer them to the first one to continue with the market neutral approach trading without being liquidated. Anyways...my idea gets rid of this MAJOR issue so funds do not have to be transferred back and forth to continue the arbitrage trading on the exchanges.
เพิ่มเติม