OPEN-SOURCE SCRIPT
已更新 X-trender

This script is designed to identify the market trend, its momentum, and potential reversal points by combining Arnaud Legoux Moving Averages (ALMA) and the Relative Strength Index (RSI).
The indicator is plotted in a separate pane below the price chart (overlay=false).
Here is a detailed breakdown of how the script works:
1. Core Logic (The Calculation)
The indicator filters out market noise by combining two powerful tools:
- ALMA (Arnaud Legoux Moving Average): An advanced moving average that reduces lag while maintaining superior smoothness. The script allows you to choose your preferred price source (e.g., Close, HLC3, OHLC4).
- RSI (Relative Strength Index): Instead of applying RSI directly to raw prices, the script calculates the RSI of the smoothed ALMA values and subtracts 50. This centers the indicator around a zero (0) baseline:
x - Values above 0 signal a bullish (upward) trend.
x - Values below 0 signal a bearish (downward) trend.
2. Dual Time Horizons (Short vs. Long)
The indicator analyzes the market from two perspectives simultaneously, creating two overlapping histograms:
- ShortTermXtrender: Calculates the RSI based on the difference between two fast ALMA lines. This captures rapid, local changes in price momentum.
- LongTermXtrender: Calculates the RSI directly from a single long ALMA line. This tracks the more stable, macro market trend.
3. Visual Signals and Charting
- Histogram Colors: Bright green/dark green represents upward momentum, while bright red/dark red represents downward momentum. The color brightens when the move accelerates and darkens when it slows down.
- Signal Line: A further smoothed ALMA of the short-term indicator. It turns bright green when moving up and red when moving down.
- Reversal Dots (Tiny Circles): Plotted at the exact pivot points of the signal line. A green dot marks a local bottom (potential buy signal), and a red dot marks a local peak (potential sell signal).
- Fixed Levels: Horizontal lines at 30 / -30 and 40 / -40 help identify overbought and oversold conditions.
4. Dynamic ATR Bands
When enabled, orange bands are drawn around the short-term indicator based on market volatility (Average True Range). These work similarly to Bollinger Bands. When the histogram breaks outside these bands, it signals an extreme market condition and a high probability of a price correction.
5. Multi-Timeframe (MTF) Dashboard
The script features an MTF dashboard that creates a clean table in the corner of your chart. It fetches the long-term trend data from multiple higher timeframes (e.g., 15m, 1h, 4h, 1D) at the same time:
- Displays BULL (green) if the long-term trend on that timeframe is positive.
- Displays BEAR (red) if the trend on that timeframe is negative.This allows you to quickly check the "higher timeframe bias" without switching charts.
The indicator is plotted in a separate pane below the price chart (overlay=false).
Here is a detailed breakdown of how the script works:
1. Core Logic (The Calculation)
The indicator filters out market noise by combining two powerful tools:
- ALMA (Arnaud Legoux Moving Average): An advanced moving average that reduces lag while maintaining superior smoothness. The script allows you to choose your preferred price source (e.g., Close, HLC3, OHLC4).
- RSI (Relative Strength Index): Instead of applying RSI directly to raw prices, the script calculates the RSI of the smoothed ALMA values and subtracts 50. This centers the indicator around a zero (0) baseline:
x - Values above 0 signal a bullish (upward) trend.
x - Values below 0 signal a bearish (downward) trend.
2. Dual Time Horizons (Short vs. Long)
The indicator analyzes the market from two perspectives simultaneously, creating two overlapping histograms:
- ShortTermXtrender: Calculates the RSI based on the difference between two fast ALMA lines. This captures rapid, local changes in price momentum.
- LongTermXtrender: Calculates the RSI directly from a single long ALMA line. This tracks the more stable, macro market trend.
3. Visual Signals and Charting
- Histogram Colors: Bright green/dark green represents upward momentum, while bright red/dark red represents downward momentum. The color brightens when the move accelerates and darkens when it slows down.
- Signal Line: A further smoothed ALMA of the short-term indicator. It turns bright green when moving up and red when moving down.
- Reversal Dots (Tiny Circles): Plotted at the exact pivot points of the signal line. A green dot marks a local bottom (potential buy signal), and a red dot marks a local peak (potential sell signal).
- Fixed Levels: Horizontal lines at 30 / -30 and 40 / -40 help identify overbought and oversold conditions.
4. Dynamic ATR Bands
When enabled, orange bands are drawn around the short-term indicator based on market volatility (Average True Range). These work similarly to Bollinger Bands. When the histogram breaks outside these bands, it signals an extreme market condition and a high probability of a price correction.
5. Multi-Timeframe (MTF) Dashboard
The script features an MTF dashboard that creates a clean table in the corner of your chart. It fetches the long-term trend data from multiple higher timeframes (e.g., 15m, 1h, 4h, 1D) at the same time:
- Displays BULL (green) if the long-term trend on that timeframe is positive.
- Displays BEAR (red) if the trend on that timeframe is negative.This allows you to quickly check the "higher timeframe bias" without switching charts.
版本注释
minor code chcanges版本注释
.版本注释
- Changed the RSI calculation method: replaced the built-in `ta.rsi` to (RMA) with a manually calculated `ta.rsi` to (ALMA) to ensure the script's overall operational consistency.This allows the calculations and the shape of the curve to more accurately and promptly identify the start and end of ongoing momentum and trends.
- Several minor cosmetic changes and code fixes.
版本注释
- a slight name change版本注释
-old script ;(开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。