Regime Lab

  • 程序库
  • Shipra Gupta
    Shipra Gupta
    我是 Shipra Gupta,一名交易员和量化策略开发者,拥有扎实的数学、经济学以及算法交易系统背景。多年来,我长期专注于外汇、黄金、指数、大宗商品及加密货币市场,致力于构建以数据驱动、强调稳定性、精准度与纪律执行的交易策略。
    我的专长包括开发 MetaTrader 5 Expert Advisors(EA)、量化交易模型、剥头皮交易系统、趋势跟随算法、波动率策略以及风险控制自动化框架。我开发的每一个系统都基于市场结构分析、统计研究、历史回测、优化以及真实市场验证。
  • 版本: 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.

作者的更多信息
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 — EMA 交叉 + 智能 TP/SL KN Smart TP SL Signals 是一款简洁的 MetaTrader 5 EMA 交叉指标,可将每一次经过确认的交叉转换为完整的可视化交易方案: Entry → Stop Loss → TP1 → TP2 → TP3 无需手动计算交易水平。 核心逻辑 快速 EMA 向上穿越慢速 EMA → 买入 快速 EMA 向下穿越慢速 EMA → 卖出 信号仅在 已收盘K线 上确认,从而避免当前正在形成的K线产生信号。 核心功能 EMA 交叉信号 可配置快速和慢速 EMA 基于 ATR 的止损 使用可配置 R 倍数计算 TP1 / TP2 / TP3 默认 1.5 ATR 止损 / 1R / 2R / 3R 止盈 自动绘制 Entry、SL 和 TP 水平线 盈利与亏损可视化区域 实时交易跟踪 TP/SL 状态更新 历史信号持续显示,便于复盘 可配置最大历史信号数量 可配置线条延伸长度 MT5 推送通知 ,支持信号、TP 和 SL 支持
IFVG Sniper Entry Engine — MQL5 市场描述 IFVG Sniper Entry Engine 是一款专为 MT5 打造的高精度指标,围绕聪明的钱(Smart Money Concepts)中最具体且高概率的入场模式之一——反转公允价值差值(Inverse Fair Value Gap, IFVG)构建。它默默地追踪图表上生成的每一个原始 Fair Value Gap,监测每个潜在的转化(缓解)机会。一旦确认符合条件的 IFVG,它就会立即触发买入(BUY)或卖出(SELL)信号,并提供完整的 SL/TP 交易布局和推送通知——对包括历史信号在内的每一个信号均有效。 工作原理 在每个确认关闭的 K 线处,引擎都会将新形成的看涨和看跌 Fair Value Gaps 存储到隐藏内存池中——这些差值是大多数指标从未追踪过的。每个隐藏的 FVG 都会随着 K 线逐根增加时间。当随后的收盘价向后穿透存储的差值边界时,该 FVG 就会发生反转:被多头重新收复的看跌差值变成 看涨 IFVG ,被空头跌破的看涨差值变成 看跌 IFVG 。 随后,每一次反转都会通过当前活跃
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 — 带有历史盈亏比回测 Dynmaic HMA 带状指标 Tension Flow Trend 是一款用于 MetaTrader 5 的高级趋势 shadow 指标,它将 赫尔移动平均线 (HMA) 趋势带、Z-Score 动量分析以及内置的直观风险回报比 (Risk:Reward) 回测引擎完美融合于单个图表叠加层中。该指标旨在识别高概率的趋势延续机会,通过要求斜率确认的 HMA 交叉以及可配置的信号冷却时间来过滤市场噪音,从而生成交易设置。 当有效的买入 (BUY) 或卖出 (SELL) 信号出现时,指标会自动计算并在图表上直接绘制出完整的交易结构,包括入场价、基于 ATR(200) 的止损位以及基于风险回报比的止盈位。动态的止盈 (TP) 和止损 (SL) 框会随着 K 线逐根向前延伸,直到触及其中一个级别,从而为每笔完成的交易创建清晰的视觉历史记录。 核心功能 动态赫尔移动平均线 (HMA) 带: 凭借响应迅速的 HMA 计算实现平滑的趋势检测。带状宽度根据市场波动性自动扩展和收缩。牛市和熊市趋势状态通过颜色编码,以便进行快速的视觉 cru
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] 是一款面向 MetaTrader 5(MQL5)的高级多功能趋势跟踪与风险管理指标。它将平滑的 Arnaud Legoux Moving Average(ALMA) 核心与基于波动率和斜率的确认过滤器相结合,用于识别市场趋势、绘制动态颜色趋势带,并自动生成多层级 Risk-to-Reward($R$)交易目标。 核心功能 1. ALMA 趋势带与斜率过滤 ALMA Smoothing Engine: 使用 Arnaud Legoux Moving Average 核心线降低滞后,同时减少市场噪声影响。可调整 Length、Offset 和 Sigma 参数。 Volatility & Slope Validation: 通过测量标准差带以及相对于 Average True Range(ATR)的斜率阈值来确认趋势动能。 Color-Coded Ribbon Fill: 在主图窗口绘制自适应趋势带,根据市场动能偏多或偏空动态改变颜色。 2. 自动信号生成 Flip-
FREE
Structure-Anchored VWAP [WAT] Structure-Anchored VWAP [WAT] 是一款适用于 MetaTrader 5 的市场结构感知型 VWAP 指标。它将 VWAP 锚定在有意义的摆动点和结构点,而不是仅依赖固定的交易时段重置。 它将 市场结构 + 锚定 VWAP + 偏离带 + 回测信号 + ATR 交易管理 整合到一个可视化框架中。 核心功能 3 种锚定模式 — Swing、Structure 和 Fast 结构识别 — HH、HL、LH、LL、EQH 和 EQL Anchored VWAP — VWAP 跟随具有意义的结构性行情移动 偏离带 — 可选 0.5σ 和 2σ 偏离带 Premium / Fair Value / Discount 区域 VWAP 回测信号 — 在可配置的位移幅度后识别回测 基于结构的 VWAP 多空着色 成交量尖峰保护 — 使用成交量中位数进行过滤 基于 ATR 的 SL + TP1 + TP2 + TP3 TP1 后自动移动至保本 实时仪表盘 — 显示趋势、
FREE
Liquidity Intelligence System — MQL5 市场描述 Liquidity Intelligence System 是一款机构级的 MT5 指标,用于绘制聪明的钱(Smart Money)流动性池、检测扫损反转(sweep-and-reverse)设置,并通过 16 个独立可测试的信号模型生成高汇聚度的交易信号——所有这些功能都集成在单个清爽的指标中。 工作原理 该引擎通过检测基于波段高低点(pivot)的买方流动性(BSL)和卖方流动性(SSL)区域,包括等高点(EQH)和等低点(EQL),来持续构建实时流动性图。当价格扫过流动性水平并伴随符合条件的拒绝影线(rejection wick)时,就会生成一个基础的扫损信号。然后 cross 过滤此原始信号,通过多达六个可选的汇聚层:EMA 趋势、公允价值差值(FVG)的存在、成交量激增、RSI 阈值和位移(Displacement)动量烛线质量。最终产生 16 种模型组合,范围从纯流动性扫损(模型 0)到全六重过滤器汇聚(模型 15, LQ+ALL)。 核心功能 16 种信号模型: 仅需通过单一输入即可选择任
Precision Sniper Trader Precision Sniper Trader 是一款专业的趋势 tend 跟踪与动量确认指标,专为在汇市(Forex)、黄金(Gold)、指数(Indices)和加密货币(Crypto)市场中追求清晰图表执行、高概率进场以及结构化交易管理的交易者而设计。 该指标采用精准的“狙击手风格”方法,结合了 EMA 趋势分析、动量确认、基于 ATR 的动态目标以及智能信号过滤,帮助交易者捕捉强有力的市场机会,同时减少图表噪音和不必要的干扰。 与传统的交叉系统 chart 不同,Precision Sniper Trader 专注于趋势对齐、经波动率调整的交易管理以及清晰的执行可视化,非常适合头寸剥头皮(Scalping)、日内交易(Intraday)和波段交易(Swing trading)。 核心功能 高级趋势检测 Precision Sniper Trader 使用多 EMA 结构来识别: 趋势方向 动量转变 市场延续机会 反转确认 该指标能动态适应不断变化的市场环境,同时保持清晰且响应迅速的信号。 狙击手级买入与卖出信号 该指标通过以下技术生
FREE
TrendIQ pro
Shipra Gupta
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 指标 面向 MetaTrader 5 的专业级波动率挤压与动量突破交易系统 Squeeze Momentum Breakout 是一款专业级的 MT5 突破指标,旨在捕捉低波动率盘整期后的爆发性市场行情。该指标专为头寸黄牛党(Scalpers)、日内交易者和动量交易者量身定制,将波动率挤压、动量确认、成交量过滤以及结构化交易管理完美融合于一个完整的交易框架中。 指标可自动识别挤压区域、突破机会、趋势扩张阶段,并在图表上动态绘制入场点(Entry)、止损点(Stop Loss)、以及 TP1、TP2、TP3 点位,实现结构化的交易执行与管理。 针对以下市场进行了优化: XAUUSD (黄金) 外汇货币对 NASDAQ / US30 加密货币市场 股指 黄牛交易与日内交易 核心功能 高级挤压检测算法: 在爆发性突破行情发生前,精准捕捉低波动的盘整区域。 自动买入与卖出信号: 突破确认后,生成清晰的多头(Long)和空头(Short)突破信号。 智能突破确认: 融合布林带(Bollinger Bands)、肯特纳通道(Keltner
FREE
VOLUME BREAKOUT PRO MT5 指标 面向 MetaTrader 5 的专业级成交量扩张与突破交易系统 Volume Breakout Pro 是一款专为 MetaTrader 5 平台开发的机构级突破交易指标。该系统专为高频黄牛(Scalpers)、日内交易者以及动量突破交易者设计,核心在于精准捕捉由异常成交量扩张和流动性失衡引发 The 爆发性价格行情。 该指标完美融合了: 量权振荡器(Volume Weighted Oscillator)逻辑 枢轴点(Pivot)突破检测 动量扩张加速 基于 ATR 的交易风险管理 动态突破结构映射 直接在图表上为您提供具备专业风险管理的高概率突破交易机会。 Volume Breakout Pro 能够自动检测: 注入成交量的多头突破(Bullish Volume Breakouts) 伴随放量的空头跌破(Bearish Volume Breakdowns) 流动性扩张区域 枢轴点结构破位(Pivot Structure Breaks) 成交量驱动的动量转换 并在盘中实时动态绘制: 买入/卖出信号(Buy/Sell Signals
FREE
Meridian Flow — MT5 Smart Money Structure 指标 Meridian Flow 是一款专为使用 Smart Money Concepts (SMC) 和 ICT Price Action 方法论的交易者打造的 MetaTrader 5 指标。它可以在任意品种和时间周期上自动识别 BOS(Break of Structure)和 CHoCH(Change of Character),并为每个信号绘制完整的风险地图——Entry、Stop Loss、TP1、TP2 和 TP3,包括历史信号。 信号只会在确认后的已收盘 K 线上触发。 不重绘,不猜测。 Meridian Flow 的独特之处 大多数结构指标只显示当前活跃交易。Meridian Flow 会为图表上的每一个历史信号绘制 SL 和 TP 水平,并让每个信号拥有独立的未来 K 线显示范围。这样,你可以在投入真实资金之前,直观地检查指标在不同市场环境下的表现。 Stop Loss 根据 ATR(Average True Range)计算,因此会自动适应当前品种的波动率。当 TP1 被触发后,S
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
筛选:
无评论
回复评论