OPEN-SOURCE SCRIPT
Madrid Ribbon with ST/TEMA Filter

How the Combination Works
The script is combined by:
Porting to Pine Script v6: The Madrid Ribbon code was updated from v4 to v6 syntax (mainly changing study() to indicator(), change() to ta.change(), and using ta. prefixes for built-in functions like ema and sma).
Integrating SuperTrend Logic: The full calculation for the Zero-lag TEMA filtered SuperTrend's final_trend was copied into the combined script. This logic determines if the market is in a confirmed 1 (Uptrend) or -1 (Downtrend) based on the combined signal of the TEMA cross and the SuperTrend.
Filtering the Ribbon Color: The Madrid Ribbon's custom coloring function, maColor, was modified to include the final_trend as a filter:
If i_st_enabled is true, the original Madrid Ribbon color (LIME/GREEN for bullish, RUBI/MAROON for bearish) is only displayed if the final_trend confirms that direction.
If the final_trend is neutral or contradicts the ribbon's direction, the MA is colored GRAY.
Input Simplification: The numerous input options for the SuperTrend's source and MA type were simplified to use close and EMA by default to avoid excessive complexity, but the main parameters like TEMA periods, ATR Multiplier, and MA length were kept as inputs.
This results in a Madrid Ribbon that only shows its standard color signals when the longer-term, double-filtered SuperTrend confirms the same trend.
The script is combined by:
Porting to Pine Script v6: The Madrid Ribbon code was updated from v4 to v6 syntax (mainly changing study() to indicator(), change() to ta.change(), and using ta. prefixes for built-in functions like ema and sma).
Integrating SuperTrend Logic: The full calculation for the Zero-lag TEMA filtered SuperTrend's final_trend was copied into the combined script. This logic determines if the market is in a confirmed 1 (Uptrend) or -1 (Downtrend) based on the combined signal of the TEMA cross and the SuperTrend.
Filtering the Ribbon Color: The Madrid Ribbon's custom coloring function, maColor, was modified to include the final_trend as a filter:
If i_st_enabled is true, the original Madrid Ribbon color (LIME/GREEN for bullish, RUBI/MAROON for bearish) is only displayed if the final_trend confirms that direction.
If the final_trend is neutral or contradicts the ribbon's direction, the MA is colored GRAY.
Input Simplification: The numerous input options for the SuperTrend's source and MA type were simplified to use close and EMA by default to avoid excessive complexity, but the main parameters like TEMA periods, ATR Multiplier, and MA length were kept as inputs.
This results in a Madrid Ribbon that only shows its standard color signals when the longer-term, double-filtered SuperTrend confirms the same trend.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.