Double Channel Kitchen - Chiến lược giao dịch thuật toán tập trung vào tăng trưởng tài sản

Tác giả:ChaoZhang, Ngày: 2023-10-10 15:25:53
Tags:

Tổng quan

Chiến lược Double Channel Kitchen sử dụng các chỉ số Supertrend và StochRSI để phân tích xu hướng giá và điều kiện mua quá mức / bán quá mức trong các khung thời gian khác nhau, để xác định các tín hiệu mua và bán tiềm năng.

Chiến lược logic

Chiến lược này sử dụng chỉ số Supertrend trong cả khung thời gian 1 giờ và 4 giờ để xác định hướng xu hướng giá. Khi Supertrends trong cả hai khung thời gian đều hướng về cùng một hướng, nó cho thấy xu hướng giá tương đối mạnh.

Ngoài ra, chỉ số StochRSI được sử dụng để phát hiện các điều kiện mua quá mức / bán quá mức. StochRSI kết hợp các điểm mạnh của cả chỉ số RSI và Stochastic Oscillator. Khi đường StochRSI vượt quá ngưỡng mua quá mức, nó chỉ ra một điều kiện bán quá mức có thể xảy ra trong giá. Khi đường StochRSI vượt dưới ngưỡng bán quá mức, nó đánh dấu một điều kiện mua quá mức tiềm ẩn.

Để xác minh thêm tín hiệu, một giai đoạn xem lại được thực hiện, sau khi tín hiệu quá mua / quá bán StochRSI, chuyển động giá trong vài thanh trước được kiểm tra - nếu nó xác nhận tín hiệu StochRSI, sau đó mua hoặc bán sẽ được kích hoạt.

Tóm lại, chiến lược này sử dụng khung thời gian hai Supertrend để xác định xu hướng chính và StochRSI để xác định sự đảo ngược địa phương, để thực hiện các giao dịch theo xu hướng trong trung hạn đến dài hạn.

Ưu điểm của Chiến lược

  • Sử dụng các chỉ số trên nhiều khung thời gian giúp lọc ra các tín hiệu sai
  • Kết hợp các điểm mạnh của Supertrend và StochRSI để phân tích xu hướng và mua quá mức / bán quá mức
  • Kiểm tra xem lại tránh giao dịch không cần thiết
  • Các giao dịch trung và dài hạn tránh giao dịch quá mức và trượt
  • Dễ hiểu thiết lập chỉ số kép, với điều chỉnh tham số linh hoạt

Rủi ro của chiến lược

  • Thị trường hỗn loạn mà không có xu hướng trung bình dài hạn rõ ràng có thể tạo ra tín hiệu sai
  • Thời gian xem lại quá nhiều có thể khiến bạn bỏ lỡ những cơ hội tốt
  • Cài đặt tham số StochRSI kém có thể dẫn đến tín hiệu mua quá mức / bán quá mức không chính xác
  • Các thông số siêu xu hướng không chính xác có thể gây ra phán đoán hướng xu hướng sai
  • Các tín hiệu cơ học sau đó bỏ qua những thay đổi cơ bản lớn

Cải tiến:

  • Tối ưu hóa sự kết hợp của các tham số StochRSI và Supertrend
  • Điều chỉnh thời gian xem lại dựa trên các điều kiện thị trường khác nhau
  • Thêm các chỉ số âm lượng để xác minh tín hiệu
  • Theo dõi các sự kiện tin tức cơ bản quan trọng, can thiệp thủ công khi cần thiết

Các lĩnh vực cải tiến

  • Thêm nhiều chỉ số Supertrend trên các khung thời gian khác nhau để sàng lọc nhiều giai đoạn
  • Thay StochRSI bằng các chỉ số mua quá mức / bán quá mức khác chẳng hạn như KD, RSI
  • Kết hợp các chiến lược dừng lỗ để đi theo xu hướng
  • Kết hợp các đường trung bình động chính ví dụ như MA 30 giai đoạn để xác định xu hướng chính
  • Phát triển tối ưu hóa tham số tự động cho độ bền

Kết luận

Chiến lược Double Channel Kitchen sử dụng hiệu quả siêu xu hướng cho xu hướng chính và StochRSI cho sự đảo ngược địa phương, để thực hiện một hệ thống theo xu hướng đáng tin cậy. Nó tập trung vào cổ phần trung dài hạn để tránh giao dịch và trượt quá mức. Thông qua tối ưu hóa tham số, kết hợp các chỉ số, chiến lược này có thể đạt được kết quả tích cực ổn định. Tuy nhiên, các nhà đầu tư vẫn nên cảnh giác với những thay đổi cơ bản lớn, thay vì chỉ theo dõi các tín hiệu chỉ số một cách cơ học. Nhìn chung, chiến lược này cung cấp một cách tiếp cận phân tích kỹ thuật hiệu quả cho các nhà đầu tư tích cực để tạo ra lợi nhuận tích cực với nhận thức rủi ro thích hợp.


