OPEN-SOURCE SCRIPT
Lead/Lag Correlation (Quant Lab)

How to use it? (Briefly)
• otherSymbol: The asset you think could be the leader
• Example: If you are on a BTC chart → BINANCE:ETHUSDT, TOTAL3, USDT.D etc.
• lagBars:
• If you say 5: You are looking to see if there is a correlation between the movement of the other instrument 5 bars ago and your current movement. • In other words, is the other one leading?
• corr (green/red line):
• Close to +1 → strong positive correlation
• Close to -1 → strong negative correlation
• Close to 0 → no correlation
Lead/Lag interpretation:
• If the correlation is high for a specific lagBars (e.g., 0.7+):
➜ The otherSymbol you chose could be a strong "leader" for your current chart. In other words, its movement 5 bars ago is now explaining yours.
• otherSymbol: The asset you think could be the leader
• Example: If you are on a BTC chart → BINANCE:ETHUSDT, TOTAL3, USDT.D etc.
• lagBars:
• If you say 5: You are looking to see if there is a correlation between the movement of the other instrument 5 bars ago and your current movement. • In other words, is the other one leading?
• corr (green/red line):
• Close to +1 → strong positive correlation
• Close to -1 → strong negative correlation
• Close to 0 → no correlation
Lead/Lag interpretation:
• If the correlation is high for a specific lagBars (e.g., 0.7+):
➜ The otherSymbol you chose could be a strong "leader" for your current chart. In other words, its movement 5 bars ago is now explaining yours.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.