Regime Lab

  • Bibliotecas
  • Shipra Gupta
    Shipra Gupta
    Sou Shipra Gupta, trader e desenvolvedora de estratégias quantitativas com sólida formação em matemática, economia e sistemas de trading algorítmico. Ao longo dos anos, trabalhei amplamente nos mercados de forex, ouro, índices, commodities e criptomoedas, focando na construção de estratégias
  • Versão: 1.0

RegimeLab – Hidden Markov Model & Market Regime Detection

Most EAs fail because they run the right logic in the wrong regime. RegimeLab tells your EA which regime it is in, using published statistics instead of another moving average.

Features

  • Hidden Markov Model – 2-state Gaussian HMM fitted by Baum-Welch: probability of the turbulent state, state means, volatilities, persistence and expected duration.
  • Hurst exponent – Rescaled-range estimate on any symbol/timeframe or on your own array.
  • Variance ratio z-test – Lo-MacKinlay heteroskedasticity-robust test of momentum vs mean reversion.
  • Efficiency ratio – Kaufman path efficiency from 0 (noise) to 1 (straight line).
  • Volatility percentile – Current Wilder ATR ranked against its own history.
  • Composite label – TREND_UP, TREND_DOWN, MEAN_REVERT, RANDOM or HIGH_VOL in one call.

Quick start

1. Buy and download the library. MetaTrader installs it to MQL5\Libraries\RegimeLab.ex5.
2. Paste the import block below at the top of your EA, indicator or script.
3. Call the functions.

void OnTick()
  {
   int r=RL_Regime(_Symbol,PERIOD_H1,500,1,0.70,1.96);
   if(r==RL_REGIME_HIGH_VOL) return;                 // stand aside
   if(r==RL_REGIME_TREND_UP || r==RL_REGIME_TREND_DOWN) RunTrend(r);
   if(r==RL_REGIME_MEAN_REVERT) RunMeanRevert();
  }

Import block (copy into your code)

#define RL_OK            0
#define RL_ERR_PARAM     1
#define RL_ERR_DATA      2
#define RL_ERR_SYMBOL    3
#define RL_ERR_FIT       4
#define RL_REGIME_UNKNOWN      0
#define RL_REGIME_TREND_UP     1
#define RL_REGIME_TREND_DOWN   2
#define RL_REGIME_MEAN_REVERT  3
#define RL_REGIME_RANDOM       4
#define RL_REGIME_HIGH_VOL     5

#import "RegimeLab.ex5"
int RL_LastError();
double RL_Hurst(const string symbol,const ENUM_TIMEFRAMES tf,const int bars,const int shift);
double RL_HurstArray(const double &series[],const bool is_price);
bool RL_VarianceRatio(const string symbol,const ENUM_TIMEFRAMES tf,const int bars,const int q, const int shift,double &vr,double &z);
double RL_EfficiencyRatio(const string symbol,const ENUM_TIMEFRAMES tf,const int period,const int shift);
double RL_VolPercentile(const string symbol,const ENUM_TIMEFRAMES tf,const int atr_period, const int lookback,const int shift);
double RL_HMMFit(const string symbol,const ENUM_TIMEFRAMES tf,const int bars,const int shift, const int max_iter);
bool RL_HMMParams(const int state,double &mean,double &stdev,double &stay_prob);
double RL_HMMExpectedDuration(const int state);
double RL_HMMLogLikelihood();
int RL_Regime(const string symbol,const ENUM_TIMEFRAMES tf,const int bars,const int shift, const double hivol_prob,const double z_crit);
string RL_RegimeName(const int regime);
#import

Notes

  • Uses completed bars (shift ≥ 1): no repaint, no look-ahead.
  • 64 to 20,000 bars per call; bounded for optimisation.
  • Any symbol and timeframe, so multi-symbol and multi-timeframe filters fit in one EA.

Technical

  • Pure MQL5. No DLL, no WebRequest, no file I/O.
  • Every exported function validates its inputs. RL_LastError() returns the reason for any failed call.
  • Works in the Strategy Tester and live, on any broker, symbol and account currency.

Past performance shown in screenshots is from historical data and does not guarantee future results.

