Chiến lược giao dịch chỉ số RSI ngẫu nhiên

Tác giả:ChaoZhang, Ngày: 2023-09-11 11:57:39
Tags:

Chiến lược giao dịch chỉ số RSI ngẫu nhiên

Chiến lược này giao dịch dựa trên các tín hiệu chéo từ chỉ số Stochastic RSI.

Các quy tắc nhập cảnh cụ thể là:

  • Nhập dài khi chỉ số RSI Stochastic vượt trên 30

  • Nhập ngắn khi chỉ số RSI Stochastic vượt dưới 70

Các bộ lọc nhập thêm:

  • Long đòi hỏi SMA 9 giai đoạn trên SMA 21 giai đoạn

  • Short đòi hỏi SMA 9 giai đoạn dưới SMA 21 giai đoạn

  • Long chỉ dưới VWAP, short chỉ trên VWAP

Chiến lược sử dụng dừng lỗ và lấy lợi nhuận để quản lý rủi ro:

  • Đặt lệnh dừng lỗ ở mức 20 lần cho cả hai lệnh dài và ngắn

  • Lấy lợi nhuận đặt tại 25 ticks cho cả hai dài và ngắn

Ưu điểm chính là sử dụng chỉ số RSI Stochastic để xác định các khu vực mua quá mức / bán quá mức kết hợp với bộ lọc SMA và VWAP để giảm tín hiệu sai. Tuy nhiên, chiến lược này hoạt động tốt hơn trong xu hướng hơn là thị trường giới hạn phạm vi.


/*backtest
start: 2023-09-03 00:00:00
end: 2023-09-10 00:00:00
period: 1m
basePeriod: 1m
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/
// © thedoggwalker

//@version=4
strategy("Stochastic RSI Strategy", overlay=true)

// Stochastic RSI
length = input(14, title="Length")
src = input(close, title="Source")
smoothK = input(3, title="K")
smoothD = input(3, title="D")

rsiValue = rsi(src, length)
highestRSI = highest(rsiValue, length)
lowestRSI = lowest(rsiValue, length)
k = (rsiValue - lowestRSI) / (highestRSI - lowestRSI) * 100
d = sma(k, smoothD)

// Moving averages
maShort = sma(close, 9)
maLong = sma(close, 21)

// Spread between moving averages
spread = maShort - maLong

// VWAP
vwapValue = vwap(hlc3)

// Entry conditions
longCondition = crossover(k, 30) and spread > 0 and close < vwapValue
shortCondition = crossunder(k, 70) and spread < 0 and close > vwapValue

// Entry orders
if (longCondition)
    strategy.entry("Long", strategy.long)

if (shortCondition)
    strategy.entry("Short", strategy.short)

// Exit orders
// longStopLoss = close - 20 * syminfo.mintick
// longTakeProfit = close + 25 * syminfo.mintick
// strategy.exit("Exit Long", "Long", stop=longStopLoss, limit=longTakeProfit)

// shortStopLoss = close + 20 * syminfo.mintick
// shortTakeProfit = close - 25 * syminfo.mintick
// strategy.exit("Exit Short", "Short", stop=shortStopLoss, limit=shortTakeProfit)

Thêm nữa