
Chiến lược này là một hệ thống giao dịch theo dõi xu hướng kết hợp nhiều chỉ số kỹ thuật. Nó kết hợp các tín hiệu thị trường với nhiều chiều như trung bình di chuyển (EMA), theo dõi tỷ lệ biến động (ATR), xu hướng khối lượng giao dịch (PVT) và dao động động (Ninja) để tăng độ chính xác của giao dịch thông qua sự phối hợp tín hiệu. Chiến lược sử dụng cơ chế dừng động để kiểm soát rủi ro nghiêm ngặt trong khi theo dõi xu hướng.
Chiến lược này được xây dựng dựa trên bốn trụ cột chính:
Tạo ra tín hiệu giao dịch cần đáp ứng các điều kiện sau:
Chiến lược này xây dựng một hệ thống giao dịch tương đối hoàn chỉnh thông qua các cơ chế đồng bộ đa chỉ số và dừng động. Ưu điểm cốt lõi của chiến lược là cơ chế xác nhận tín hiệu đa chiều và kiểm soát rủi ro nghiêm ngặt. Mặc dù có một số rủi ro về sự chậm trễ và tín hiệu giả, nhưng thông qua việc tối ưu hóa và hoàn thiện liên tục, chiến lược này có khả năng duy trì hiệu suất ổn định trong các môi trường thị trường khác nhau.
/*backtest
start: 2024-11-12 00:00:00
end: 2024-12-11 08:00:00
period: 2h
basePeriod: 2h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Triple Indicator Strategy", shorttitle="TIS", overlay=true)
// --- Inputs ---
var string calcGroup = "Calculation Parameters"
atrLength = input.int(22, title="ATR Period", group=calcGroup)
atrMult = input.float(3.0, title="ATR Multiplier", step=0.1, group=calcGroup)
emaLength = input.int(200, title="EMA Length", group=calcGroup)
// --- ATR and EMA Calculations ---
atr = atrMult * ta.atr(atrLength)
ema200 = ta.ema(close, emaLength)
// --- Chandelier Exit Logic ---
longStop = ta.highest(high, atrLength) - atr
shortStop = ta.lowest(low, atrLength) + atr
var int dir = 1
dir := close > shortStop ? 1 : close < longStop ? -1 : dir
buySignal = dir == 1 and dir[1] == -1
sellSignal = dir == -1 and dir[1] == 1
// --- Price Volume Trend (PVT) ---
pvt = ta.cum((close - close[1]) / close[1] * volume)
pvtSignal = ta.ema(pvt, 21)
pvtBuy = ta.crossover(pvt, pvtSignal)
pvtSell = ta.crossunder(pvt, pvtSignal)
// --- Ninja Indicator ---
ninjaOsc = (ta.ema(close, 3) - ta.ema(close, 13)) / ta.ema(close, 13) * 100
ninjaSignal = ta.ema(ninjaOsc, 24)
ninjaBuy = ta.crossover(ninjaOsc, ninjaSignal)
ninjaSell = ta.crossunder(ninjaOsc, ninjaSignal)
// --- Strategy Conditions ---
longCondition = buySignal and close > ema200 and (pvtBuy or ninjaBuy)
shortCondition = sellSignal and close < ema200 and (pvtSell or ninjaSell)
if longCondition
strategy.entry("Buy", strategy.long)
strategy.exit("Exit Long", "Buy", stop=low - atr)
if shortCondition
strategy.entry("Sell", strategy.short)
strategy.exit("Exit Short", "Sell", stop=high + atr)
// --- Plotting ---
plot(ema200, title="EMA 200", color=color.blue, linewidth=2)
plotshape(buySignal, title="Chandelier Buy", location=location.belowbar, color=color.green, style=shape.triangleup, size=size.small)
plotshape(sellSignal, title="Chandelier Sell", location=location.abovebar, color=color.red, style=shape.triangledown, size=size.small)
// --- Labels for Buy/Sell with price ---
if buySignal
label.new(bar_index, low, "Buy: " + str.tostring(close), color=color.green, style=label.style_label_up, yloc=yloc.belowbar, size=size.small)
if sellSignal
label.new(bar_index, high, "Sell: " + str.tostring(close), color=color.red, style=label.style_label_down, yloc=yloc.abovebar, size=size.small)
// --- Alerts ---
alertcondition(longCondition, title="Buy Alert", message="Buy Signal Triggered!")
alertcondition(shortCondition, title="Sell Alert", message="Sell Signal Triggered!")