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).
1Copy the scriptPress Copy script above, or the copy button on the code below.
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
382 lines of Pine Script v5 from HMM Enhanced Regime Probability.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.
HMM Enhanced: Regime Probability calculates regime probabilities on each bar using transition probability matrices and optional adaptive online learning. On the main price chart, it plots a smoothed dual moving average midline and a ratcheting trailing stop level, while rendering an on-screen status table that displays real-time regime probability readings. Input settings allow users to adjust moving average types, band calculations, ADX parameters, transition matrix probabilities, and visual styles.
Hidden Markov Model regime probability calculation
Adaptive dual moving average trend engine with ATR/Range bands
Adaptive online learning for emission parameters
Ratcheting trailing stop level and trend midline plots
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Source
source
hlc3
source
Adaptive Length
int
20
length
Smoothing
int
20
smoothing
Band Multiplier
float
1.0
multiplier
Band Type
string
True Range
bandtype
MA Type
string
WMA
macalc
Use Min/Max Ratchet
bool
false
usemm
Show Basis (Dual MA Midline)
bool
true
show_basis
Show Trailing Level
bool
true
show_trail
Basis Line Width
int
2
basis_width
Trail Line Width
int
1
trail_width
DMI Length
int
14
adx_len
Show all 30 settings
Setting
Type
Default
Variable
ADX Smoothing
int
14
adx_smooth
Z-Score Lookback
int
50
zscore_len
P(Bull | Bull)
float
0.80
p_stay_bull
P(Bear | Bear)
float
0.80
p_stay_bear
P(Chop | Chop)
float
0.60
p_stay_chop
Enable Adaptive Learning
bool
true
use_learning
Learning Rate
float
0.05
learn_rate
Min Emission Std Dev
float
0.3
learn_floor
Emission Temperature
float
2.0
emission_temp
Color Transition Speed
float
0.4
color_smooth
Bull Weak
color
color.teal
c_bull_start
Bull Strong
color
color.lime
c_bull_end
Bear Weak
color
color.red
c_bear_start
Bear Strong
color
color.orange
c_bear_end
Chop Weak
color
color.aqua
c_chop_start
Chop Strong
color
color.blue
c_chop_end
Table Position
string
Top Right
table_pos
Table Text Size
string
Small
table_size
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 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
This indicator classifies the market into gamma regime types (negative gamma trend, positive gamma mean-reversion, or transition) by calculating a composite score based on daily ATR ratios, session VWAP crossover frequencies, and opening range displacement. It
This indicator calculates standardized trend strength and historical volatility to estimate position sizes. It computes the differences between three user-defined EMAs standardized by price using MACD logic, while historical volatility is derived from the stan
Adaptive Fair Value Cloud calculates a volatility-adaptive fair value channel around a selectable centerline, such as KAMA, EMA, linear regression, or VWMA. It blends ATR and mean deviation with volatility percentiles and trend sensors, including ADX, Efficien
Dynamic Extreme Channels & Reversals tracks evolving price highs and lows to plot adaptive channel bands and a midline directly on the price chart. When no new extremes occur within the specified lookback window, the channel boundaries interpolate toward price
This indicator scans a pasted list of symbols and shows matching long and short setups in a table in a separate pane. It uses a Supertrend crossover, then applies an ATR or fixed-point volatility range so quiet, sideways conditions can be skipped. Optional fil