This strategy is an automated trading system based on the SuperTrend indicator, generating trading signals by analyzing price crossovers with the SuperTrend line. The strategy employs fixed ATR period and multiplier parameters, combining price crossover direction with the SuperTrend line to determine market trends, achieving an organic integration of trend following and capital management.
The core of the strategy utilizes the SuperTrend indicator, which is constructed based on the ATR (Average True Range) volatility indicator. Specific implementation includes:
This is a well-structured and logically rigorous trend-following strategy. Through the dynamic characteristics of the SuperTrend indicator, it achieves unity in trend capture and risk control. The strategy demonstrates strong practicality and extensibility, and through appropriate parameter settings and implementation of optimization directions, it shows promise for stable performance in live trading.
/*backtest start: 2019-12-23 08:00:00 end: 2024-12-09 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Commodity KIng", overlay=true) // Supertrend Parameters atr_period = 10 // Fixed ATR Period atr_multiplier = 2.0 // Fixed ATR Multiplier // Calculate Supertrend [supertrend, direction] = ta.supertrend(atr_multiplier, atr_period) // Plot Supertrend with reversed colors plot(supertrend, color=direction > 0 ? color.red : color.green, title="Supertrend", linewidth=2) // Buy and Sell Conditions longCondition = ta.crossover(close, supertrend) // Buy when price crosses above Supertrend shortCondition = ta.crossunder(close, supertrend) // Sell when price crosses below Supertrend // Execute Buy and Sell Orders if (longCondition) strategy.entry("Buy", strategy.long) if (shortCondition) strategy.entry("Sell", strategy.short) // Exit Conditions if (shortCondition) strategy.close("Buy") // Close long position if price crosses below Supertrend if (longCondition) strategy.close("Sell") // Close short position if price crosses above Supertrend // Alerts if (longCondition) alert("Buy Signal: " + str.tostring(close), alert.freq_once_per_bar) if (shortCondition) alert("Sell Signal: " + str.tostring(close), alert.freq_once_per_bar)