PROTECTED SOURCE SCRIPT

True Trend Oscillator

34
Core Concept: The Range Filter
The main purpose of this indicator is not just to show the trend, but to actively filter out "noise" or sideways (ranging) markets.

It doesn't give you a buy or sell signal simply because a fast line crosses a slow one. Instead, it tells you if the market has sufficient strength to sustain a trend. If it doesn't, it signals this by painting the line gray, suggesting it's better to stay out.

How It Works: The 3 Key Components
Your indicator works by fusing three concepts: Price Momentum, Volatility Momentum, and a Threshold Filter.

1. Price Momentum Component (RSI)
What it does: It uses a standard RSI (14-period) to measure the internal strength of the price.

How it's used:

If the RSI is high (e.g., > 50), the "Bulls" have the momentum.

If the RSI is low (e.g., < 50), the "Bears" have the momentum.

2. "Energy" Component (Stochastic ATR)
What it does: This is the most advanced part of the indicator. It doesn't measure price; it measures volatility.

How it's used:

It calculates the ATR (Average True Range) to measure volatility.

It then calculates a Stochastic of the ATR. This measures where the current volatility is relative to its recent range (highs and lows of volatility).

The result is the value k, which represents the market's "energy" or "conviction".

3. The Fusion: Creating the Bull and Bear Lines
This is where the magic happens. The indicator combines price momentum (RSI) with energy (k) using a geometric mean (math.sqrt):

bull = math.sqrt(RSI * k)

bear = math.sqrt((100 - RSI) * k)

This means a strong "Bull" line needs not only a high RSI but also high "energy" (k).

The Visual Logic: How to Read the Oscillator
You have modified the indicator to display a single line (trendStrength) whose value is the strength of the dominant trend (math.max(bull, bear)).

The color of this line is the most important signal and is based on the Threshold Filter:

🟩 Green Color (Strong Bullish Trend)
The line is painted green (lime) only if TWO conditions are met:

Bullish strength is greater than bearish strength (bull > bear).

AND the bearish strength (the weaker side) is still above the threshold (math.min(bull, bear) > threshold).

Meaning: The bulls are winning, but the bears are still putting up a fight. This is a "true trend," not just a weak, random move.

🟥 Red Color (Strong Bearish Trend)
The line is painted red only if TWO conditions are met:

Bearish strength is greater than bullish strength (bear > bull).

AND the bullish strength (the weaker side) is still above the threshold (math.min(bull, bear) > threshold).

Meaning: The bears are winning in a real, strong trend.

⬜ Gray Color (Range-Bound or "Chop" Market)
The line is painted gray if either of the two forces (bullish or bearish) drops below the threshold.

Meaning: This is the filter signal. The indicator is telling you that the market has lost its directional energy. The trend has either exhausted itself, or the market is in a sideways chop. It's a "do not trade" or "take profits" signal.

Visual Summary
Main Line (and Area Fill): Shows the strength of the dominant trend. Its color (green, red, or gray) tells you the state of that trend.

Bar Coloring: You have the option (showBarColors) to have your main price chart candles painted the same color as the oscillator, allowing you to see the trend without looking at the panel below.

Background Lines (threshold, 80, 0): These are fixed reference levels. The threshold line (green by default) is the most important, as it's the filter that decides if you are in a trend or a range.

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

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