Mis à jour

[blackcat] L1 M.H. Pee Trend Intensity Index (TII)

6 361
Level: 1

Background

M.H. Pee developed the Trend intensity index (TII) indicator to measure the strength of a trend in the market.

Function

In this pine script, it uses the current 55-bar moving average for the measurements. TII looks at the proportion of prices of prior 34 bars being above or below today’s 55-bar moving average. The purpose of the TII indicator’s measurements is to gauge the future price trend movement.

The TII indicator takes today’s 55-bar moving average and each bar’s deviation (close – average). Up deviations give a positive amount while the downside deviations give negative amounts.

Up = close – average

Down = average- close

Then, the trend intensity index is the percentage of the total up amount out of the total up and down amounts. The formula is:

Trend intensity index (TII) = {total up / (total up + total down)} × 100

I use alma() plus hma() to filter out noise signal.


Inputs

Price --> Price source as input.
AvgLength --> Length input for the moving average for the TII measurements.
DevCalcLength --> Length input for bar’s deviation.

Key Signal

TII --> TII output signal

Remarks

This is a Level 1 free and open source indicator.

Feedbacks are appreciated.
Notes de version
OVERVIEW

This Pine Script, titled "[blackcat] L1 M.H. Pee Trend Intensity Index (TII)", designed by blackcat1402, serves as a custom indicator on TradingView. It calculates and visualizes the Trend Intensity Index (TII) based on price data, employing moving averages and deviations to measure market trends. The script includes plotting functionalities, conditionals for buy/sell signals, and alert mechanisms to notify traders of potential trading opportunities ⭐️.

The primary objective of this script is to provide traders with insights into trend strength and direction, helping them make informed decisions about their trades 📈.

FEATURES
✅ Uses Simple Moving Average (SMA) and ALMA smoothing techniques.
✅ Plots the TII line along with a comparison line from three bars ago for visualization.
✅ Highlights areas between the two lines using colored fills.
✅ Identifies and marks buy and sell conditions with respective labels.
✅ Generates real-time alerts for buy and sell signals.
✅ Customizable parameters for price source, averaging length, and deviation calculation period.
❌ No built-in risk management features.

INPUT PARAMETERS
price_source: Defines the price basis for calculations (high, low, close, etc.).
average_length: Sets the length for the simple moving average used in calculating the TII.
deviation_calculation_length: Specifies the number of periods considered in deviation calculations.
HOW TO USE
Add the Indicator: Paste the script into your TradingView chart editor and add it to your chart.
Customize Settings:
Adjust the inputs like price_source, average_length, and deviation_calculation_length according to your strategy preferences.
Interpret the Chart: Observe the yellow and fuchsia plots along with filled regions to gauge trend intensity and direction.
Utilize Labels: Use generated "B" and "S" labels to identify potential buying and selling points.
Enable Alerts: Set up notifications to receive immediate alerts when new trade signals are identified.
LIMITATIONS
The script assumes that all necessary indicators (such as SMA and ALMA) are available and correctly implemented within the TradingView environment.
Users must understand basic technical analysis concepts to effectively interpret the results.
Risk management should be handled externally as the script does not incorporate stop-loss or take-profit levels.
NOTES
Always backtest any script with historical data before applying it to live markets.
Fine-tune parameters regularly to adapt to changing market conditions.
You can modify the code further to better suit individual trading styles and requirements.
Notes de version
█ OVERVIEW

This open-source indicator plots the Trend Intensity Index (TII), a bounded oscillator measuring the strength of buying versus selling pressure, and turns its momentum shifts into a complete, trade-ready signal system. Version 2 adds a signal state machine, ATR-based take-profit and stop-loss references, a live status dashboard, and full alert coverage.

█ CONCEPTS

The Trend Intensity Index, introduced by M. H. Pee, compares total price deviations above and below a moving average:

• SD+ — sum of deviations where price sits above its average
• SD- — sum of deviations where price sits below its average
• TII = SD+ / (SD+ + SD-) x 100

Reading it is intuitive:
• Near 100 — buyers dominate
• Near 0 — sellers dominate
• Near 50 — balance between both sides

The raw ratio is smoothed with an ALMA filter followed by a Hull moving average, producing a fluid line that reacts quickly without excessive noise. Signals fire when the TII crosses its own 3-bar delayed line, highlighting momentum turns in both directions.

█ HOW TO USE

1 — Add the indicator; it loads in its own pane below price.
2 — Tune the core lengths to fit the instrument's volatility.
3 — Read signals: B = long entry, S = short entry, orange XL/XS crosses = exits.
4 — Open the Data Window for Entry, Stop Loss, and Take Profit reference levels.
5 — Create alerts from the four provided alert channels.

Input Parameters
• Price Source: source fed into the calculation (default hl2)
• Average Length: baseline average period (default 55)
• Deviation Calculation Length: deviation lookback (default 34)
• Midline Filter: requires TII above/below 50 for long/short entries (default off)
• Same-bar Entry/Exit Exclusivity: blocks conflicting signals on one bar (default on)
• Cooldown Bars: minimum bars between signals, 0 disables (default 3)
• Show ATR TP/SL Levels: enables risk references (default on)
• ATR Length: volatility lookback (default 14)
• Stop Loss (xATR): stop distance in ATR multiples (default 2.0)
• Take Profit (xATR): target distance in ATR multiples (default 3.0)
• Show Status Dashboard / Show Position Background: display toggles (default on)

█ FEATURES

• Signal governance — state machine with cooldown and same-bar exclusivity suppresses whipsaw clusters; all filters switchable to restore raw behavior
• ATR risk levels — volatility-adaptive take-profit and stop-loss references shown in the Data Window and dashboard
• Momentum ribbon — fill between TII and its 3-bar lag, yellow rising, fuchsia falling
• Status dashboard — position state, live TII value, ATR, and current TP/SL levels
• Position background — subtle green or red shading reflects the active state
• Complete alerts — four alertcondition channels plus bar-close alert() messages that include price

█ SIGNALS

• Yellow line: current TII value
• Fuchsia line: TII delayed by 3 bars
• Filled ribbon: momentum direction between the two lines
• B (green): TII crossed above its delayed line — long opportunity
• S (red): TII crossed below its delayed line — short opportunity
• XL / XS (orange cross): exit of the long or short position
• Dotted 50 midline: bull/bear boundary used by the optional filter
• Dashboard (top right): position, TII, ATR, TP/SL summary

█ IMPLEMENTATION NOTES

• Built with Pine Script v6 built-ins: ta.sma, ta.alma, ta.hma, ta.atr, ta.crossover, ta.crossunder
• Zero-division guard returns a neutral 50 during warm-up, and the delayed line uses raw history, so no artificial signals appear early on
• All alerts confirm on bar close; no repaint-prone intrabar triggers are used

█ LIMITATIONS

• Excels in trending conditions; can churn in tight ranges — enable the Midline Filter and Cooldown Bars to dampen noise
• TP/SL values are manual-execution references, not automated orders
• Defaults were tuned for 4-hour and daily charts; test before faster timeframes

█ NOTES

• Concept credit: M. H. Pee, Trend Intensity Index
• Open source under Mozilla Public License 2.0
• Companion to the blackcat L1 series of indicators

═════════════════════════════════════════════════════════════════════════
For questions or feedback, use the comments section below.
Feel free to use and modify — attribution appreciated.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.