Indicator · Pine Script v6 · On the chart

DST HMM v9 XAUUSD

by Javas128282

DST HMM v9 XAUUSD classifies the market into hidden regimes such as Sideways, Bull and Bear using a hidden Markov model retrained on a rolling window with Baum-Welch iterations.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code1,419
Settings40inputs
LicenceNone stated
Last update5 months ago1 Jun 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.

Overview

DST HMM v9 XAUUSD adds a Kalman filter line with confidence bands and an optional multi-bar Kalman forecast cone, a confidence measure, and adaptive stop loss and take profit lines. Several tables show model internals. It is designed for gold on the hourly chart and draws on the price chart.

Details

Published by

Javas128282 on GitHub

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

AI / machine learning, Trend, Volatility & bands

Markets

Gold

Timeframes

M15-H1

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

hidden-markov-modelhmm-viterbi-algorithmindicator-analysispinescripttrading-strategy-simulation

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Process Noise Q (base)float0.01kf_q_base
Q ATR Multiplier (adaptive Q)float2.0kf_q_atr_mul
Measurement Noise Rfloat1.0kf_r
Confidence Band Multiplierfloat1.5kf_band_mult
Gunakan KF sebagai Fitur HMMbooltrueuse_kf_feat
SL/TP Berbasis KF Pricebooltruekf_sl_base
Plot KF Line + Band di Chartbooltrueshow_kf_plot
Plot KF Velocity (histogram)boolfalseshow_kf_vel
Show Kalman N-Step Forecastbooltrueshow_kf_fcast
Forecast Steps (bars ahead)int10kf_fcast_steps
Forecast Cone Multiplierfloat1.0kf_fcast_cone
Forecast Color (up trend)colorcolor.rgb(80,200,255,60)kf_fcast_col_up
Show all 40 settings
SettingTypeDefaultVariable
Forecast Color (down trend)colorcolor.rgb(255,150,80,60)kf_fcast_col_dn
Forecast Color (flat)colorcolor.rgb(180,180,180,60)kf_fcast_col_flat
Jumlah Hidden States (N)int3n_states
Training Window (bars)int150hmm_win
Baum-Welch Iterationsint3bw_n
Min Emission sigmafloat0.30sig_floor
Stationary Power (A^n)int30stat_pow
Min Duration - Sideways (bars)int2min_dur_s
Min Duration - Bull/Bear (bars)int1min_dur_b
Regularization Strengthfloat0.30reg_str
Min State Occupancy (%T)float0.05min_occ_pct
Posterior Temperaturefloat3.0temp_scale
Retraining Interval (bars)int20retrain_interval
Adaptive Retraining Triggerbooltrueuse_adaptive
Vol Shock Threshold (z_atr)float2.0vol_shock_thr
Vol Shock Persistence (bars)int3vol_shock_bars
Regime Flip Window (bars)int10flip_window
Max Regime Flips in Windowint4flip_limit
Confidence Collapse Thresholdfloat0.20conf_collapse_thr
Adaptive Retraining Cooldown (bars)int5retrain_cooldown
Z-Score Windowint20z_win
EMA Length (fallback slope)int21ema_len
Slope Lookback (fallback)int14slope_per
ATR Length (fitur)int14atr_len_f
Volume Z-Score Windowint20vol_len_f
ATR Length (SL/TP)int14atr_len_sl
Base SL Mult - Bullfloat1.2atr_bull_base
Base SL Mult - Bearfloat1.5atr_bear_base
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

46 stars

This indicator uses a Hidden Markov Model (HMM) framework combined with an adaptive dual moving average engine and Directional Movement Index (DMI) features to identify market regimes (bullish, bearish, or ranging/chop). It calculates regime probabilities on e

Indicator v5 AI / machine learningTrend
Updated 7 weeks ago · None stated GitHub repository of HMM Enhanced: Regime Probability

This overlay indicator plots a SuperTrend-style band on the price chart using ATR length, a selectable source, and a base factor. Optional settings enable an adaptive factor driven by rate of change, a volatility filter, K-means clustering, and an LSTM layer w

Indicator v6 TrendVolatility & bands
Updated 4 months ago · MIT GitHub repository of ML SuperTrend (Ultimate) - Auto-Optimized AI with LSTM

Chandelier Flip Radar plots an ATR trailing stop on the price chart and tracks a directional trend state. It holds a ratchet stop until an accepted flip, using close or wick extremums and a body filter so weak breaks do not change direction. Distance to the fl

Indicator v6 TrendVolatility & bands
Updated 2 days ago · MIT GitHub repository of Chandelier Flip Radar [WavesUnchained]

This indicator calculates a volatility-adaptive SuperTrend by applying k-means clustering to ATR values over a user-defined training period. It segments historical volatility into high, medium, and low clusters to dynamically adjust the SuperTrend bands to shi

Indicator v5 TrendVolatility & bands
Updated 8 months ago · None stated GitHub repository of Machine Learning Adaptive SuperTrend [AlgoAlpha]
1 stars

A chart-overlay trailing stop that adapts to market conditions. It uses Kaufman's adaptive moving average to measure how efficiently price is moving, scales an ATR-based stop distance accordingly, and optionally adds a k-nearest-neighbours pattern layer that n

Indicator v6 TrendVolatility & bands
Updated 9 months ago · None stated GitHub repository of Adaptive ML Trailing Stop

More indicators

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers