Quantitative Strategy: Multi-Indicator Fusion POMDP-Inspired Trading System

RSI STOCH MFI MACD BB POMDP TA
Created on: 2025-07-22 09:11:25 Modified on: 2025-07-22 09:11:25
Copy: 0 Number of hits: 213
avatar of ianzeng123 ianzeng123
2
Follow
319
Followers

 Quantitative Strategy: Multi-Indicator Fusion POMDP-Inspired Trading System  Quantitative Strategy: Multi-Indicator Fusion POMDP-Inspired Trading System

Overview

The quantitative strategy “Multi-Indicator Fusion POMDP-Inspired Trading System” is a trading method based on technical analysis and Partially Observable Markov Decision Processes (POMDP). This strategy cleverly combines Stochastic RSI, Money Flow Index (MFI), Bollinger Bands, and Moving Average Convergence Divergence (MACD) to generate buy and sell signals. The core concept of the strategy is to construct a POMDP-like decision framework through multi-dimensional market state observations to address the uncertainty and partial observability of financial markets. This strategy is particularly suitable for trading scenarios with moderate price expectations, implementing a risk-controlled trading system through clearly defined entry and exit rules.

Strategy Principles

The core principle of this strategy is based on the concept of Partially Observable Markov Decision Processes (POMDP), viewing the market as a system with partially visible states. The market state is observed through the following key technical indicators:

  1. Bollinger Bands: Using a 20-period simple moving average as the middle band, with a standard deviation multiplier of 2.0 to form the upper and lower bands, used to identify price volatility ranges.

  2. Stochastic RSI: Combining the advantages of RSI and stochastic indicators, with a 14-period length and 3-period smoothing parameter, used to identify overbought and oversold conditions. A K value below 30 is considered oversold, while above 70 is considered overbought.

  3. Money Flow Index (MFI): Calculated over a 14-period timeframe, measuring money flow through the product of typical price (TP) and volume. An MFI below 40 is considered an oversold signal, while above 60 is an overbought signal.

  4. MACD Indicator: Using 12/26/9 parameter settings, the relationship between the MACD line and signal line is used to confirm trend direction.

The decision rules of the strategy are as follows:

  • Long Condition (Call Debit Spread): When the K value is below 30 (oversold) or MFI is below 40 (oversold), and simultaneously the MACD line is above the signal line, a long signal is triggered.
  • Short Condition (Put Debit Spread): When the K value is above 70 (overbought) or MFI is above 60 (overbought), and simultaneously the MACD line is below the signal line, a short signal is triggered.

The strategy also implements a time-based automatic exit mechanism, setting positions to automatically close after 5 periods, effectively controlling position time risk.

Strategy Advantages

  1. Multi-dimensional Signal Confirmation: By combining multiple technical indicators (Stochastic RSI, MFI, MACD), the strategy can observe market conditions from different angles, reducing the risk of misleading signals that might come from a single indicator.

  2. Adaptability of the POMDP Framework: The introduction of POMDP concepts enables the strategy to make relatively optimized decisions under conditions of uncertainty and partial observability, better aligning with actual market environments.

  3. Clear Risk Control: Through a fixed exit period (5 periods), the strategy implements time-dimension risk control, avoiding the expansion of losses from long-term adverse trends.

  4. Complementary Technical Indicators: Stochastic RSI primarily reflects price momentum, MFI combines price and volume information, MACD captures trend changes, and Bollinger Bands define volatility ranges. These indicators complement each other, improving signal reliability.

  5. Robust Code Implementation: The strategy uses math.sum instead of ta.sum when calculating MFI, correcting potential calculation errors and enhancing strategy stability.

  6. Automated Execution Capability: Implementation in TradingView’s Pine Script allows the strategy to automatically generate and execute trading signals, reducing human intervention and emotional influence.

Strategy Risks

  1. Limitations of Overbought/Oversold Thresholds: The strategy uses fixed overbought/oversold thresholds (Stochastic RSI 3070 and MFI 4060). These fixed thresholds may not always be optimal across different market environments and different products, potentially leading to decreased signal quality.

  2. Double-edged Sword of Time Exit Mechanism: The fixed 5-period exit mechanism, while controlling risk, may also prematurely exit favorable trends, limiting potential returns.

  3. Multi-indicator Redundancy Risk: While multiple indicators provide multi-dimensional confirmation, there may be some correlation and redundancy between indicators, potentially leading to signal bias reinforcement under certain market conditions.

  4. Insufficient Adaptability in Trending Markets: This strategy is primarily based on overbought/oversold and reversal signals, which may generate too many false signals in strong trending markets, leading to frequent trading and unnecessary costs.

  5. Parameter Optimization Dependency: The strategy’s effectiveness largely depends on the parameter settings of various indicators. Different market conditions may require different parameter combinations, increasing the complexity of strategy maintenance and adjustment.

  6. Lack of Volatility Adaptation Mechanism: The strategy does not have an adaptive mechanism for market volatility changes, potentially generating more false signals in high-volatility environments.

