Communications on Applied Nonlinear Analysis ISSN: 1074-133X Vol 32 No. 9S (2025) https://internationalpubls.com 3242 Regime-Aware Short-Term Trading Strategy Using Hidden Markov Models and Monte Carlo Simulation Chaitya Shah1*, Ayush Shah2, Dr. Nilesh Patil3, Darsh Jain4 1*Dept. of Computer Engineering, Dwarkadas J. Sanghvi College of Engineering, Mumbai, India shahchaitya8@gmail.com, ORCID : 0009-0006-3727-1199 2Dept. of Computer Engineering, Dwarkadas J. Sanghvi College of Engineering, Mumbai, India ayushshah979@gmail.com, ORCID : 0009-0004-2940-0267 3Associate Professor, Dept. of Computer Engineering, Dwarkadas J. Sanghvi College of Engineering Mumbai, India, nilesh.p@djsce.ac.in, ORCID : 0000-0001-8335-4426 4Dept. of Computer Engineering, Dwarkadas J. Sanghvi College of Engineering, Mumbai, India darshjain368@gmail.com, ORCID : 0009-000-8936-2586 *Corresponding Author: Chaitya Shah *Dwarkadas J. Sanghvi College of Engineering, Mumbai, India shahchaitya8@gmail.com, ORCID : 0009-0006-3727-1199 Article History: Abstract: This paper presents a new short term trading strategy for financial markets that considers market regimes. It uses Hidden Markov Models (HMMs) to identify market states dynamically and Monte Carlo simulation for short term price forecasting. By modeling underlying market conditions (such as bull, bear, or stagnation) through a Gaussian HMM, the strategy adjusts its trading signals according to current market conditions. We also apply Monte Carlo simulation, specifically Geo- metric Brownian Motion (GBM), to predict 1,000 future 5 day price paths. This approach quantifies uncertainty and enables buy/sell decisions based on price percentiles. The strategy has been thoroughly backtested using daily adjusted closing prices of the NIFTY 50 index (NSEI) from January 2018 to December 2024. Backtesting results show a Sharpe Ratio of 1.0461, a Sortino Ratio of 1.5119, and a Cumulative Return of 44.83%. This significantly outperforms a traditional buy-and-hold strategy, which produced a Sharpe Ratio of about 0.67, a Cumulative Return of around 26.44%, and a Maximum Drawdown of roughly -38.44% during the same time, while achieving similar annualized returns but with notably lower volatility and drawdowns. This framework improves signal accuracy and risk management, offering a solid approach to short- term trading. Key Words : Hidden Markov Models, Monte Carlo Simulation, Regime Detection, Trading Strategy I. INTRODUCTION Traditional short term trading strategies often assume that markets are stable. This is an oversimplification given the dynamic and non-linear behavior of financial markets. Market behavior, marked by different levels of volatility, mean returns, and autocorrelation, often shifts between different phases or ’regimes’ such as bullish, bearish, or stagnant. Ignoring these shifts can lead to poor decision making, higher risk, and lower profits, especially in volatile times. To tackle this issue, quantitative finance increasingly relies on advanced modeling techniques. This paper introduces a strategy that combines two effective methods: Hidden Markov Models (HMMs) to identify unseen market states and Monte Carlo simulation for generating probabilistic short term price forecasts. By adjusting forecasting parameters based on the identified market regime, our strategy seeks to create more accurate and adaptable trading signals. II. RELATED WORK Financial markets are inherently dynamic and characterized by regime shifts such as bull, bear, and stagnant phases. Traditional time-series models often assume stationarity, but such assumptions fail to capture structural changes in volatility and return distributions. To overcome these limitations, Received: 03-01-2025 Revised: 11-01-2025 Accepted: 17-01-2025 mailto:shahchaitya8@gmail.com mailto:ayushshah979@gmail.com mailto:nilesh.p@djsce.ac.in mailto:darshjain368@gmail.com mailto:shahchaitya8@gmail.com Communications on Applied Nonlinear Analysis ISSN: 1074-133X Vol 32 No. 9S (2025) https://internationalpubls.com 3243 researchers have increasingly employed probabilistic models and simulation-based ap- proaches for regime detection and forecasting. Several studies have explored the use of Hidden Markov Models (HMMs) in finance. Pavlidis et al. [1] demonstrated how HMMs effectively capture the latent state dynamics of financial time series, while Lee et al. [2] combined HMMs with Genetic Algorithms to improve forecasting performance. Nystrup et al. [3] focused on regime-switching models for asset allocation, emphasizing the value of adapting portfolio strategies to different market conditions. Beyond market forecasting, Park and Lee [4] applied HMMs to credit risk assess- ment, showcasing the model’s flexibility across financial applications. In parallel, Monte Carlo methods have been widely adopted in quantitative finance. Glasserman [5] established Monte Carlo simulation as a key tool in financial engineering, particularly for derivative pricing and risk management. Hull [6] further highlighted its application in options pricing and uncertainty quantification. Singh et al. [7] applied Monte Carlo methods to market risk estimation, while Singh and Singh [8] extended the approach to stock price prediction using simulation and machine learning. Finally, Hamilton’s foundational work on regime switching time series models [9] laid the groundwork for integrating hidden states into economic and financial modeling. This work influenced much of the subsequent literature on combining state inference with forecasting. While these prior studies either focused on HMM- based regime detection or Monte Carlo-based forecasting, relatively few approaches integrate both. Existing HMM research often stops at identifying regimes without translating them into forward-looking price predictions, whereas Monte Carlo studies typically ignore the structural dynamics of different market states. Our work bridges this gap by combining HMMs with Monte Carlo simulation: HMMs identify the prevailing market regime, and the corresponding regime-specific parameters are used to condition Monte Carlo forecasts. This hybrid framework enhances predictive accuracy while improving risk adjusted performance in short-term trading. III. METHODOLOGY A. Data Source We gathered daily adjusted closing prices for the NIFTY 50 index (ˆNSEI) from Yahoo Finance from January 1, 2018, to December 31, 2024. The log return at time t is calculated as: Rt = ln(Pt/Pt−1) (1) where Pt is the adjusted closing price at time t. B. Hidden Markov Model A Hidden Markov Model (HMM) is a probabilistic model designed to capture systems that evolve through a sequence of hidden (unobservable) states, where each hidden state generates observable data according to a probability distribution. In financial markets, the under lying market regime (e.g., bull, bear) is not directly observable but can be inferred from observed returns. Formally, an HMM is defined by three components: 1) Initial state distribution: πi = P (S1 = i),i = 1, . . . , K (2) where St represents the hidden regime at time t, and K is the total number of hidden states. 2) State transition probabilities: (3) Communications on Applied Nonlinear Analysis ISSN: 1074-133X Vol 32 No. 9S (2025) https://internationalpubls.com 3244 j j which define how likely the market is to switch from regime i to regime j. 3) Emission (observation) probabilities: Each state j generates observed returns Rt according to a Gaussian distribution: Rt | St = j ∼ N (µj, σ 2) (4) where µj and σ2 are the mean and variance of returns in regime j. The joint probability of observing a sequence of returns R = (R1, R2, . . . , RT ) and hidden states S = (S1, S2, . . . , ST ) can be written as: (5) To estimate the parameters θ = (π, A, µj, σ 2), we used the Expectation-Maximization (EM) algorithm, also known as the Baum-Welch algorithm, which maximizes the likelihood of the observed data: (6) The Hidden Markov Model not only identifies the most likely market regime at each point in time but also provides the regime specific parameters, namely the mean return µj and volatility σj. These parameters are then used as inputs to the Monte Carlo simulation. In particular, the drift and diffusion terms of the Geometric Brownian Motion are set to the values estimated from the current regime, ensuring that simulated price paths are consistent with the statistical characteristics of that regime. Thus, the HMM serves as a regime aware parameter generator, while the Monte Carlo step translates these parameters into forward looking distributions of possible prices. In our study, we trained a Gaussian HMM with two hidden states on daily log returns of the NIFTY 50 index. The log-likelihood of the fitted model was 5659.65, indicating a good statistical fit. These hidden states were later interpreted as distinct market regimes typically resembling bullish, bearish-which form the basis for regime aware forecasting in the subsequent Monte Carlo simulation step. C. Monte Carlo Forecasting Upon determining the current market regime, we simulate 1,000 future 5 day price paths using Geometric Brownian Motion (GBM). The drift (µ) and volatility (σ) parameters are dynamically set based on the identified HMM regime. The discrete-time simulation is: (7) where Z is a standard normal random variable. From this distribution, the 25th percentile (P25) and 75th percentile (P75) are computed. D. Signal Generation Trading signals are generated daily based on the current price compared to the forecasted P25 and P75 values. Buy signals are generated if the current price is below P25, sell signals if above P75, and hold signals if the price is between the two percentiles. E. Methodology Pipeline (HMM + Monte Carlo) The pipeline shown in Figure 1 is summarized stage-by- stage below: • Data collection & preprocessing : Download adjusted close prices and compute log returns; handle missing values and basic cleaning. Communications on Applied Nonlinear Analysis ISSN: 1074-133X Vol 32 No. 9S (2025) https://internationalpubls.com 3245 Fig. 1. Methodological pipeline for the regime-aware trading strategy, spanning data collection, regime detection, Monte Carlo forecasting, signal generation, and backtesting. • HMM regime detection : Fit a Gaussian Hidden Markov Model to returns, infer hidden states and regime parameters (means, covariances, transition matrix). • Model evaluation : Compute log-likelihood, per regime statistics (mean, std, count) and visualize transition probabilities to interpret regime persis- tence. • Regime-conditioned Monte Carlo forecasting : Use regime specific drift and volatility to run GBM simulations (1,000 paths, 5-day horizon), apply variance-reduction/reproducibility where needed, and compute terminal percentiles (P25, P75). • Signal generation Produce Buy / Hold / Sell by comparing current price to P25/P75 percentiles; convert signals to tradable positions (shifted to next period to avoid look ahead). • Backtesting & execution mechanics : Apply shifted signals to returns, include transaction costs/slippage and position sizing as approprate; compute cumulative strategy and buy and hold benchmarks for comparison. • Performance metrics & statistical validation : Report cumulative/annualized return, volatility, Sharpe, Sortino, maximum drawdown, Calmar, win rate and (optionally) bootstrap confidence intervals for robustness. • Visualization & iteration : Produce Monte Carlo fan plots, cumulative return curves, drawdown plots, return histograms and rolling Sharpe; use results to tune HMM components, forecast horizon, simulation size and percentile thresholds in an iterative optimization loop. Communications on Applied Nonlinear Analysis ISSN: 1074-133X Vol 32 No. 9S (2025) https://internationalpubls.com 3246 IV. RESULTS Fig. 2. Regime Transition Probability Matrix. A. Regime Analysis The HMM identified two distinct market regimes, with statistics summarized in Table I. The heatmap in Figure 2 shows the probabilities of transitioning between these identified market states. This matrix helps in understanding the persistence of these regimes and the likelihood of shifts. For instance, high diagonal values show that a regime is stable, while non zero off diagonal values indicate that market behavior can change quickly. TABLE I REGIME STATISTICS Regime Mean Std Count 0 -0.000898 0.035669 87 1 0.000548 0.008102 1634 2 -0.009450 0.017500 19 B. Signal Forecasting and Backtesting Figure 3 shows an example of the 1,000 Monte Carlo simulated price paths, which form the basis for signal generation. The backtesting results are summarized in Table II. Figure 4 illustrates the cumulative returns for both the strategy and the buy-and-hold benchmark, clearly showing the strategy’s smoother equity curve. The Drawdown Curve (Figure 5) effectively shows how the strategy mitigates large capital drawdowns. Figure 6 presents a histogram of daily strategy returns, and the Rolling Sharpe Ratio (Figure 7) further highlights the strategy’s consistent risk adjusted performance over time. Communications on Applied Nonlinear Analysis ISSN: 1074-133X Vol 32 No. 9S (2025) https://internationalpubls.com 3247 Fig. 3. Monte Carlo simulation showing 1,000 forecasted 5-day price paths along with the current price, P25, and P75 bands. V. CONCLUSION The proposed paper introduced a regime sensing short term trading strategy that combines Hidden Markov Models (HMMs) for regime detection in markets with Monte Carlo simulations for probabilistic price forecasting. Through conditioning simulations on regime dependent drift and volatility parameters, the strategy dynamically adjusts to underlying market conditions and produces trading signals from forecast percentiles. TABLE II PERFORMANCE COMPARISON: STRATEGY VS. BUY & HOLD Metric Strategy Buy & Hold Cumulative Return 1.448263 1.264360 Annualized Return 0.131107 0.119673 Sharpe Ratio 1.046113 0.671523 Maximum Drawdown -0.174948 -0.384399 Fig. 4. Cumulative Returns: Regime-Aware Strategy vs. Buy & Hold. Fig. 5. Drawdown Curve for the Regime-Aware Strategy. Communications on Applied Nonlinear Analysis ISSN: 1074-133X Vol 32 No. 9S (2025) https://internationalpubls.com 3248 Backtesting on the NIFTY 50 index for 2018 to 2024 showed better risk-adjusted returns versus a buy- and-hold strategy, with greater Sharpe and Sortino ratios, reduced maximum drawdowns, and a more even equity curve. The main contribution of this research is bringing together the interpretability of HMM-based regime detection and the forward-looking uncertainty Fig. 6. Histogram of Daily Strategy Returns. Fig. 7. Rolling Sharpe Ratio (63-day window) of the Strategy. quantification of Monte Carlo approaches. This fusion not only enhances predictive accuracy but also boosts risk management, rendering it fitting for the non-stationary and volatile financial markets. The study also suffers from some limitations. First, the analysis was limited to one index (NIFTY 50) with daily frequency data, and findings can vary across asset classes, markets, or higher- frequency trading. Second, transaction costs and slippage were accounted for only partially, which could impact real-world profitability. Third, the model has Gaussian emissions in the HMM and a Geometric Brownian Motion process in price dynamics, which do not necessarily reflect extreme events or fat-tailed return distributions. Follow-up work can generalize this framework by using other regime detection models (e.g., Bayesian non- parametric HMMs), investigating more complex simulation methods (e.g., stochastic volatility or jump diffusion models), and testing the strategy over several markets and asset classes. Further, portfolio optimization or reinforcement learning in conjunction with regime sensitivity aware forecasts may offer a route to increasingly adaptive and resilient trading systems. Communications on Applied Nonlinear Analysis ISSN: 1074-133X Vol 32 No. 9S (2025) https://internationalpubls.com 3249 REFERENCES [1] N. V. Pavlidis, D. P. K. Watson, and K. P. P. Voulgaris, “Modeling financial time series with Hidden Markov Models”, Proceedings of the IEEE International Joint Conference on Neural Networks (IJCNN), 2009, pp. 2038–2045. [2] Y. J. Lee, C. W. Lin, and M. D. Chen, “A financial forecasting model based on Hidden Markov Models and Genetic Algorithms”, Proceedings of the 2006 IEEE International Conference on Systems, Man and Cybernetics, 2006, pp. 2872–2877. [3] K. Nystrup, T. F. Maare, and T. B. Pedersen, “Market regime switching models for active asset allocation”, Quantitative Finance and Economics, vol. 1, no. 1, pp. 1–28, 2017. [4] Communications on Applied Nonlinear Analysis, ISSN: 1074-133X, vol. 32, no. 9S, 2025. Available: https://internationalpubls.com. [5] B. K. Park and M. C. Lee, “Credit risk assessment using Hidden Markov Models”, Journal of Risk Management in Financial Institutions, vol. 7, no. 1, pp. 78–90, 2013. [6] P. Glasserman, Monte Carlo Methods in Financial Engineering. New York, NY, USA: Springer, 2004. [7] J. Hull, Options, Futures, and Other Derivatives, 10th ed. Boston, MA, USA: Pearson, 2017. [8] M. R. D. Singh, S. C. S. Lamba, and V. R. Sharma, “Risk management using Monte Carlo simulation in financial market”, Proceedings of the 2018 International Conference on Computing, Power and Communication Technologies (ICCPCT), 2018, pp. 609–613. [9] P. K. Singh and A. G. Singh, “Stock price prediction using Monte Carlo simulation and machine learning”, Proceedings of the 2018 IEEE International Conference on Information Technology (ICIT), 2018, pp. 258–263. [10] J. D. Hamilton, “A new approach to the economic analysis of nonstationary time series and the business cycle”, Econometrica, vol. 57, no. 2, pp. 357–384, 1989. [11] “Market Price of Shares for the required dates”, Yahoo Finance. Available: https://finance.yahoo.com.