/*backtest
start: 2023-09-09 00:00:00
end: 2023-10-09 00:00:00
period: 4h
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/
// © Baby_whale_to_moon

//@version=5
strategy('Kitchen [ilovealgotrading]', overlay=true, format=format.price, initial_capital = 1000)

// BACKTEST DATE
Start_Time = input(defval=timestamp('01 January 2017 13:30 +0000'), title='Start_Time', group = " ################# BACKTEST DATE ################ " )
End_Time = input(defval=timestamp('30 April 2024 19:30 +0000'), title='End_Time', group = " ################# BACKTEST DATE ################ " )

// supertrend 
atrPeriod = input(10, 'ATR Length', group = " #################  Supertrend  ################ ")
factor = input(3, 'Factor', group = " #################  Supertrend  ################ ")

time1 = input.string(title='Short Time Period', defval='07 1h', options=['01 1m','02 3m','03 5m',  '04 15m', '05 30m', '06 45m', '07 1h', '08 2h', '09 3h', '10 4h', '11 1D', '12 1W' ], group = " #################  Supertrend  ################ ",tooltip = "this timeframe is the value of our short-time supertrend indicator")
time2 = input.string(title='Long Time Period', defval='10 4h', options=[ '01 1m','02 3m','03 5m', '04 15m', '05 30m', '06 45m', '07 1h', '08 2h', '09 3h', '10 4h', '11 1D', '12 1W' ], group = " #################  Supertrend  ################ ",tooltip = "this timeframe is the value of our long-time supertrend indicator")


res(Resolution) =>
    if Resolution == '00 Current'
        timeframe.period
    else
        if Resolution == '01 1m'
            '1'
        else
            if Resolution == '02 3m'
                '3'
            else
                if Resolution == '03 5m'
                    '5'
                else
                    if Resolution == '04 15m'
                        '15'
                    else
                        if Resolution == '05 30m'
                            '30'
                        else
                            if Resolution == '06 45m'
                                '45'
                            else
                                if Resolution == '07 1h'
                                    '60'
                                else
                                    if Resolution == '08 2h'
                                        '120'
                                    else
                                        if Resolution == '09 3h'
                                            '180'
                                        else
                                            if Resolution == '10 4h'
                                                '240'
                                            else
                                                if Resolution == '11 1D'
                                                    '1D'
                                                else
                                                    if Resolution == '12 1W'
                                                        '1W'
                                                    else
                                                        if Resolution == '13 1M'
                                                            '1M'


// supertrend Long time period 
[supertrend2, direction2] = request.security(syminfo.tickerid, res(time2), ta.supertrend(factor, atrPeriod))
bodyMiddle4 = plot((open + close) / 2, display=display.none)
upTrend2 = plot(direction2 < 0 ? supertrend2 : na, 'Up Trend', color=color.new(color.green, 0), style=plot.style_linebr, linewidth=2)
downTrend2 = plot(direction2 < 0 ? na : supertrend2, 'Down Trend', color=color.new(color.red, 0), style=plot.style_linebr, linewidth=2)

// supertrend short time period 
[supertrend1, direction1] = request.security(syminfo.tickerid, res(time1), ta.supertrend(factor, atrPeriod))
bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(direction1 < 0 ? supertrend1 : na, 'Up Trend', color=color.new(color.yellow, 0), style=plot.style_linebr)
downTrend = plot(direction1 < 0 ? na : supertrend1, 'Down Trend', color=color.new(color.orange, 0), style=plot.style_linebr)


// Stochastic RSI
low_limit_stoch_rsi = input.float(title = 'Stoch Rsi Low Limit', step=0.5, defval=15, group = " #################  Stoch RSI   ################ ", tooltip = "when Stock rsi value crossover Low Limit value we get Long")
up_limit_stoch_rsi = input.float(title = 'Stoch Rsi Up Limit', step=0.5, defval=85, group = " #################  Stoch RSI   ################ ", tooltip = "when Stock rsi value crossunder Up Limit value we get Short")
stocrsi_back_length = input.int(20, 'Stoch Rsi retroactive length', minval=1, group = " #################  Stoch RSI   ################ ", tooltip = "How many candles are left behind, even if there is a buy or sell signal, it will be valid now")
smoothK = input.int(3, 'Stochastic RSI K', minval=1, group = " #################  Stoch RSI   ################ ")
lengthRSI = input.int(14, 'RSI Length', minval=1, group = " #################  Stoch RSI   ################ ")
lengthStoch = input.int(14, 'Stochastic Length', minval=1, group = " #################  Stoch RSI   ################ ")
src_rsi = input(close, title='RSI Source', group = " #################  Stoch RSI   ################ ")
rsi1 = request.security(syminfo.tickerid, '240', ta.rsi(src_rsi, lengthRSI))
k = request.security(syminfo.tickerid, '240', ta.sma(ta.stoch(rsi1, rsi1, rsi1, lengthStoch), smoothK))

// Strategy settings 
dollar = input.float(title='Dollar Cost Per Position ', defval=20000, group = " #################  Strategy Settings  ################ ")
trade_direction = input.string(title='Trade_direction', group = " #################  Strategy Settings  ################ ", options=['LONG', 'SHORT', 'BOTH'], defval='BOTH')
Long_message_open = input('Long Open', title = "Long Open Message", group = " #################  Strategy Settings  ################ ", tooltip = "if you write your alert window this code {{strategy.order.alert_message}} .When trigger Long signal you will get dynamically what you pasted here for Long Open Message ")
Short_message_open = input('Short Open', title = "Short Open Message", group = " #################  Strategy Settings  ################ ", tooltip = "if you write your alert window this code {{strategy.order.alert_message}} .When trigger Long signal you will get dynamically what you pasted here for Short Open Message ")
Long_message_close = input('Long Close', title = "Long Close Message", group = " #################  Strategy Settings  ################ ", tooltip = "if you write your alert window this code {{strategy.order.alert_message}} .When trigger Long signal you will get dynamically what you pasted here for Long Close Message ")
Short_message_close = input('Short Close', title = "Short Close Message", group = " #################  Strategy Settings  ################ ", tooltip = "if you write your alert window this code {{strategy.order.alert_message}} .When trigger Long signal you will get dynamically what you pasted here for Short Close Message ")

Time_interval = true
bgcolor(Time_interval ? color.rgb(255, 235, 59, 95) : na)

back_long = 0
back_short = 0

for i = 1 to stocrsi_back_length by 1
    if ta.crossover(k, low_limit_stoch_rsi)[i] == true 
        back_long += i
        back_long
    if ta.crossunder(k, up_limit_stoch_rsi)[i] == true 
        back_short += i
        back_short

// bgcolor(back_long>0?color.rgb(153, 246, 164, 54):na)
// bgcolor(back_short>0?color.rgb(246, 153, 153, 54):na)

buy_signal = false
sell_signal = false

if direction2 < 0 and direction1 < 0 and back_long > 0
    buy_signal := true
    buy_signal

if direction2 > 0 and direction1 > 0 and back_short > 0
    sell_signal := true
    sell_signal


//bgcolor(buy_signal  ? color.new(color.lime,90) : na ,title="BUY bgcolor")
plotshape( buy_signal[1] == false and  strategy.opentrades == 0 and Time_interval and buy_signal  ? supertrend2 : na, title="Buy", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=color.green, textcolor=color.white)

//bgcolor(sell_signal  ? color.new(color.red,90) : na ,title="SELL bgcolor")
plotshape(sell_signal[1] == false and strategy.opentrades == 0 and Time_interval and sell_signal  ? supertrend2 : na , title="Sell", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=color.red, textcolor=color.white)


// Strategy entries 
if strategy.opentrades == 0 and Time_interval and buy_signal and ( trade_direction == 'LONG' or trade_direction == 'BOTH')
    strategy.entry('Long_Open', strategy.long, qty=dollar / close, alert_message=Long_message_open)

if strategy.opentrades == 0 and Time_interval and sell_signal and ( trade_direction == 'SHORT' or trade_direction == 'BOTH')
    strategy.entry('Short_Open', strategy.short, qty=dollar / close, alert_message=Short_message_open)


// Strategy Close
if close < supertrend1 and strategy.position_size > 0 
    strategy.exit('Long_Close',from_entry = "Long_Open", stop=close, qty_percent=100, alert_message=Long_message_close)

if close > supertrend1 and strategy.position_size < 0 
    strategy.exit('Short_Close',from_entry = "Short_Open", stop=close, qty_percent=100, alert_message=Short_message_close)



Thêm nữa