PROTECTED SOURCE SCRIPT

HEENA 12 [CLEVER]

37
This script—HEENA 12 [CLEVER]—is a combined trading system that merges:

1. Multi-Timeframe Trend & Retest Signals

Using 4 timeframes, it generates Buy and Sell signals based on trend direction and clean retests of adjusted moving averages.
لقطة XAUUSD GBPMXN USOIL BTCUSD
2. Nadaraya-Watson Smoothed Bollinger Bands

A custom implementation of Kernel Regression–smoothed Bollinger Bands that behave like dynamic zones of support/resistance.

3. Visual Suite (Clouds, Signals, Themes)

Custom graphic settings, cloud coloring, and configurable signal shapes.

This is a trend continuation + volatility envelope system.

📌 Section 1 — User Inputs (Trend System)

The script allows the trader to pick up to 4 separate timeframes for signal generation.

Inputs include:

Timeframes (TF1–TF4)

MA length

MA type (SMA, EMA, RMA, WMA, VWMA)

Trend colors

These settings control the Phantom Trend system.

📌 Section 2 — Trend Algorithm
Moving Averages Used

For each timeframe, the script computes:

MA1: MA(length)

MA2: MA(length × 2)

Trend is defined by:

trend = MA1 > MA2

ATR-Adjusted Moving Averages

ATR(200) is used to create a dynamic threshold:

if uptrend: MA1 - ATR, MA2 - ATR
if downtrend: MA1 + ATR, MA2 + ATR


These adjusted values define zones for retest detection.

📌 Section 3 — Multi-Timeframe Retest Signals

For each timeframe, the script checks:

✔ BUY (retestUp)

Triggered when:

Price crosses up from below MA1 (after ATR adjustments)

Trend has not changed recently

Overall trend is up

There was no other retest in the last 5 bars

The bar is confirmed (barstate.isconfirmed)

✔ SELL (retestDn)

Triggered when:

Price crosses down from above MA1

Trend is down

No trend change

No recent retest in last 5 bars

Thus, signals appear only during trend continuation after clean pullbacks.

Signals Are Multi-Timeframe

You get TF1, TF2, TF3, TF4 signals on the same chart.

📌 Section 4 — Nadaraya-Watson Smoothed Bollinger Bands

This is the most advanced part of the script.

The indicator computes:

4 sets of Bollinger Bands

Short Period

Medium Period

Long Period

Extended Long Period

Standard bands:

BOLU = SMA(tp, n) + k * stdev(tp, n)
BOLD = SMA(tp, n) - k * stdev(tp, n)


Where tp = (high + low + close)/3

Then applies Nadaraya-Watson Kernel Regression smoothing

The Gaussian kernel:

exp(-(distance² / (2h²)))


This smooths band lines and removes jagged behavior.

Two smoothing modes:

Repaint ON → uses full future data (visually smoother, not valid for trading)

Repaint OFF → forward-looking kernel valid for real trading

📌 Section 5 — Band Break Alerts

If enabled, the script alerts when:

Price crosses above the smoothed upper band

Price crosses below the smoothed lower band

Uses customizable source (close, pivots, or highs/lows).

📌 Section 6 — Visual Elements
Signal Styles

User chooses shapes:

Arrow, triangle, diamond, circle, flag, cross, etc.

Band Clouds

The script fills between different band layers using custom bull/bear color palettes, creating:

Level 1 bands

Level 2 bands

Each with its own transparency settings.

Trend cloud removed

Only Bollinger cloud remains.

📌 Section 7 — What the Indicator Does in Practice

This indicator combines:

A — Trend Structure

Using multi-timeframe moving average alignment.

B — Pullback Entries

Using ATR-adjusted retests.

C — Adaptive Volatility Envelopes

Using Nadaraya-Watson smoothed Bollinger Bands.

D — Visual Confluence

To highlight:

Overextensions

Trend continuation zones

High-confidence pullbacks

Multi-timeframe alignment

How it Works The script operates through several complex computational steps on the TradingView servers:
Inputs and Definitions: The initial section defines variables based on user inputs for moving average type, lengths, colors, band parameters, and visual styles.
ma() Function: A custom function determines which type of moving average (SMA, EMA, WMA, etc.) to use based on the user's maTypeInput selection.
getIndicatorValues() Function: This core function calculates two moving averages (ma1 and ma2), the Average True Range (atr), and determines the current trend based on the MA crossover. It also calculates an adjusted MA value using the ATR, likely to create a dynamic offset channel.
request.security() Calls: This is the multi-timeframe mechanism. The script uses the request.security function to fetch the indicator values calculated by getIndicatorValues() from up to four different timeframes selected by the user, and plots them on the current chart's timeframe.
Signal Generation: The script compares price action (highs and lows) against the calculated MAs across the various timeframes. Boolean variables like retestUp and retestDn flag specific crossover events that occur during an existing trend, suggesting potential continuation or pullback signals.
Band Calculations (Implied): Although not fully shown, the extensive inputs for "Clever Bands" imply that the script calculates Bollinger Bands (or a similar volatility channel) with short, medium, and long periods, which are then used for visual plotting and alerts.
In summary, this script is a powerful, integrated indicator that uses multi-timeframe data requests to display a comprehensive view of trend and volatility in a single interface.

إخلاء المسؤولية

لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.