HMA Crossover 1H with RSI, Stochastic RSI, and Trailing Stop
Jun 25, 2024

The HMA Crossover 1H with RSI, Stochastic RSI, and Trailing Stop tool provides a comprehensive trend-following framework that combines fast-reacting Hull Moving Averages with momentum oscillators to identify high-probability entries and exits.
Usage
The Usage section describes how the script can be used to navigate market trends. This indicator is primarily designed for higher timeframes like the 1H chart, where it filters price action through multiple layers of technical analysis.
Trend Identification and Crossovers
The core of the strategy relies on the interaction between two Hull Moving Averages (HMA). A 5-period HMA serves as the fast signal line, while a 20-period HMA serves as the slow baseline. Users look for crossovers to identify potential shifts in trend direction.
Momentum Filtering
To avoid entering trades during exhausted trends, the script applies RSI and Stochastic RSI filters:
- Long Conditions: A bullish HMA crossover is only valid if the RSI is below 45 and the Stochastic %K is below 39, ensuring the entry occurs when the asset is not overbought.
- Short Conditions: A bearish HMA crossunder is only valid if the RSI is above 60 and the Stochastic %K is above 63, ensuring the entry occurs when the asset is not oversold.
Risk Management
The script includes a built-in trailing stop-loss mechanism. This feature automatically adjusts the exit price as the trade moves in a favorable direction, securing profits and protecting capital from sudden reversals.
Details
The script utilizes the Hull Moving Average (HMA) due to its ability to reduce lag while maintaining a high degree of smoothness compared to standard EMAs or SMAs. By combining this with the Relative Strength Index (RSI) and Stochastic RSI, the algorithm attempts to solve the common issue of moving average "whipsaws" in ranging markets.
The implementation uses a 14-period RSI and a smoothed Stochastic %K (3-period SMA of a 14-period Stochastic). The logic ensures that trend signals (HMA) are only acted upon when momentum (RSI/Stoch) suggests there is room for the price to move further in the direction of the crossover.
Settings
- HMA Fast Length (5): Determines the period for the fast Hull Moving Average. Lower values increase sensitivity.
- HMA Slow Length (20): Determines the period for the slow Hull Moving Average used to define the broader trend.
- RSI Length (14): Sets the lookback period for the Relative Strength Index calculation.
- Stochastic RSI %K (3): Defines the smoothing period for the Stochastic oscillator component.
- Trailing Stop Offset (0.05): Sets the percentage distance for the trailing stop loss to follow price movement.
- Short Trailing Points (250): Specifically defines the point-based trailing exit for short positions.
FAQ
How do I interpret the BUY and SELL labels? The labels appear on the chart when all conditions—HMA crossover, RSI threshold, and Stochastic RSI threshold—are met simultaneously on a bar close.
Can I use this on timeframes other than the 1H? While optimized for the 1H timeframe, the logic can be applied to other timeframes; however, users should adjust the HMA and RSI settings to account for increased noise on lower timeframes.
How do I get access to the HMA Crossover 1H with RSI, Stochastic RSI, and Trailing Stop? You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.
Free indicator
Get free access to this indicator on the platforms below.
Unlock the entire LuxAlgo Library
Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.