PROTECTED SOURCE SCRIPT

Real-Time Swing High/Low Detector with liquidity sweep

518
This script identifies the most important market structure points (swing highs/lows) and liquidity sweeps in a configurable and timeframe-adaptive manner.
By default:

It shows 5 recent swing highs and lows to keep your charts readable.

It detects and illustrates up to 3 Liquidity Sweeps (very close new highs/lows to earlier extremes).

It automatically adjusts how tight the sweep detection is based on your chart’s timeframe to balance precision and noise.

You can tweak all these numbers via the input settings panel to customize the indicator to your personal trading style and chart preferences


Configurable Parameters
Pivot Length (pivot_length)

What it does: Determines how many bars to the left and right the script looks at when identifying swing highs and lows.

Effect: Increasing this value results in fewer, more significant swings; decreasing it makes the indicator more sensitive and detects more swings.

Default: 5

Suggested: Adjust based on your trading timeframe and style to balance sensitivity and noise.

Show Labels (show_labels)

What it does: Toggles the display of swing labels such as HH, HL, LH, LL on the chart.

Effect: If enabled, the script marks swing points with their corresponding label for easier visual reference.

Default: true

Use: Turn off if you prefer a cleaner chart without textual swing indicators.

Show Current Levels (show_current_levels)

What it does: Toggles horizontal lines extending from the latest swing highs and lows.

Effect: Provides visual support/resistance zones on the chart.

Default: true

Use: Helpful for visualizing major price levels based on recent swings.

Max Swing Points (max_swings)

What it does: Limits the number of swing points stored and displayed.

Effect: Prevents chart clutter and performance issues by controlling history length.

Default: 20

Use: Increase for longer history; decrease for lighter charts.

Liquidity Sweep Threshold (liq_sweep_threshold_pc) [Automatically Set Based on Timeframe]

What it does: Defines the maximum percentage price difference allowed to consider a new high/low "very close" to the previous one, detecting a Liquidity Sweep.

Effect: Controls how sensitively the script detects these sweep points.

Default: Automatically set based on chart timeframe:

For timeframes below 1 hour: 0.05% (stricter, less tolerant)

For 1 hour and above: 0.1% (more tolerant)

Use: This dynamic setting ensures relevance of Liquidity Sweeps across different timeframes.

Liquidity Sweep Label Transparency (liq_sweep_alpha)

What it does: Controls the opacity of "Liquidity Sweep" labels, with 0 being fully opaque and 255 fully transparent.

Default: 10 (mostly opaque but slightly transparent)

Use: You can increase this value if you want the labels to be more subtle.

Declinazione di responsabilità

Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.