Strategy Optimization Directions

  1. Dynamic Parameter Adjustment Mechanism: Introduce parameter self-adaptation mechanisms based on market states, such as adjusting the Bollinger Bands standard deviation multiplier based on volatility, or adjusting overbought/oversold thresholds based on market trend strength, improving the strategy’s adaptability across different market environments.

  2. Improved Stop-Loss Mechanism: In addition to the time-dimension exit mechanism, add price-based stop-loss and take-profit mechanisms, such as setting ATR-based stop-loss points, enhancing comprehensive risk management.

  3. Market Environment Filter: Add a market environment recognition module, such as trend strength indicators or volatility indicators, to reduce or pause trading in market environments unsuitable for the strategy, avoiding excessive trading under unfavorable conditions.

  4. Signal Quality Scoring System: Develop a signal quality scoring mechanism to score signals based on factors such as the consistency of multiple indicators, market environment, and historical signal success rates, executing only high-quality signals to improve strategy effectiveness.

  5. Machine Learning Enhancement: Combine the POMDP framework with machine learning methods to train and optimize decision strategies through historical data, enabling the system to learn from past trades and improve.

  6. Capital Management Strategy Optimization: Introduce dynamic position management mechanisms to adjust trading size based on signal strength, market state, and account risk, implementing more scientific capital management.

Summary

The “Multi-Indicator Fusion POMDP-Inspired Trading System” is a quantitative trading strategy that combines multiple technical indicators with a POMDP decision framework. Through the synergy of Stochastic RSI, MFI, MACD, and Bollinger Bands, this strategy addresses the issue of partial market observability to a certain extent, providing multi-dimensional signal confirmation for trading decisions.

The main advantages of the strategy lie in its multi-angle market observation capability and clear risk control mechanisms, while also facing challenges such as parameter optimization dependency and insufficient adaptability in certain market environments. By introducing dynamic parameter adjustments, improving stop-loss mechanisms, adding market environment filters, and other optimization directions, this strategy has the potential to further enhance its robustness and adaptability.

Overall, this is a well-designed, logically clear quantitative trading system, particularly suitable for traders who have a certain predictive ability for markets but wish to control risk. Through continuous optimization and adaptation to different market environments, this strategy can become an effective tool in a trader’s toolkit.

Strategy source code
/*backtest
start: 2024-07-22 00:00:00
end: 2025-07-20 08:00:00
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT","balance":2000000}]
*/

//@version=6
strategy("Debit Spread POMDP‑Inspired Strategy", overlay=true, margin_long=100, margin_short=100)

// ——— Constants
const int K_OVERSOLD      = 30
const int K_OVERBOUGHT    = 70
const int MFI_OVERSOLD    = 40
const int MFI_OVERBOUGHT  = 60
const int EXIT_BARS       = 5

// ——— User inputs
stochLength  = input.int(14,  "Stochastic RSI length")
stochSmooth  = input.int(3,   "Stochastic smoothing")
mfiLength    = input.int(14,  "MFI length")
bbLength     = input.int(20,  "Bollinger length")
bbStdDev     = input.float(2.0, "Bollinger std dev")
macdFast     = input.int(12,  "MACD fast length")
macdSlow     = input.int(26,  "MACD slow length")
macdSignal   = input.int(9,   "MACD signal length")

// ——— Bar index tracking for exits
var int callEntryBar = na
var int putEntryBar = na

// ——— Bollinger Bands
basis   = ta.sma(close, bbLength)
upper   = basis + bbStdDev * ta.stdev(close, bbLength)
lower   = basis - bbStdDev * ta.stdev(close, bbLength)

// ——— Stochastic RSI
rsi      = ta.rsi(close, stochLength)
k        = ta.sma(ta.stoch(rsi, rsi, rsi, stochLength), stochSmooth)
d        = ta.sma(k, stochSmooth)

// ——— Manual MFI calculation (FIXED: using math.sum)
tp        = (high + low + close) / 3.0
rawMF     = tp * volume
posFlow   = (tp > tp[1] ? rawMF : 0.0)
negFlow   = (tp < tp[1] ? rawMF : 0.0)
posMF     = math.sum(posFlow, mfiLength)  // FIXED: math.sum instead of ta.sum
negMF     = math.sum(negFlow, mfiLength)  // FIXED: math.sum instead of ta.sum
moneyRatio = negMF != 0 ? posMF / negMF : 0.0
mfi       = negMF != 0 ? 100 - 100 / (1 + moneyRatio) : 0.0

// ——— Manual MACD calculation
fastMA     = ta.ema(close, macdFast)
slowMA     = ta.ema(close, macdSlow)
macdLine   = fastMA - slowMA
signalLine = ta.ema(macdLine, macdSignal)

// ——— POMDP‑inspired decision rules
bullCondition = ((k < K_OVERSOLD) or (mfi < MFI_OVERSOLD)) and (macdLine > signalLine)
bearCondition = ((k > K_OVERBOUGHT) or (mfi > MFI_OVERBOUGHT)) and (macdLine < signalLine)

if bullCondition
    strategy.entry("CallDebit", strategy.long)
    callEntryBar := bar_index  // Track entry bar

if bearCondition
    strategy.entry("PutDebit", strategy.short)
    putEntryBar := bar_index   // Track entry bar

// FIXED: Manual time-based exits using bar_index
if not na(callEntryBar) and bar_index >= callEntryBar + EXIT_BARS
    strategy.close("CallDebit")
    callEntryBar := na

if not na(putEntryBar) and bar_index >= putEntryBar + EXIT_BARS
    strategy.close("PutDebit")
    putEntryBar := na

// ——— Plots
plot(basis, color=color.gray, linewidth=1, title="BB Basis")
plot(upper, color=color.orange, linewidth=1, title="BB Upper")
plot(lower, color=color.orange, linewidth=1, title="BB Lower")
plot(k, title="%K", color=color.blue)
plot(d, title="%D", color=color.purple)
plot(mfi, title="MFI", color=color.green)
plot(macdLine - signalLine, title="MACD Histogram", color=color.red, style=plot.style_columns)