OPEN-SOURCE SCRIPT
Обновлено

Bull/Bear Trend Ribbon | 6-Layer Smooth Trend Tracking System

693
描述 / Description

是什么 / What

本指标基于 复合平滑均线 + 线性回归预测 构建了一套多时间框架趋势跟踪系统。
它计算了从短期到中长期的 7 条复合均线(A1–A7),每条均线融合了 3 组不同周期的 EMA,再对每条均线进行 6 期线性回归(linreg) 得到最终曲线(VAR1–VAR7)。
代码中默认绘制 VAR1–VAR6 共 6 条曲线,形成一条“趋势丝带”。每条曲线根据 当前值是否大于前一根 K 线的值 动态变色:

🔴 粉色(#FF00FF):上升方向
🟢 绿色(#00FF00):下降方向

This indicator builds a multi-timeframe trend tracking system based on composite smoothed moving averages + linear regression.
It calculates 7 composite MAs (A1–A7) from short to medium-long term. Each composite MA averages three EMAs of different lengths, then applies a 6-period linear regression (linreg) to produce the final curves (VAR1–VAR7).
By default, VAR1 through VAR6 are plotted, forming a “trend ribbon”. Each curve changes color dynamically based on whether its current value is greater than the previous bar’s value:

🔴 Pink (#FF00FF) – rising direction
🟢 Green (#00FF00) – falling direction

为什么 / Why

传统单根均线易产生滞后和噪音,而多周期复合均线能平滑价格波动,同时保留不同时间维度的趋势信息。在此基础上叠加 线性回归,进一步滤除随机扰动,提前捕捉趋势的转折倾向。
通过 6 条曲线的排列顺序与颜色变化,你可以直观判断:
  • 趋势强度:丝带发散且全部同色 → 强趋势
  • 趋势衰竭:丝带收敛、颜色频繁交错 → 震荡或变盘前兆
  • 多空力量对比:粉色曲线增多 vs 绿色曲线增多

A single moving average often suffers from lag and noise. Multi‑period composite MAs smooth price fluctuations while preserving trend information across different time dimensions. Adding linear regression further filters random noise and helps detect potential trend reversals earlier.
By observing the arrangement and color changes of the 6 curves, you can intuitively assess:
  • Trend strength – ribbon diverges and all curves share the same color → strong trend
  • Trend exhaustion – ribbon converges, colors frequently alternate → consolidation or reversal ahead
  • Bull/bear power balance – increasing number of pink curves vs. green curves


怎么用 / How to Use
  1. 直接加载:将脚本添加到图表(适用于任何品种和 K 线周期)。
  2. 观察丝带整体方向:
    -多数曲线为粉色且向上发散 → 多头趋势
    -多数曲线为绿色且向下发散 → 空头趋势
  3. 寻找入场时机:
    -多头开仓:短期曲线(VAR1/VAR2)从绿色转粉色,并上穿长期曲线(VAR5/VAR6)
    -空头开仓:短期曲线从粉色转绿色,并下穿长期曲线
  4. 离场/止损:当丝带开始频繁变色、曲线相互缠绕时,考虑平仓或收紧止损。

Add to chart – works on any symbol and timeframe.
Observe overall ribbon direction

Most curves pink and diverging upward → bullish trend
Most curves green and diverging downward → bearish trend
Entry signals

Long entry – short‑term curves (VAR1/VAR2) turn from green to pink and cross above long‑term curves (VAR5/VAR6)
Short entry – short‑term curves turn from pink to green and cross below long‑term curves
Exit / stop loss – consider closing or tightening stops when the ribbon changes color frequently and curves become entangled.

什么时候用 / When to Use

  • 趋势行情(单边上涨或下跌)中效果最佳,丝带干净、信号明确。
  • 大周期过滤:建议在日线或 4 小时图上判断主趋势,然后在 1 小时/15 分钟图上利用丝带的短线方向寻找顺势入场点。
  • 避免在剧烈震荡或低波动市场中依赖丝带的颜色翻转信号,此时假信号较多。

  • Works best in trending markets (strong up or down) – the ribbon is clean and signals are clear.
  • Higher timeframe filter – use Daily or 4H to determine the main trend, then use the ribbon’s short‑term direction on 1H/15min for pullback entries in the trend direction.
  • Avoid relying solely on color‑flip signals in highly ranging or low‑volatility markets – false signals increase.


⚠️ 注意事项 / Caution
  1. 非买卖点直接提示:本指标不提供“买入/卖出”文字标签,需要交易者自行根据曲线交叉与颜色变化判断。
  2. 无未来函数:ta.linreg(source, length, 0) 中 offset=0 是不包含未来的经典实现,仅基于当前及历史值计算,无未来函数风险。
  3. 宝塔线未包含在此版本:标题中的“宝塔线”为本指标的原始设想,当前发布的版本仅含多空趋势丝带。
  4. 参数固定:均线周期与回归长度均为内设值,无法通过设置界面调整。如需自定义,请修改 Pine 脚本源码。
  5. 适用周期:建议 1 小时及以上周期信号更稳定;分钟周期上颜色切换可能过于频繁。
  6. 风险提示:指标仅为技术分析工具,不构成投资建议。请结合资金管理与风控策略使用。


  1. No direct buy/sell labels – the indicator does not provide “BUY/SELL” signals. Traders must interpret crossovers and color changes themselves.
  2. No lookahead bias – ta.linreg(source, length, 0) with offset=0 uses only current and historical data. No future function risk.
  3. “Pagoda” not included in this version – the title originally mentioned “Pagoda lines”, but this release only includes the trend ribbon.
  4. Fixed parameters – MA periods and regression length are hardcoded and cannot be changed via settings. To customize, edit the Pine script source.
  5. Recommended timeframe – 1H or higher for more stable signals. Lower timeframes may produce excessive color flipping.
  6. Risk disclosure – The indicator is a technical analysis tool only and does not constitute investment advice. Always use proper risk management.
Информация о релизе
fixed some bugs

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

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