
Chiến lược này là một hệ thống theo dõi xu hướng động dựa trên phân tích kỹ thuật, chủ yếu sử dụng đường hai đường trung bình (đường trung bình di chuyển đơn giản 200 ngày và đường trung bình di chuyển chỉ số 21 tuần) để xác định xu hướng thị trường. Chiến lược này thực hiện quản lý rủi ro động bằng cách tích hợp các chỉ số tương đối mạnh (RSI) và chỉ số xu hướng trung bình (ADX) làm bộ lọc động lực và kết hợp với tần số sóng thực (ATR) để nắm bắt chính xác xu hướng tăng và kiểm soát rủi ro hiệu quả.
Logic cốt lõi của chiến lược này dựa trên các yếu tố chính sau:
Đây là một chiến lược theo dõi xu hướng được thiết kế hợp lý, logic rõ ràng, bằng cách sử dụng nhiều chỉ số kỹ thuật phối hợp, cân bằng lợi nhuận và rủi ro tốt hơn. Chiến lược có thể tùy biến mạnh mẽ, phù hợp để duy trì hiệu quả của nó thông qua tối ưu hóa tham số trong các môi trường thị trường khác nhau. Mặc dù có một số rủi ro trì trệ, nhưng thông qua cơ chế kiểm soát rủi ro hoàn thiện, chiến lược tổng thể thể hiện sự ổn định và đáng tin cậy tốt hơn.
/*backtest
start: 2022-02-09 00:00:00
end: 2025-02-06 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("BTCUSDT Daily - Enhanced Bitcoin Bull Market Support [CYRANO]", shorttitle="BTCUSDT Daily BULL MARKET", overlay=true, commission_type=strategy.commission.percent, commission_value=0.1, slippage=3)
// Inputs
smaLength = input.int(200, title="SMA Length (Bull Market)")
emaLength = input.int(147, title="EMA Length (21-Week Approximation)")
atrLength = input.int(14, title="ATR Length")
riskATR = input.float(2.0, title="ATR Multiplier for Stop Loss", step=0.1)
takeProfitPercent = input.float(10.0, title="Take Profit (%)", step=0.1)
rsiFilter = input.bool(true, title="Enable RSI Filter")
rsiLength = input.int(14, title="RSI Length")
adxFilter = input.bool(true, title="Enable ADX Filter")
adxThreshold = input.float(25, title="ADX Threshold")
// Date Range Filter
startDate = input(timestamp("2018-01-01 00:00 +0000"), title="Start Date")
endDate = input(timestamp("2069-12-31 00:00 +0000"), title="End Date")
inDateRange = true
// Moving Averages
sma200 = ta.sma(close, smaLength)
ema21w = ta.ema(close, emaLength)
// ATR Calculation
atr = ta.atr(atrLength)
stopLoss = close - (riskATR * atr)
takeProfit = close * (1 + takeProfitPercent / 100)
// RSI Filter
rsi = ta.rsi(close, rsiLength)
rsiCondition = rsiFilter ? rsi > 50 : true
// ADX Filter
[diplus, diminus, adx] = ta.dmi(14, 14)
adxCondition = adxFilter ? adx > adxThreshold : true
// Entry and Exit Conditions
buyCondition = inDateRange and close > sma200 and close > ema21w and rsiCondition and adxCondition
exitCondition = inDateRange and (close < sma200 or close < ema21w)
// Strategy Execution
if buyCondition
strategy.entry("BUY", strategy.long, stop=stopLoss, limit=takeProfit)
if exitCondition
strategy.close("BUY")
// Plot MAs
plot(sma200, title="200-Day SMA", color=color.blue, linewidth=2)
plot(ema21w, title="21-Week EMA", color=color.purple, linewidth=2)
// Background Highlight
bullColor = color.new(color.green, 80)
bearColor = color.new(color.red, 80)
bgcolor(close > sma200 and close > ema21w ? bullColor : bearColor, title="Bull Market Background")