1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
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 Mobile classifies the market into Sideways, Bull and Bear states using Baum-Welch retraining on a rolling window, draws a Kalman filter line with confidence bands and an optional forecast cone, and shows adaptive stop loss and take profit lines. A table can be placed on screen. It draws on the price chart.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Process Noise Q (base)
float
0.01
kf_q_base
Q ATR Multiplier (adaptive Q)
float
2.0
kf_q_atr_mul
Measurement Noise R
float
1.0
kf_r
Confidence Band Multiplier
float
1.5
kf_band_mult
Gunakan KF sebagai Fitur HMM
bool
true
use_kf_feat
SL/TP Berbasis KF Price
bool
true
kf_sl_base
Plot KF Line + Band di Chart
bool
true
show_kf_plot
Plot KF Velocity (histogram)
bool
false
show_kf_vel
Show Kalman N-Step Forecast
bool
true
show_kf_fcast
Forecast Steps (bars ahead)
int
10
kf_fcast_steps
Forecast Cone Multiplier
float
1.0
kf_fcast_cone
Forecast Color (up)
color
color.rgb(80,200,255,60)
kf_fcast_col_up
Show all 40 settings
Setting
Type
Default
Variable
Forecast Color (down)
color
color.rgb(255,150,80,60)
kf_fcast_col_dn
Forecast Color (flat)
color
color.rgb(180,180,180,60)
kf_fcast_col_flat
Jumlah Hidden States (N)
int
3
n_states
Training Window (bars)
int
150
hmm_win
Baum-Welch Iterations
int
3
bw_n
Min Emission sigma
float
0.30
sig_floor
Stationary Power (A^n)
int
30
stat_pow
Min Duration - Sideways (bars)
int
2
min_dur_s
Min Duration - Bull/Bear (bars)
int
1
min_dur_b
Regularization Strength
float
0.30
reg_str
Min State Occupancy (%T)
float
0.05
min_occ_pct
Posterior Temperature
float
3.0
temp_scale
Retraining Interval (bars)
int
20
retrain_interval
Adaptive Retraining Trigger
bool
true
use_adaptive
Vol Shock Threshold (z_atr)
float
2.0
vol_shock_thr
Vol Shock Persistence (bars)
int
3
vol_shock_bars
Regime Flip Window (bars)
int
10
flip_window
Max Regime Flips in Window
int
4
flip_limit
Confidence Collapse Threshold
float
0.20
conf_collapse_thr
Adaptive Retraining Cooldown (bars)
int
5
retrain_cooldown
Z-Score Window
int
20
z_win
EMA Length (fallback slope)
int
21
ema_len
Slope Lookback (fallback)
int
14
slope_per
ATR Length (fitur)
int
14
atr_len_f
Volume Z-Score Window
int
20
vol_len_f
ATR Length (SL/TP)
int
14
atr_len_sl
Base SL Mult - Bull
float
1.2
atr_bull_base
Base SL Mult - Bear
float
1.5
atr_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.
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
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
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
This overlay indicator builds many SuperTrend trailing stops across a user-set ATR length, factor range, and step. Each factor is scored with an exponential performance memory. K-means clustering groups those results, and the user chooses the best, average, or
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
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