ML Model for Technical Indicators: RSI, MACD, and Bollinger Bands

A trading strategy based on RSI, MACD, or Bollinger Bands is classic, but fixed parameters fail. In a trending market, RSI can stay in overbought territory for weeks, while Bollinger Bands narrow, generating false breakouts. We build AI models that adapt these indicators to a specific asset and mark

AI Development Areas

Frequently Asked Questions

Latest works

  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1284
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1240
  • image_logo-advance_0.webp
    B2B Advance company logo design
    696
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    982
  • image_logo-aider_0.webp
    AIDER company logo development
    917
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    1031

A trading strategy based on RSI, MACD, or Bollinger Bands is classic, but fixed parameters fail. In a trending market, RSI can stay in overbought territory for weeks, while Bollinger Bands narrow, generating false breakouts. We build AI models that adapt these indicators to a specific asset and market state. The result is an increase in Sharpe ratio by an average of 1.5-2 times compared to standard settings, confirmed on out-of-sample data.

In real trading, simply using RSI with period 14 and thresholds 30/70 is insufficient. Even for a single instrument, optimal parameters change with market regime. We solve this through ML optimization: the model trains on historical data and dynamically selects indicator parameters. Additionally, we add contextual features: trend, volatility, volume. This avoids false signals during unstable periods. For example, in a volatile market, Bollinger Bands expand to 3σ, while in a sideways market they narrow to 1.5σ, improving breakout accuracy. Feature engineering is key: we generate over 50 features, including lags and cross-indicator products.

How ML improves RSI

RSI traditionally uses period 14 and thresholds 30/70. The problem: in a trending market, RSI can stay below 30 for weeks. The ML approach:

  • Optimization of period (7-28) via Optuna for each instrument
  • RSI in trend context: rsi_divergence_from_trend = rsi - trend_adjusted_rsi
  • Multi-timeframe RSI: 7d, 14d, 21d as separate features
  • RSI velocity: change in RSI over 3 days (acceleration signal)

We also apply neural network encoders to extract hidden patterns, but the baseline model is LightGBM, which ensures interpretability and speed.

Why combining MACD and Bollinger Bands yields better signals

MACD provides momentum signals, Bollinger provides volatility context. The ML model automatically learns when to use which signal.

Feature matrix — merging all indicators:

def build_technical_features(df): features = {} # RSI family for period in [7, 14, 21]: features[f'rsi_{period}'] = talib.RSI(df.close, period) features['rsi_divergence'] = compute_rsi_divergence(df) # MACD family macd, signal, hist = talib.MACD(df.close, 12, 26, 9) features['macd_hist'] = hist features['macd_hist_trend'] = hist.diff(3) features['macd_cross'] = (macd > signal).astype(int) # Bollinger upper, middle, lower = talib.BBANDS(df.close, 20, 2, 2) features['bb_pct_b'] = (df.close - lower) / (upper - lower) features['bb_bandwidth'] = (upper - lower) / middle features['bb_squeeze'] = (features['bb_bandwidth'] < features['bb_bandwidth'].rolling(126).min() * 1.1) # Stochastic slowk, slowd = talib.STOCH(df.high, df.low, df.close) features['stoch_k'] = slowk features['stoch_cross'] = (slowk > slowd).astype(int) return pd.DataFrame(features) 

The model is LightGBM with quantile loss. Target: forward 5-day return. Feature importance reveals which indicators are truly predictive. We run Optuna for 100 iterations to tune hyperparameters (learning rate, max_depth, subsample).

Context dependency of indicators

Indicators work differently in different market regimes:

  • Trending market: RSI < 30 = continuation of decline
  • Ranging market: RSI < 30 = genuine reversal signal
  • High volatility: Bollinger Bands need to be widened (3σ instead of 2σ)

Regime-conditional model:

regime = classify_market_regime(df) # 'trending', 'ranging', 'volatile' if regime == 'trending': signal = momentum_model.predict(features) elif regime == 'ranging': signal = mean_reversion_model.predict(features) 

Hull, J., "Options, Futures, and Other Derivatives"

Comparison of standard and ML approach

Indicator Standard ML Improvement
RSI Period 14, thresholds 30/70 Period optimization, multi-timeframe, divergence
MACD (12,26,9) Bayesian optimization by Sharpe, histogram trend
Bollinger Bands (20,2) Adaptive sigma, squeeze prediction, band walk

Results on real data

Metric Standard settings ML optimization
Sharpe ratio 0.6-0.8 1.2-1.6
Win rate 45% 58%
Max drawdown 25% 18%

Process

  1. Instrument: collect historical data, check quality.
  2. Feature engineering: generate 50+ features based on RSI, MACD, Bollinger, Stochastic.
  3. Optimization: use Bayesian search to tune indicator parameters.
  4. Modeling: LightGBM with time-series cross-validation.
  5. Backtesting: account for commissions, slippage, overnight swap.
  6. Deployment: model in trading environment (SageMaker, Vertex AI, or your server).

Additional capabilities: model interpretability

Feature importance (SHAP) shows which indicator combinations actually work. For example, on S&P 500 futures test, top contributions are bb_squeeze (23%), macd_hist (18%), and rsi_divergence (15%). This allows us to filter out noisy features and simplify the model without quality loss. We also use partial dependence plots to validate model logic — it's crucial that dependencies are economically meaningful.

What's included in the work

  • Baseline model with RSI, MACD, Bollinger, Stochastic
  • Parametric optimization (Optuna/Bayesian)
  • Regime detection (trending, ranging, volatile)
  • Backtesting with real transaction costs
  • Documentation and team training
  • Code guarantee and 3-month support
  • Target: Sharpe > 1.0 on out-of-sample data

Want a model adapted to your instrument? Get a consultation — we'll analyze the data and propose an architecture. Our engineers have 5+ years of experience in ML for financial markets and have completed 30+ projects building trading models. Contact us to discuss your task.