
Chiến lược này sử dụng sự kết hợp của T3 Moving Averages, ATR Indicators và Hybrid Force để xác định các tín hiệu mua và bán, và theo dõi xu hướng giao dịch dựa trên ATR để tính toán điểm dừng lỗ. Lợi thế của chiến lược là phản ứng nhanh chóng và kiểm soát rủi ro giao dịch.
T3 trung bình di chuyển: tính toán trung bình di chuyển T3 với một tham số mịn là T3 (tức 100 mặc định) để xác định hướng xu hướng.
ATR: tính toán ATR (trung bình độ dao động thực tế) để xác định kích thước của vị trí dừng lỗ.
ATR dừng di động: Một đường dừng di động được tính toán dựa trên ATR, có thể được điều chỉnh theo sự thay đổi giá và tỷ lệ biến động, để theo dõi xu hướng.
Tín hiệu mua: Tín hiệu mua được tạo ra khi giá đóng cửa vượt qua đường dừng di chuyển ATR và dưới mức trung bình T3.
Tín hiệu bán: Tín hiệu bán được tạo ra khi vượt qua đường dừng di chuyển ATR dưới giá đóng cửa và trên mức trung bình T3.
Lệnh dừng lỗ: Sau khi nhập, giá dừng lỗ và giá dừng được tính dựa trên giá trị ATR và tỷ lệ lợi nhuận rủi ro mà người dùng đặt.
Sau khi mua, giá dừng là giá mua trừ ATR, giá dừng là giá mua cộng với ATR nhân tỷ lệ lợi nhuận rủi ro.
Sau khi bán, giá dừng là giá mua cộng với giá ATR, giá dừng là giá mua trừ giá ATR nhân tỷ lệ lợi nhuận rủi ro.
Khi giá kích hoạt mức dừng lỗ hoặc giá dừng, vị thế bằng phẳng sẽ ra đi.
T3 có tham số trung bình mặc định là 100, nhạy cảm hơn so với trung bình di chuyển thông thường và có thể phản ứng nhanh hơn với sự thay đổi giá.
Việc tính toán Stop Loss di động bằng ATR có thể dựa trên giá trail biến động của thị trường, tránh rủi ro bị phá vỡ. Vị trí Stop Loss Stop Loss dựa trên ATR có thể kiểm soát tỷ lệ rủi ro cho mỗi giao dịch.
ATR Mobile Stop Line có thể theo dõi xu hướng và không bị kích hoạt ngay cả khi giá giảm ngắn hạn, do đó giảm tín hiệu sai.
Chu kỳ trung bình T3 và chu kỳ ATR có thể được tối ưu hóa để điều chỉnh các tham số cho các thị trường khác nhau và tăng sự ổn định của chiến lược.
Nếu xảy ra tình huống khắc nghiệt, giá có thể phá vỡ đường dừng và gây thiệt hại. Các chu kỳ ATR và khoảng cách dừng có thể được mở rộng thích hợp để giảm nhẹ.
Khi xu hướng đảo ngược, giá vượt qua đường dừng di chuyển có thể gây thiệt hại. Bạn có thể kết hợp các chỉ số khác để đánh giá xu hướng và tránh giao dịch gần điểm đảo ngược.
Tối ưu hóa tham số cần được hỗ trợ bởi dữ liệu lịch sử phong phú, có nguy cơ tối ưu hóa quá mức. Các tham số tối ưu hóa kết hợp nhiều chu kỳ thời gian đa thị trường nên được áp dụng, không thể phụ thuộc vào một tập dữ liệu duy nhất.
Kiểm tra các tham số khác nhau của chu kỳ trung bình T3 để tìm ra sự kết hợp tham số tốt nhất để cân bằng độ nhạy và độ ổn định
Kiểm tra tham số chu kỳ ATR để tìm sự cân bằng tốt nhất giữa kiểm soát rủi ro và xu hướng thu được
Kết hợp các chỉ số như RSI, MACD để tránh giao dịch sai
Sử dụng phương pháp học máy để đào tạo các tham số tối ưu, giảm giới hạn tối ưu hóa bằng tay
Tăng chiến lược quản lý vị thế để kiểm soát rủi ro tốt hơn
Chiến lược này tích hợp các lợi thế của đường trung bình T3 và chỉ số ATR để đáp ứng nhanh chóng với sự thay đổi giá cả và kiểm soát rủi ro. Bằng cách tối ưu hóa và kết hợp các chỉ số khác, bạn có thể tăng cường sự ổn định của chiến lược và hiệu quả giao dịch. Tuy nhiên, nhà giao dịch vẫn cần chú ý đến rủi ro đảo ngược và đột phá, tránh phụ thuộc quá nhiều vào kết quả kiểm tra lại.
/*backtest
start: 2022-10-31 00:00:00
end: 2023-11-06 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy(title='UT Bot Alerts (QuantNomad) Strategy w/ NinjaView', overlay=true)
T3 = input(100)//600
// Input for Long Settings
// Input for Long Settings
xPrice3 = close
xe1 = ta.ema(xPrice3, T3)
xe2 = ta.ema(xe1, T3)
xe3 = ta.ema(xe2, T3)
xe4 = ta.ema(xe3, T3)
xe5 = ta.ema(xe4, T3)
xe6 = ta.ema(xe5, T3)
b3 = 0.7
c1 = -b3*b3*b3
c2 = 3*b3*b3+3*b3*b3*b3
c3 = -6*b3*b3-3*b3-3*b3*b3*b3
c4 = 1+3*b3+b3*b3*b3+3*b3*b3
nT3Average = c1 * xe6 + c2 * xe5 + c3 * xe4 + c4 * xe3
//plot(nT3Average, color=color.white, title="T3")
// Buy Signal - Price is below T3 Average
buySignal3 = xPrice3 < nT3Average
sellSignal3 = xPrice3 > nT3Average
// Inputs
a = input(1, title='Key Value. "This changes the sensitivity"')
c = input(50, title='ATR Period')
h = input(true, title='Signals from Heikin Ashi Candles')
riskRewardRatio = input(1, title='Risk Reward Ratio')
xATR = ta.atr(c)
nLoss = a * xATR
src = h ? request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, close, lookahead=barmerge.lookahead_off) : close
xATRTrailingStop = 0.0
iff_1 = src > nz(xATRTrailingStop[1], 0) ? src - nLoss : src + nLoss
iff_2 = src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), src + nLoss) : iff_1
xATRTrailingStop := src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src - nLoss) : iff_2
pos = 0
iff_3 = src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
pos := src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0) ? 1 : iff_3
xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue
ema = ta.ema(src, 1)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossunder(ema, xATRTrailingStop)
buy = src > xATRTrailingStop and above
sell = src < xATRTrailingStop and below
barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop
plotshape(buy, title='Buy', text='Buy', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), size=size.tiny)
plotshape(sell, title='Sell', text='Sell', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny)
barcolor(barbuy ? color.new(color.green, 90) : na)
barcolor(barsell ? color.new(color.red, 90) : na)
var float entryPrice = na
var float takeProfitLong = na
var float stopLossLong = na
var float takeProfitShort = na
var float stopLossShort = na
if buy and buySignal3
entryPrice := src
takeProfitLong := entryPrice + nLoss * riskRewardRatio
stopLossLong := entryPrice - nLoss
takeProfitShort := na
stopLossShort := na
if sell and sellSignal3
entryPrice := src
takeProfitShort := entryPrice - nLoss * riskRewardRatio
stopLossShort := entryPrice + nLoss
takeProfitLong := na
stopLossLong := na
// Strategy order conditions
acct = "Sim101"
ticker = "ES 12-23"
qty = 1
OCOMarketLong = '{ "alert": "OCO Market Long", "account": "' + str.tostring(acct) + '", "ticker": "' + str.tostring(ticker) + '", "qty": "' + str.tostring(qty) + '", "take_profit_price": "' + str.tostring(takeProfitLong) + '", "stop_price": "' + str.tostring(stopLossLong) + '", "tif": "DAY" }'
OCOMarketShort = '{ "alert": "OCO Market Short", "account": "' + str.tostring(acct) + '", "ticker": "' + str.tostring(ticker) + '", "qty": "' + str.tostring(qty) + '", "take_profit_price": "' + str.tostring(takeProfitShort) + '", "stop_price": "' + str.tostring(stopLossShort) + '", "tif": "DAY" }'
CloseAll = '{ "alert": "Close All", "account": "' + str.tostring(acct) + '", "ticker": "' + str.tostring(ticker) + '" }'
strategy.entry("Long", strategy.long, when=buy ,alert_message=OCOMarketLong)
strategy.entry("Short", strategy.short, when=sell , alert_message=OCOMarketShort)
// Setting the take profit and stop loss for long trades
strategy.exit("Take Profit/Stop Loss", "Long", stop=stopLossLong, limit=takeProfitLong,alert_message=CloseAll)
// Setting the take profit and stop loss for short trades
strategy.exit("Take Profit/Stop Loss", "Short", stop=stopLossShort, limit=takeProfitShort,alert_message=CloseAll)
// Plot trade setup boxes
bgcolor(buy ? color.new(color.green, 90) : na, transp=0, offset=-1)
bgcolor(sell ? color.new(color.red, 90) : na, transp=0, offset=-1)
longCondition = buy and not na(entryPrice)
shortCondition = sell and not na(entryPrice)
var line longTakeProfitLine = na
var line longStopLossLine = na
var line shortTakeProfitLine = na
var line shortStopLossLine = na
if longCondition
longTakeProfitLine := line.new(bar_index, takeProfitLong, bar_index + 1, takeProfitLong, color=color.green, width=2)
longStopLossLine := line.new(bar_index, stopLossLong, bar_index + 1, stopLossLong, color=color.red, width=2)
label.new(bar_index + 1, takeProfitLong, str.tostring(takeProfitLong, "#.#####"), color=color.green, style=label.style_none, textcolor=color.green, size=size.tiny)
label.new(bar_index + 1, stopLossLong, str.tostring(stopLossLong, "#.#####"), color=color.red, style=label.style_none, textcolor=color.red, size=size.tiny)
if shortCondition
shortTakeProfitLine := line.new(bar_index, takeProfitShort, bar_index + 1, takeProfitShort, color=color.green, width=2)
shortStopLossLine := line.new(bar_index, stopLossShort, bar_index + 1, stopLossShort, color=color.red, width=2)
label.new(bar_index + 1, takeProfitShort, str.tostring(takeProfitShort, "#.#####"), color=color.green, style=label.style_none, textcolor=color.green, size=size.tiny)
label.new(bar_index + 1, stopLossShort, str.tostring(stopLossShort, "#.#####"), color=color.red, style=label.style_none, textcolor=color.red, size=size.tiny)
alertcondition(buy, 'UT Long', 'UT Long')
alertcondition(sell, 'UT Short', 'UT Short')