Mais do autor
AMD Po3
Shipra Gupta
AMD Po3 for MetaTrader 5 Accumulation, manipulation, distribution: mapped for you. AMD Po3 is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator maps the reaction zones that matter right now: the nearest areas above and
KN Smart TP SL Signals — Cruzamento de EMA + TP/SL Inteligentes KN Smart TP SL Signals é um indicador limpo de cruzamento de EMA para MetaTrader 5 que transforma cada cruzamento confirmado em uma configuração visual completa de trade: Entry → Stop Loss → TP1 → TP2 → TP3 Não é necessário calcular os níveis manualmente. Lógica Principal EMA rápida cruza acima da EMA lenta → Compra EMA rápida cruza abaixo da EMA lenta → Venda Os sinais são confirmados em candles fechados , evitando sinais gerados
IFVG Sniper Entry Engine — Descrição para o MQL5 Marketplace O IFVG Sniper Entry Engine é um indicador de precisão para MT5 construído em torno de um dos padrões de entrada mais específicos e de alta probabilidade do Smart Money Concepts — o Gap de Valor Justo Inverso (Inverse Fair Value Gap, IFVG). Ele rastreia silenciosamente cada Fair Value Gap bruto formado no gráfico, monitora cada um em busca de inversão (mitigação) e, no momento em que um IFVG qualificado é confirmado, dispara um sinal de
Coppock Curve MultiFilter for MetaTrader 5 The classic Coppock curve with modern filters. Coppock Curve MultiFilter is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator plots its oscillator in a separate subwindow with
FREE
Tension Flow Trend — Faixa HMA Dinâmica com Backtest Histórico de RR O Tension Flow Trend é um indicador avançado de acompanhamento de tendências para o MetaTrader 5 que combina uma faixa de tendência de Média Móvel de Hull (HMA), análise de momentum Z-Score e um mecanismo de backtesting visual de Risco:Recompensa (Risk:Reward) integrado em uma única sobreposição de gráfico. Projetado para identificar oportunidades de continuação de tendência de alta probabilidade, o indicador filtra o ruído do
FREE
Adaptive RSI Supertrend for MetaTrader 5 Trend and RSI momentum in one view. Adaptive RSI Supertrend is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend: bull co
FREE
Trend Target Ribbon [BOSWaves] Trend Target Ribbon [BOSWaves] é um indicador avançado e multifuncional de acompanhamento de tendência e gestão de risco desenvolvido para MetaTrader 5 (MQL5). Ele combina uma Arnaud Legoux Moving Average (ALMA) suavizada com filtros de confirmação baseados em volatilidade e inclinação para mapear tendências de mercado, ribbons dinâmicos com cores e projeções automatizadas de operações em múltiplos níveis de Risk-to-Reward ($R$). Principais recursos 1. Ribbon de te
FREE
Structure-Anchored VWAP [WAT] Structure-Anchored VWAP [WAT] é um indicador VWAP para MetaTrader 5 orientado pela estrutura de mercado. Ele ancora o VWAP em swings e pontos estruturais relevantes, em vez de depender apenas de reinicializações fixas de sessão. Combina Estrutura de Mercado + VWAP Ancorado + Bandas de Desvio + Sinais de Reteste + Gestão de Operações baseada em ATR em uma única estrutura visual. Principais recursos 3 modos de ancoragem — Swing, Structure e Fast Detecção de estrut
FREE
Liquidity Intelligence System — Descrição para o MQL5 Marketplace O Liquidity Intelligence System é um indicador MT5 de nível institucional que mapea pools de liquidez de Smart Money, detecta configurações de captura e reversão (sweep-and-reverse) e gera sinais de negociação de alta confluência por meio de 16 modelos de sinal testáveis de forma independente — tudo dentro de um único indicador limpo. Como Funciona O mecanismo constrói continuamente um mapa de liquidez em tempo real, detectando zo
Precision Sniper Trader O Precision Sniper Trader é um indicador profissional de acompanhamento de tendência e confirmação de momentum, projetado para traders que exigem uma execução limpa no gráfico, entradas de alta probabilidade e gerenciamento estruturado de operações nos mercados de Forex, Ouro, Índices e Criptomoedas. Desenvolvido com uma abordagem estilo "sniper" (franco-atirador), o indicador combina análise de tendência por EMA, confirmação de momentum, alvos dinâmicos baseados em ATR e
FREE
TrendIQ Pro for MetaTrader 5 Adaptive volatility trend with a trend cloud. TrendIQ Pro is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend: bull colour for long
SQUEEZE MOMENTUM BREAKOUT MT5 INDICATOR Sistema Profissional de Trading de Rompimento de Momentum e Compressão de Volatilidade para MetaTrader 5 O Squeeze Momentum Breakout é um indicador de rompimento (breakout) de nível profissional para MT5, projetado para detetar movimentos explosivos do mercado após períodos de consolidação com baixa volatilidade. Desenvolvido para scalpers, traders intradiários (day traders) e traders de momentum, o indicador combina compressão de volatilidade, confirmação
FREE
VOLUME BREAKOUT PRO MT5 INDICATOR Sistema Profissional de Trading de Expansão de Volume e Rompimento para MetaTrader 5 O Volume Breakout Pro é um indicador de rompimento (breakout) de nível institucional desenvolvido especificamente para a plataforma MetaTrader 5. Projetado para scalpers, day traders e traders de momentum, o sistema foca-se na identificação de movimentos explosivos de preço impulsionados por uma expansão anormal de volume e desequilíbrio de liquidez. O indicador combina: Lógica
FREE
Meridian Flow — Indicador de Smart Money Structure para MT5 Meridian Flow é um indicador para MetaTrader 5 desenvolvido para traders que utilizam Smart Money Concepts (SMC) e a metodologia de ICT Price Action . Ele detecta automaticamente eventos BOS (Break of Structure) e CHoCH (Change of Character) em qualquer ativo e timeframe, desenhando um mapa de risco completo — Entry, Stop Loss, TP1, TP2 e TP3 — para cada sinal, incluindo sinais históricos. Os sinais são gerados apenas em candles fechad
Adaptive Trend System for MetaTrader 5 A trend line that adapts to volatility. Adaptive Trend System is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend: bull co
Market Path Forecast for MetaTrader 5 Projected price paths from swing statistics. Market Path Forecast is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator detects confirmed swing highs and lows and tracks how price b
FREE
RSI Signal Entries for MetaTrader 5 RSI extremes plus candle confirmation. RSI Signal Entries is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator plots its oscillator in a separate subwindow with clear extreme zones.
FREE
Trident Swing Projector for MetaTrader 5 Quarter-swing projections from ABC structures. Trident Swing Projector is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator detects confirmed swing highs and lows and tracks how
Z-Score Range Boxes Breakout for MetaTrader 5 Statistical extremes boxed, breakouts flagged. Z-Score Range Boxes Breakout is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator tracks the range or channel price is tradin
Precision Sniper Pro for MetaTrader 5 Four pillars: EMA, RSI, MACD and ADX. Precision Sniper Pro is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator watches for its signal condition and waits for the candle to close b
FREE
Stealth Trail Supertrend for MetaTrader 5 A supertrend that adapts its own multiplier. Stealth Trail Supertrend is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the tre
Fibonacci Path Profile for MetaTrader 5 How price moved after similar retracements. Fibonacci Path Profile is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator detects confirmed swing highs and lows and tracks how pric
Strong Fade Signals for MetaTrader 5 Fade the overextended move, with a score. Strong Fade Signals is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator watches for its signal condition and waits for the candle to close
FREE
Fan Principle Signals for MetaTrader 5 The classic fan principle, as clear signals. Fan Principle Signals is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator detects confirmed swing highs and lows and tracks how price
McGinley Dynamic Fusion for MetaTrader 5 McGinley Dynamic crossovers with ATR levels. McGinley Dynamic Fusion is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend
Liquidity Entry Signals for MetaTrader 5 Entries where liquidity gets taken. Liquidity Entry Signals is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator maps the reaction zones that matter right now: the nearest areas
Cardwell Range Pro for MetaTrader 5 RSI ranges that change with the market regime. Cardwell Range Pro is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator plots its oscillator in a separate subwindow with clear extreme
Adaptive RSI Supertrend for MetaTrader 5 Trend and RSI momentum in one view. Adaptive RSI Supertrend is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator draws one trend line that changes colour with the trend: bull co
Market Structure Target Tracker for MetaTrader 5 Swings, BOS, CHoCH and ATR targets. Market Structure Target Tracker is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator detects confirmed swing highs and lows and track
Smart TrendFlow Pro for MetaTrader 5 Channel breaks with a volatility heatmap. Smart TrendFlow Pro is a MetaTrader 5 indicator built for traders who want clear, rule-based chart reading without clutter. It focuses on one job and does it visibly on your chart, so you can make decisions faster and with more confidence. It works on gold (XAUUSD), forex, indices and crypto, on any timeframe from M5 to D1. How it works The indicator tracks the range or channel price is trading in and highlights per
Filtro:
Sem comentários
Responder ao comentário