Momentum Strategy (BTC/USDT; 30m) - STOCH RSI (with source code)
Jan 7, 2021

The Momentum Strategy (BTC/USDT; 30m) - STOCH RSI indicator is a quantitative trading tool designed for low-timeframe Bitcoin analysis by combining Stochastic RSI momentum with EMA-based trend filtering. It aims to capture mean-reversion opportunities within established trends while utilizing a dynamic position sizing model to manage capital recovery.
Usage
The strategy identifies entries based on Stochastic RSI "Golden" and "Death" crosses within overbought and oversold zones. It is optimized for the 30-minute timeframe on BTC/USDT but can be adapted for other assets.
The tool features a unique "Gamble Sizing" mechanism:
- Standard Sizing: By default, the strategy risks a fixed percentage of equity (e.g., 70%).
- Recovery Logic: If "Gamble Sizing" is enabled and a loss is detected, the strategy increases the position size for the subsequent trade by a user-defined percentage (default 25%) up to a specified limit.
- Reset Logic: Upon a successful trade, the position size resets to the initial default value.
Details
The strategy employs several layers of validation before executing trades:
- Momentum: Uses Stochastic RSI (K and D lines) to find extremes in price action.
- Trend Filter: A Fast EMA and Slow EMA relationship acts as a directional filter. Long positions are restricted if the Fast EMA is below the Slow EMA, and Short positions are restricted if the Fast EMA is above the Slow EMA.
- Bars Delay: To prevent premature exits, the strategy includes a programmable delay. Once a closing condition is met, the script waits for a specific number of bars before executing the exit.
- Risk Management: Each trade is protected by percentage-based Stop Loss and Take Profit levels defined in the settings.
Settings
Backtest Period
- Start/End Year/Month/Day: Defines the historical range for strategy calculation.
Basic Parameters
- Smooth K/D: The period for smoothing the Stochastic components.
- RSI Length: The lookback period for the underlying RSI calculation.
- Stoch Length: The lookback period for the Stochastic calculation.
- Overbought/Oversold Height: The threshold levels (e.g., 85.29 and 30.6) for identifying momentum extremes.
- Bars Delay: Number of bars to wait after a close signal before executing the exit.
Position Sizing
- Gamble Sizing: Toggle for the dynamic recovery sizing logic.
- Gamble Add (%): The amount of equity percentage to add after a loss.
- Gamble MAX (%): The maximum equity exposure allowed when scaling up.
Trend & Risk
- Fast/Slow EMA Length: Periods used for the trend direction filter.
- TREND FILTER LONG/SHORT: Toggles to enable or disable the EMA-based direction requirement.
- Stop Loss / Take Profit %: Percentage-based risk and reward targets for both directions.
FAQ
How do I use the Trend Filter?
Enable the "TREND FILTER" options in the settings to ensure the strategy only enters Longs during uptrends (Fast EMA > Slow EMA) and Shorts during downtrends (Fast EMA < Slow EMA).
What is the Bars Delay setting?
This setting tells the strategy to wait a specific number of candles after an exit signal is triggered before actually closing the position, helping to avoid volatility spikes.
How can I access the Momentum Strategy (BTC/USDT; 30m) - STOCH RSI?
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.