PROTECTED SOURCE SCRIPT
STC Hedging SMA Trend Gate

Schaff Trend Cycle (STC)–based hedging tool with a built-in higher-timeframe trend filter (“Trend Gate”) and a signal cooldown mechanism.
It is designed to provide long/short hedge entry signals only when both the momentum (STC) and the higher-timeframe trend agree, helping filter out noise and false trades.
Key Components
1. STC Core (Momentum Engine)
The Schaff Trend Cycle (STC) is calculated from a normalized MACD cycle:
Uses fastLength and slowLength EMAs.
Normalizes the EMA difference over a lengthSTC window.
Smooths and rescales into a 0–100 oscillator.
Thresholds:
Lower Threshold (default 20): potential long/hedge long entry if crossed upwards.
Upper Threshold (default 80): potential short/hedge short entry if crossed downwards.
2. Trend Gate (Higher-Timeframe Filter)
Pulls fast SMA and slow SMA from a higher timeframe (gateTF, default = 5m).
Defines the prevailing trend:
Bullish Trend: fast SMA > slow SMA.
Bearish Trend: fast SMA < slow SMA.
Requires persistence (trendBars) before validating a trend direction, avoiding “one-bar flips.”
3. Signal Debounce & Cooldown
Uses barstate.isconfirmed → ensures signals trigger only on bar close (prevents repainting).
Requires a minimum number of bars (cooldownBars) between signals.
Tracks the last signal bar (lastSigBar) so no new signals fire too close together.
4. Trade Signals
Long Hedge Signal:
STC crosses above the lower threshold.
Higher timeframe is bullish for at least trendBars bars.
Cooldown condition is satisfied.
Short Hedge Signal:
STC crosses below the upper threshold.
Higher timeframe is bearish for at least trendBars bars.
Cooldown condition is satisfied.
Signals are shown with:
Green ▲ triangles below bars = Long Hedge
Red ▼ triangles above bars = Short Hedge
5. Alerts
Built-in alertcondition() allows TradingView alerts for:
STC Long Hedge
STC Short Hedge
This indicator is intended for hedging strategies and trend-aligned momentum trading.
By combining:
STC cycle turns (momentum shifts), HTF moving average trend filter, and Signal cooldown (to reduce over-trading), Aims to generate cleaner long/short hedge entry signals with reduced noise and false triggers.
It is designed to provide long/short hedge entry signals only when both the momentum (STC) and the higher-timeframe trend agree, helping filter out noise and false trades.
Key Components
1. STC Core (Momentum Engine)
The Schaff Trend Cycle (STC) is calculated from a normalized MACD cycle:
Uses fastLength and slowLength EMAs.
Normalizes the EMA difference over a lengthSTC window.
Smooths and rescales into a 0–100 oscillator.
Thresholds:
Lower Threshold (default 20): potential long/hedge long entry if crossed upwards.
Upper Threshold (default 80): potential short/hedge short entry if crossed downwards.
2. Trend Gate (Higher-Timeframe Filter)
Pulls fast SMA and slow SMA from a higher timeframe (gateTF, default = 5m).
Defines the prevailing trend:
Bullish Trend: fast SMA > slow SMA.
Bearish Trend: fast SMA < slow SMA.
Requires persistence (trendBars) before validating a trend direction, avoiding “one-bar flips.”
3. Signal Debounce & Cooldown
Uses barstate.isconfirmed → ensures signals trigger only on bar close (prevents repainting).
Requires a minimum number of bars (cooldownBars) between signals.
Tracks the last signal bar (lastSigBar) so no new signals fire too close together.
4. Trade Signals
Long Hedge Signal:
STC crosses above the lower threshold.
Higher timeframe is bullish for at least trendBars bars.
Cooldown condition is satisfied.
Short Hedge Signal:
STC crosses below the upper threshold.
Higher timeframe is bearish for at least trendBars bars.
Cooldown condition is satisfied.
Signals are shown with:
Green ▲ triangles below bars = Long Hedge
Red ▼ triangles above bars = Short Hedge
5. Alerts
Built-in alertcondition() allows TradingView alerts for:
STC Long Hedge
STC Short Hedge
This indicator is intended for hedging strategies and trend-aligned momentum trading.
By combining:
STC cycle turns (momentum shifts), HTF moving average trend filter, and Signal cooldown (to reduce over-trading), Aims to generate cleaner long/short hedge entry signals with reduced noise and false triggers.
受保护脚本
此脚本以闭源形式发布。 但是,您可以自由使用它,没有任何限制 — 在此处了解更多信息。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
受保护脚本
此脚本以闭源形式发布。 但是,您可以自由使用它,没有任何限制 — 在此处了解更多信息。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。