Welcome to our Support Centre! Simply use the search box below to find the answers you need.
If you cannot find the answer, then Call, WhatsApp, or Email our support team.
We’re always happy to help!
Unsupervised Clustering Strategy
The Unsupervised Clustering Strategy is a machine learning approach that segments forex market conditions into distinct regimes or behaviour patterns without predefined labels. By grouping similar data points (e.g. price action, volatility, momentum) into clusters, this strategy enables traders to tailor trade decisions based on the current market type, such as trending, ranging, or high-volatility phases.
Ideal for quant traders, AI developers, and system designers, this strategy is especially powerful in environments where market regimes shift often and traditional indicators underperform.
What Is Unsupervised Clustering in Trading?
Unsupervised clustering uses algorithms to identify natural groupings within data. In forex trading, clustering helps classify:
- Market states (e.g. trend vs chop)
- Volatility zones (low, medium, high)
- Pattern frequency or candlestick behaviour
- Asset correlations and co-movement
Popular clustering algorithms:
- K-Means – partitions data into k groups by minimising intra-cluster variance
- DBSCAN – detects dense clusters and outliers
- Hierarchical clustering – builds a tree of nested clusters
- Gaussian Mixture Models (GMM) – probabilistic clustering based on distribution assumptions
Strategy Workflow
1. Feature Engineering
Collect and prepare features from historical price data:
- Price-based: returns, log returns, rolling averages
- Volatility: ATR, standard deviation, Bollinger Band width
- Momentum: RSI, MACD histogram, rate of change
- Volume (if available)
- Optional: time of day, session, macro indicator shocks
Normalise or standardise all inputs for clustering.
2. Cluster Formation
Choose a clustering algorithm (e.g. K-Means with 3 clusters):
- Fit the model on training data
- Assign each data point (candle or window) to a cluster
- Interpret clusters by backtesting the performance of simple strategies in each regime
Example cluster labels:
- Cluster 0 = low volatility, choppy
- Cluster 1 = strong trend, bullish
- Cluster 2 = high volatility, reversal-prone
3. Cluster-Based Trading Logic
Create a unique strategy for each cluster:
Cluster 0 (chop):
- Use mean-reversion trades with Bollinger Band reversion
- Take profit at moving average centre
Cluster 1 (trend):
- Use breakout strategy with MA filter
- Ride trend with trailing stop
Cluster 2 (volatile):
- Reduce position size
- Trade only with tight stops or fade extreme spikes
Real-Time Application
- Use a sliding window of recent candles to generate features
- Predict cluster label in real time
- Route trade signals to the appropriate rule set
- Adjust risk parameters and position sizing based on detected regime
Example: EUR/USD Clustering Strategy
- Features: 5-period return, 20-period ATR, RSI, BB width
- Algorithm: K-Means with 3 clusters
- Cluster definitions (based on backtesting):
- Cluster 0: sideways — use RSI reversals
- Cluster 1: bullish trend — use breakout entries
- Cluster 2: volatility spike — stay out or fade failed breakouts
Backtest results with adaptive logic:
- Sharpe ratio: 1.88
- Win rate: 63%
- Max drawdown: 6.2%
- Return: +21% annually
Tools and Libraries
- Python: scikit-learn, pandas, NumPy, Backtrader
- Visualization: Seaborn, Matplotlib (e.g. PCA plots for clusters)
- Deployment: MetaTrader, cTrader via Python bridge
- Real-time updates: Use rolling window + batch inference
Advantages
- Adapts to changing market regimes dynamically
- Removes need for manual state labelling
- Works well with both rule-based and AI-driven strategies
- Improves signal quality by isolating poor environments
- Easy to combine with supervised learning or reinforcement models
Limitations
- Cluster definitions can shift over time
- Requires retraining to remain effective
- Not interpretable by default — cluster meaning must be deduced
- Computational cost increases with more features and frequent updates
Best Currency Pairs
- EUR/USD, GBP/USD, USD/JPY – exhibit clear regime shifts
- AUD/JPY, GBP/JPY – highly reactive to volatility and trend states
Conclusion
The Unsupervised Clustering Strategy offers a powerful way to understand and trade market conditions by detecting natural structure in the data. By segmenting price behaviour into clusters, traders can execute strategies that are tailored to each regime, dramatically improving trade timing and performance.
To learn how to build clustering models, engineer regime features, and integrate AI-based strategies into real-time FX systems, enrol in the advanced Trading Courses at Traders MBA.