
Chiến lược này là một hệ thống giao dịch tự điều chỉnh dựa trên RSI (chỉ số tương đối mạnh) để tối ưu hóa việc tạo tín hiệu giao dịch bằng cách điều chỉnh động so với ngưỡng mua bán quá mức. Sự đổi mới cốt lõi của chiến lược là việc giới thiệu phương pháp Bufi tự điều chỉnh ngưỡng (BAT), điều chỉnh ngưỡng kích hoạt RSI theo xu hướng thị trường và động lực biến động giá, làm tăng hiệu quả của chiến lược RSI truyền thống.
Trung tâm của chiến lược là nâng cấp hệ thống RSI cố định truyền thống thành hệ thống giảm giá động. Các cách thực hiện cụ thể như sau:
Chiến lược cũng bao gồm hai cơ chế kiểm soát rủi ro:
Đây là một chiến lược giao dịch tự thích ứng sáng tạo, giải quyết các hạn chế của chiến lược RSI truyền thống thông qua tối ưu hóa giảm giá động. Chiến lược tổng hợp xem xét xu hướng và biến động của thị trường, có khả năng thích ứng và kiểm soát rủi ro mạnh mẽ. Mặc dù có những thách thức như tối ưu hóa tham số, nhưng thông qua cải tiến và tối ưu hóa liên tục, chiến lược này có khả năng đạt được hiệu suất ổn định trong giao dịch thực tế.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-11 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PineCodersTASC
// TASC Issue: October 2024
// Article: Overbought/Oversold
// Oscillators: Useless Or Just Misused
// Article By: Francesco P. Bufi
// Language: TradingView's Pine Script™ v5
// Provided By: PineCoders, for tradingview.com
//@version=5
title ='TASC 2024.10 Adaptive Oscillator Threshold'
stitle = 'AdapThrs'
strategy(title, stitle, false, default_qty_type = strategy.percent_of_equity,
default_qty_value = 10, slippage = 5)
// --- Inputs ---
string sys = input.string("BAT", "System", options=["Traditional", "BAT"])
int rsiLen = input.int(2, "RSI Length", 1)
int buyLevel = input.int(14, "Buy Level", 0)
int adapLen = input.int(8, "Adaptive Length", 2)
float adapK = input.float(6, "Adaptive Coefficient")
int exitBars = input.int(28, "Fixed-Bar Exit", 1, group = "Strategy Settings")
float DSL = input.float(1600, "Dollar Stop-Loss", 0, group = "Strategy Settings")
// --- Functions ---
// Bufi's Adaptive Threshold
BAT(float price, int length) =>
float sd = ta.stdev(price, length)
float lr = ta.linreg(price, length, 0)
float slope = (lr - price[length]) / (length + 1)
math.min(0.5, math.max(-0.5, slope / sd))
// --- Calculations ---
float osc = ta.rsi(close, rsiLen)
// Strategy entry rules
// - Traditional system
if sys == "Traditional" and osc < buyLevel
strategy.entry("long", strategy.long)
// - BAT system
float thrs = buyLevel * adapK * BAT(close, adapLen)
if sys == "BAT" and osc < thrs
strategy.entry("long", strategy.long)
// Strategy exit rules
// - Fixed-bar exit
int nBar = bar_index - strategy.opentrades.entry_bar_index(0)
if exitBars > 0 and nBar >= exitBars
strategy.close("long", "exit")
// - Dollar stop-loss
if DSL > 0 and strategy.opentrades.profit(0) <= - DSL
strategy.close("long", "Stop-loss", immediately = true)
// Visuals
rsiColor = #1b9e77
thrsColor = #d95f02
rsiLine = plot(osc, "RSI", rsiColor, 1)
thrsLine = plot(sys == "BAT" ? thrs : buyLevel, "Threshold", thrsColor, 1)
zeroLine = plot(0.0, "Zero", display = display.none)
fill(zeroLine, thrsLine, sys == "BAT" ? thrs : buyLevel, 0.0, color.new(thrsColor, 60), na)