This script is used to indicate when price action of a crypto coin is diverging significantly from that of BTC.
Explanation of the Script: Inputs:
roc_length: The period used for calculating the Rate of Change. ma_length: The period used for the moving average of the ROC. threshold: The percentage difference that indicates a divergence.
Price Data:
The script retrieves the current asset's price and Bitcoin's price. ROC Calculation:
The ROC for both the current asset and BTC is calculated based on the defined roc_length. Moving Averages:
Simple moving averages (SMA) of the ROC values are calculated to smooth out the data. Divergence Detection:
The indicator checks if the current asset's ROC MA is significantly higher or lower than Bitcoin's ROC MA based on the specified threshold. Plotting:
The script plots the ROC values and their moving averages. It also highlights the background in green when a bullish divergence is detected (when the asset is moving up while BTC is lagging) and in red for a bearish divergence.
진정한 TradingView 정신에 따라, 이 스크립트의 저자는 트레이더들이 이해하고 검증할 수 있도록 오픈 소스로 공개했습니다. 저자에게 박수를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 출판물에서 이 코드를 재사용하는 것은 하우스 룰에 의해 관리됩니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.