This script tracks divergences between price action and open interest for the BTC CME Futures contract (symbol "BTC1!") using the following components:
Key Features:
1. Price Analysis: Identifies lower highs in the price over a specified lookback period. Marks these points with red upward-facing triangles above the bars.
2. Open Interest Analysis: Retrieves open interest (OI) data for the BTC CME Futures contract via request.security. Detects lower highs in open interest over the same lookback period. Highlights these points with blue downward-facing triangles below the bars.
3. Divergence Detection: A divergence is identified when both price and open interest form lower highs simultaneously. Highlights such occurrences with a purple background, indicating potential bearish sentiment or weakening momentum.
4. Alerts: If divergences are detected, an alert is triggered (if enabled), notifying the trader to take action.
5. Visualization: Open interest is plotted as a blue line in a separate pane for added context. Red and blue markers highlight significant points in price and open interest trends.
Use Cases:
- Spot Weakening Trends: Divergences between price and open interest may indicate a loss of momentum or bearish sentiment, allowing traders to preemptively adjust their strategies.
- Monitor Institutional Activity: Open interest changes reflect shifts in market participation, especially in derivative markets like CME Futures.
- Set Alerts for Key Signals: With automated alerts, traders can stay informed of potential divergence signals without constant monitoring.
Customization Options:
- Lookback Period: Adjust the number of bars used to detect lower highs.
- Timeframe: Choose the timeframe for fetching open interest data (e.g., daily, hourly).
- Alert Activation: Enable or disable alerts for divergences.
This tool combines price action with open interest dynamics to provide a robust method for identifying market trends and potential reversals in BTC CME Futures.