
Chiến lược này là một chiến lược đơn giản chỉ cần làm nhiều hơn, sử dụng chỉ số RSI để đánh giá quá mua quá bán. Chúng tôi đã tăng cường nó, thêm lệnh dừng lỗ, đồng thời tích hợp mô-đun xác suất để tăng xác suất, chỉ mở vị trí khi xác suất giao dịch có lợi nhuận lớn hơn hoặc bằng 51% trong một khoảng thời gian gần đây. Điều này đã cải thiện đáng kể hiệu suất của chiến lược.
Chiến lược này sử dụng chỉ số RSI để đánh giá thị trường quá mua quá bán. Cụ thể, khi RSI vượt quá giới hạn dưới của phạm vi bán quá mức được thiết lập; khi RSI vượt quá giới hạn trên của phạm vi bán quá mức được thiết lập. Ngoài ra, chúng tôi đã thiết lập tỷ lệ dừng lỗ.
Điều quan trọng là chúng tôi tích hợp một mô-đun xác định xác suất. Mô-đun này sẽ thống kê tỷ lệ giao dịch nhiều hơn hoặc thua lỗ trong một khoảng thời gian gần đây (thông qua tham số lookback). Chỉ khi xác suất giao dịch có lợi gần đây lớn hơn hoặc bằng 51%, bạn sẽ mở nhiều vị trí. Điều này làm giảm đáng kể khả năng giao dịch thua lỗ.
Đây là một chiến lược RSI tăng xác suất có những lợi thế sau đây so với chiến lược RSI thông thường:
Chiến lược này cũng có những rủi ro:
Giải pháp tương ứng:
Chiến lược này có thể được tối ưu hóa hơn nữa ở những khía cạnh sau:
Chiến lược này là một chiến lược RSI đơn giản, tích hợp các mô-đun xác định xác suất để tăng cường. So với chiến lược RSI thông thường, có thể lọc một số giao dịch thua lỗ, rút lại toàn bộ và tối ưu hóa tỷ lệ thua lỗ. Sau đó, có thể cải thiện từ việc tạo ra lỗ hổng, tối ưu hóa động lực, v.v.
/*backtest
start: 2023-11-19 00:00:00
end: 2023-12-19 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © thequantscience
//@version=5
strategy("Reinforced RSI",
overlay = true,
default_qty_type = strategy.percent_of_equity,
default_qty_value = 100,
pyramiding = 1,
currency = currency.EUR,
initial_capital = 1000,
commission_type = strategy.commission.percent,
commission_value = 0.07)
lenght_rsi = input.int(defval = 14, minval = 1, title = "RSI lenght: ")
rsi = ta.rsi(close, length = lenght_rsi)
rsi_value_check_entry = input.int(defval = 35, minval = 1, title = "Oversold: ")
rsi_value_check_exit = input.int(defval = 75, minval = 1, title = "Overbought: ")
trigger = ta.crossunder(rsi, rsi_value_check_entry)
exit = ta.crossover(rsi, rsi_value_check_exit)
entry_condition = trigger
TPcondition_exit = exit
look = input.int(defval = 30, minval = 0, maxval = 500, title = "Lookback period: ")
Probabilities(lookback) =>
isActiveLong = false
isActiveLong := nz(isActiveLong[1], false)
isSellLong = false
isSellLong := nz(isSellLong[1], false)
int positive_results = 0
int negative_results = 0
float positive_percentage_probabilities = 0
float negative_percentage_probabilities = 0
LONG = not isActiveLong and entry_condition == true
CLOSE_LONG_TP = not isSellLong and TPcondition_exit == true
p = ta.valuewhen(LONG, close, 0)
p2 = ta.valuewhen(CLOSE_LONG_TP, close, 0)
for i = 1 to lookback
if (LONG[i])
isActiveLong := true
isSellLong := false
if (CLOSE_LONG_TP[i])
isActiveLong := false
isSellLong := true
if p[i] > p2[i]
positive_results += 1
else
negative_results -= 1
positive_relative_probabilities = positive_results / lookback
negative_relative_probabilities = negative_results / lookback
positive_percentage_probabilities := positive_relative_probabilities * 100
negative_percentage_probabilities := negative_relative_probabilities * 100
positive_percentage_probabilities
probabilities = Probabilities(look)
lots = strategy.equity/close
var float e = 0
var float c = 0
tp = input.float(defval = 1.00, minval = 0, title = "Take profit: ")
sl = input.float(defval = 1.00, minval = 0, title = "Stop loss: ")
if trigger==true and strategy.opentrades==0 and probabilities >= 51
e := close
strategy.entry(id = "e", direction = strategy.long, qty = lots, limit = e)
takeprofit = e + ((e * tp)/100)
stoploss = e - ((e * sl)/100)
if exit==true
c := close
strategy.exit(id = "c", from_entry = "e", limit = c)
if takeprofit and stoploss
strategy.exit(id = "c", from_entry = "e", stop = stoploss, limit = takeprofit)