OPEN-SOURCE SCRIPT

Schmitt Hysteresis Momentum [forexobroker]

320
Schmitt Hysteresis Momentum applies a textbook control-theory Schmitt trigger to rate of change. Two ATR-scaled thresholds (one positive, one negative) form a hysteresis band: state flips up only when RoC clears the upper threshold, flips down only when RoC clears the lower. Within a held state, EMA crosses provide entry timing — multiple entries per state without flip-flop.

🔶 ALGORITHM

1. RoC = (close - close[N]) / close[N].
2. Adaptive thresholds: upper = +k * (atr / close); lower = -k * (atr / close).
3. State machine: state := +1 if RoC > upper, -1 if RoC < lower, hold previous otherwise.
4. EMA cross within state direction provides the entry trigger.

🔶 SIGNAL LOGIC

- Buy: state == +1 AND close crosses EMA up AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: state == -1 AND close crosses EMA down.
- Position-lock state machine.

🔶 INPUTS

- RoC Lookback (default 10)
- Pullback EMA Length (default 8)
- Threshold k x ATR Pct (default 0.30)
- Cooldown Bars (default 4)
- Visual: dashboard, glow, EMA toggle, buy / sell colors

🔶 ALERTS

SHM Buy, SHM Sell, SHM Any Signal, SHM Bull Lock, SHM Bear Lock, SHM Upper Cross, SHM Lower Cross, SHM EMA Up, SHM Webhook JSON.

🔶 LIMITATIONS

- Hysteresis prevents flip-flop but slightly lags one-shot regime changes vs single-threshold logic.
- ATR-scaled thresholds are stationarised by atr_pct; very low-volatility periods can leave the state stuck for many bars without entries.
- RoC lookback length affects responsiveness; defaults assume 5m to 1H bars.
- This is a momentum-state engine, not a trend-strength meter; it tells you what regime you are in, not how strong it is.

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.