
This strategy is an automated trading system based on the SuperTrend indicator, integrating multiple indicators including RSI (Relative Strength Index), volume, and ATR (Average True Range) for trading decisions. It identifies market trend direction while utilizing multiple filtering conditions to ensure trading quality, creating a comprehensive trading system. The strategy’s most distinctive feature is its tight integration of technical analysis with risk management, automatically adjusting stop-loss and take-profit targets for each trade based on market volatility, forming a dynamic risk control mechanism.
The core logic of this strategy revolves around the following main components:
Trend Determination: Using the SuperTrend indicator as a foundation to construct upper and lower bands. When price breaks through the upper band, the market is considered to be in an uptrend; when it breaks through the lower band, it’s in a downtrend. This serves as the primary basis for trading direction.
Volume Confirmation: The strategy requires current trading volume to be higher than a specific multiple of the 20-period volume average (adjustable via the volumeMultiplier parameter). This ensures trades only occur when there is sufficient liquidity.
Candle Body Strength Verification: Calculates the current candle’s body size (absolute difference between closing and opening prices) and compares it with the ATR value. Only when the candle body reaches a specific proportion of ATR (controlled by the bodyPctOfATR parameter) is the price movement considered to have sufficient strength.
RSI Filtering: Uses the RSI indicator to avoid trading in overbought or oversold areas. Buy signals require RSI below the overbought level (default 70), while sell signals require RSI above the oversold level (default 30).
Automatic Take-Profit and Stop-Loss: Each trade’s stop-loss is set at one ATR distance, while the take-profit is set as a multiple of the stop-loss (controlled by the riskRewardRatio parameter), implementing dynamic risk management based on actual market volatility.
Through the comprehensive judgment of the above five aspects, the strategy forms buy and sell conditions: - Buy condition: Uptrend, sufficient volume, strong enough candle body, RSI not overbought - Sell condition: Downtrend, sufficient volume, strong enough candle body, RSI not oversold
Analyzing the code implementation of this strategy, the following significant advantages can be summarized:
Multi-dimensional Confirmation Mechanism: Through multiple confirmations from SuperTrend, RSI, volume, and candle body strength, false signals are greatly reduced, improving trading accuracy. Especially in volatile markets, this multi-dimensional confirmation mechanism can avoid many unnecessary trades.
Adaptive Risk Management: Dynamic stop-loss and take-profit settings based on ATR allow the strategy to automatically adjust risk parameters according to volatility in different market phases, avoiding the inflexibility problems of fixed stop-losses.
Integrated Capital Management: The strategy has built-in capital management functionality, allowing adjustment of capital amount per trade through the capitalPerTrade parameter based on account size and risk preference, achieving integration of risk control and trading strategy.
High Degree of Trade Automation: Everything from entry signals to capital allocation to take-profit and stop-loss is fully automated, reducing the psychological pressure and error probability of manual operations.
Comprehensive Alert System: The strategy is configured with detailed JSON format alerts, containing key information such as trading direction, capital amount, stop-loss and take-profit prices, facilitating integration with external systems or user notifications.
Despite considering multiple factors in its design, the strategy still has the following potential risks:
Parameter Sensitivity: The strategy’s performance is highly dependent on parameter settings, such as ATR period, RSI thresholds, volume multiplier, etc. Inappropriate parameters may lead to overtrading or missing important opportunities. The solution is to find optimal parameter combinations for different market environments through backtesting.
Lag at Trend Turning Points: As a trend-following indicator, SuperTrend typically has a lag at trend turning points, potentially resulting in late entries or larger stop-losses. This can be mitigated by shortening the ATR period or adjusting the ATR multiplier.
Extreme Market Risk: In market gaps or flash crashes, preset stop-losses may not execute effectively, leading to losses beyond expectations. It’s recommended to use other risk control measures, such as overall position control or maximum loss limits.
Capital Efficiency Issues: Fixed capital allocation methods may lead to inefficient use of capital. Consider implementing dynamic position adjustment based on volatility or account equity.
Single Timeframe Limitation: The current strategy is based solely on signals from a single timeframe, lacking multi-timeframe confirmation, which may generate erroneous signals under certain market conditions.
Addressing the above risks and limitations, the strategy can be optimized in the following directions:
Multi-Timeframe Analysis Integration: Introducing trend confirmation from higher timeframes, trading only in the direction of the major trend, can significantly improve strategy stability. This can be implemented through TradingView’s security function for cross-timeframe data access.
Dynamic Parameter Adaptation: Automatically adjusting parameters such as ATR multiplier and RSI thresholds based on market volatility helps the strategy better adapt to different market environments. For example, increasing the ATR multiplier in highly volatile markets to reduce false breakouts.
Optimized Capital Management Algorithm: Introducing dynamic capital management based on the Kelly formula or fixed-proportion risk model, automatically adjusting capital allocation for each trade based on historical win rates and profit/loss ratios, enhancing long-term return stability.
Enhanced Market State Recognition: Adding logic to identify market states (trending, ranging, high volatility, low volatility) and applying different trading rules or parameters in different market states improves adaptability.
Machine Learning Integration: Consider using machine learning algorithms to predict optimal entry timing or parameter combinations, especially for determining key parameters like ATR multiplier and volume thresholds. Machine learning can provide more precise adaptive capabilities.
The SuperTrend-ATR-RSI Dynamic Risk Control Strategy is a quantitative trading system that combines trend following with dynamic risk management. By identifying market trends through the SuperTrend indicator and incorporating multiple filtering mechanisms including RSI, volume, and candle body strength, it greatly improves the quality of trading signals. The core advantage lies in its adaptive risk management framework, which automatically adjusts risk control according to market volatility through ATR-based dynamic stop-loss and take-profit settings.
This strategy is suitable for market environments with significant volatility and clear trends, especially during the formation of medium to long-term trends. However, users should pay attention to parameter optimization and market environment matching in practical application, and consider the optimization directions proposed in this article, such as multi-timeframe analysis, dynamic parameter adjustment, and advanced capital management methods, to further enhance the strategy’s robustness and adaptability.
With reasonable parameter settings and thorough backtesting validation, this strategy has the potential to become a reliable automated trading tool, providing investors with a systematic solution for trade execution and risk control.
/*backtest
start: 2025-01-01 00:00:00
end: 2025-04-20 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"TRX_USD"}]
*/
//@version=5
strategy("Supertrend Hombrok Bot", overlay=true, default_qty_type=strategy.cash, default_qty_value=1000)
// INPUTS
atrPeriod = input.int(10, title="ATR Period")
atrMult = input.float(3.0, title="ATR Multiplier")
rsiPeriod = input.int(14, title="RSI Period")
rsiOverbought = input.int(70, title="RSI Overbought")
rsiOversold = input.int(30, title="RSI Oversold")
volumeMultiplier = input.float(1.2, title="Volume Multiplier")
bodyPctOfATR = input.float(0.3, title="Candle Body % of ATR (min strength)")
riskRewardRatio = input.float(2.0, title="R:R (Take Profit / Stop Loss)")
capitalPerTrade = input.float(10, title="Capital por operação ($)")
// ATR e Supertrend
atr = ta.atr(atrPeriod)
upperBand = hl2 - (atrMult * atr)
lowerBand = hl2 + (atrMult * atr)
prevUpper = nz(upperBand[1], upperBand)
prevLower = nz(lowerBand[1], lowerBand)
trendUp = close[1] > prevUpper ? math.max(upperBand, prevUpper) : upperBand
trendDown = close[1] < prevLower ? math.min(lowerBand, prevLower) : lowerBand
trend = 1
trend := nz(trend[1], trend)
trend := trend == -1 and close > trendDown ? 1 : trend == 1 and close < trendUp ? -1 : trend
isUpTrend = trend == 1
isDownTrend = trend == -1
// Filtros
volAverage = ta.sma(volume, 20)
volOk = volume > volAverage * volumeMultiplier
bodySize = math.abs(close - open)
bodyOk = bodySize > (atr * bodyPctOfATR)
rsi = ta.rsi(close, rsiPeriod)
rsiBuyOk = rsi < rsiOverbought
rsiSellOk = rsi > rsiOversold
// Condições
buyCond = isUpTrend and volOk and bodyOk and rsiBuyOk
sellCond = isDownTrend and volOk and bodyOk and rsiSellOk
// TP e SL
longSL = close - atr
longTP = close + (atr * riskRewardRatio)
shortSL = close + atr
shortTP = close - (atr * riskRewardRatio)
// Estratégia de entrada e saída
if buyCond
strategy.entry("Compra", strategy.long, qty=capitalPerTrade / close)
strategy.exit("TP/SL Compra", from_entry="Compra", stop=longSL, limit=longTP)
if sellCond
strategy.entry("Venda", strategy.short, qty=capitalPerTrade / close)
strategy.exit("TP/SL Venda", from_entry="Venda", stop=shortSL, limit=shortTP)
// ALERTAS + LABELS
alertLong = '{"side":"buy", "capital":' + str.tostring(capitalPerTrade) + ', "sl":' + str.tostring(longSL) + ', "tp":' + str.tostring(longTP) + '}'
alertShort = '{"side":"sell", "capital":' + str.tostring(capitalPerTrade) + ', "sl":' + str.tostring(shortSL) + ', "tp":' + str.tostring(shortTP) + '}'
if buyCond
label.new(bar_index, low, "BUY", style=label.style_label_up, color=color.green, textcolor=color.white)
alert(alertLong, alert.freq_once_per_bar_close)
if sellCond
label.new(bar_index, high, "SELL", style=label.style_label_down, color=color.red, textcolor=color.white)
alert(alertShort, alert.freq_once_per_bar_close)
// VISUAL
plotshape(buyCond, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(sellCond, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
plot(trend == 1 ? trendUp : na, title="Trend Up", color=color.green, linewidth=1)
plot(trend == -1 ? trendDown : na, title="Trend Down", color=color.red, linewidth=1)