PROTECTED SOURCE SCRIPT
STC Hedging EMA 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 EMA > slow EMA.
Bearish Trend: fast EMA < slow EMA.
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 EMA > slow EMA.
Bearish Trend: fast EMA < slow EMA.
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에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.