PROTECTED SOURCE SCRIPT

SK Divergence Overlay

43
This Pine Script indicator, named "SK Divergence Overlay," is designed to automatically detect and visualize both regular and hidden divergences between an asset's price action and the SK. The indicator plots directly onto the main price chart, not in a separate pane.

Here is a breakdown of its features and logic:

Core Concept: Divergence

Divergence occurs when the price of an asset moves in the opposite direction of a technical indicator (in this case, the SK). This often signals a potential reversal or continuation in the market trend.

Regular Divergence: Suggests a trend reversal.

Bullish (Buy Signal): Price makes a lower low, but the SK makes a higher low.
Bearish (Sell Signal): Price makes a higher high, but the SK makes a lower high.
Hidden Divergence: Suggests a trend continuation.
Bullish (Continuation): Price makes a higher low, but the SK makes a lower low.
Bearish (Continuation): Price makes a lower high, but the SK makes a higher high.

Indicator Components and Settings

The script uses several user-configurable inputs:
SK Length (SK Length): The lookback period for the SK calculation (default: 14 bars) [1].
Pivot Length: The sensitivity of the pivot detection for both price and SK (default: 5 bars). A pivot is confirmed only after this many bars have passed without a higher high or lower low, allowing the script to identify significant swing points.

Visibility Toggles: Checkboxes to show/hide regular divergences, hidden divergences, the connecting lines, and the buy/sell signal markers.
Colors: Customizable colors for each type of bullish and bearish signal.

How It Works
снимок XAUUSD EURUSD DXY USOIL EURCHF
SK Calculation: The script calculates the SK using the closing price and the specified skLength.
Pivot Detection: It uses the built-in Pine Script functions ta.pivotlow and ta.pivothigh to identify significant swing points (pivots) on both the price chart and the SK line.
Divergence Logic: The script compares the current confirmed pivot points with the previously stored pivot points. It checks the criteria for all four types of divergence (Bullish Regular, Bullish Hidden, Bearish Regular, Bearish Hidden) [1].
Visualization:
Lines: If enabled, colored lines are drawn connecting the actual price pivots where the divergence occurs.
Markers: Small triangles are plotted below (bullish) or above (bearish) the price bars when a divergence is confirmed, shifted back in time using offset=-pivotLen to mark the exact bar where the pivot was established [1].



Отказ от ответственности

Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.