OPEN-SOURCE SCRIPT

Liquidity Channels [TFO]

116
1. Indicator Declaration:

indicator("Liquidity Channels [TFO]", "Liquidity Channels [TFO]", true, max_lines_count = 500)
This defines the name of the indicator as "Liquidity Channels [TFO]" and sets the maximum number of lines to 500.

2. Input Variables:

bsl_color & ssl_color: These allow you to set the colors for bullish (liquidity highs) and bearish (liquidity lows) levels.
ps: Defines the "Liquidity Strength," i.e., how many bars to the left and right should the local high/low be valid for liquidity.
exag: Controls the size of the expanding channels. Higher values make the liquidity levels grow more.
del_untouched, del_after: Options to delete liquidity levels that were never traded through after a certain number of bars.
hide_channel: If true, hides the expanding channels.
line_style, line_width: Customizes the line style and width for the liquidity levels.

3. ATR Calculation:

atr = ta.atr(100) / 1000: This calculates the Average True Range (ATR) for 100 bars and scales it down.

4. Line Style Logic:

The switch statement assigns a line style based on the input (Solid, Dashed, Dotted).

5. Liquidity Type (liq):

liq is a custom type that holds:
price: Array of liquidity prices.
idx: Array of the bar index for each liquidity level.
diag: Array for diagonal lines showing channel growth.
hrz: Array for horizontal lines showing liquidity levels.

6. Methods:

add_liq: Adds a new liquidity level by saving the price and index, drawing a horizontal line at the liquidity price, and optionally adding a diagonal line showing channel expansion.
del_liq: Deletes a liquidity level by removing the price, index, and line (horizontal and diagonal).
update_liq: Updates the liquidity levels, extending the lines to the current bar index. If the liquidity level is outdated (based on the del_after setting) or the price is breached, it deletes the level.

7. Pivot Detection:

piv_hi: Detects if there is a pivot high (local high) based on the liquidity strength.
piv_lo: Detects if there is a pivot low (local low) based on the liquidity strength.

8. Logic for Adding Liquidity Levels:

If a pivot high (piv_hi) is detected, it adds a liquidity level at the high of that pivot using BSL.add_liq().
If a pivot low (piv_lo) is detected, it adds a liquidity level at the low of that pivot using SSL.add_liq().

9. Update Liquidity Levels:

The script calls BSL.update_liq(true) for bullish liquidity levels and SSL.update_liq(false) for bearish liquidity levels to update and possibly remove old or breached liquidity levels.

How to Use:

The script automatically identifies and plots liquidity levels (highs and lows) based on the price action.
You can customize the strength of liquidity, the appearance of lines, and how long the liquidity levels remain visible.
The expanding channel lines show how liquidity levels grow over time, providing dynamic visual references.

Important Notes:

You can adjust the ps parameter to control how many bars to the left and right must be higher or lower than the current bar for the level to be considered valid.
The exag parameter allows you to control how much the channel expands.
Liquidity levels that are never traded through can be automatically deleted after a specific period.

This script can be useful for traders looking to identify liquidity areas that could act as support/resistance or where price might react.

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.