
Chiến lược này là một hệ thống giao dịch tự động dựa trên chỉ số SuperTrend, tạo ra tín hiệu giao dịch bằng cách phân tích giá và đường giao thoa của SuperTrend. Chiến lược sử dụng chu kỳ ATR cố định và tham số nhân, kết hợp với hướng giá vượt qua đường SuperTrend để xác định xu hướng thị trường, thực hiện sự kết hợp hữu cơ của theo dõi xu hướng và quản lý tiền.
Cốt lõi của chiến lược là sử dụng chỉ số SuperTrend, được xây dựng dựa trên chỉ số biến động của ATR (Average True Range). Các triển khai cụ thể bao gồm:
Đây là một chiến lược theo dõi xu hướng có cấu trúc rõ ràng, logic nghiêm ngặt. Thông qua tính năng động của chỉ số SuperTrend, sự thống nhất của việc nắm bắt xu hướng và kiểm soát rủi ro được thực hiện. Chiến lược có tính thực tế và khả năng mở rộng mạnh mẽ, với việc thực hiện các tham số hợp lý và hướng tối ưu hóa, dự kiến sẽ đạt được hiệu suất ổn định trong giao dịch thực.
/*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)