
Chiến lược này là một hệ thống giao dịch tổng hợp kết hợp các chỉ số CCI, RSI và hai đường trung bình di chuyển. Hệ thống này có thể nắm bắt xu hướng thông thường, đồng thời sử dụng các chỉ số RSI giao nhau để tăng xác nhận thời gian nhập cảnh để lọc ra một số tiếng ồn.
Chiến lược này chủ yếu dựa trên chỉ số CCI để xác định hướng xu hướng. Giá trị chỉ số CCI cao hơn 100 là thị trường nhiều đầu và thấp hơn 100 là thị trường trống. Hệ thống sử dụng hai đường trung bình di chuyển để hỗ trợ xác định hướng xu hướng.
Sau khi xác định xu hướng đa luồng, hệ thống sử dụng chéo của hai chỉ số RSI với chiều dài tham số khác nhau làm xác minh nhập. Ví dụ: trong thị trường đa đầu, nếu chỉ số RSI ngắn kỳ vượt qua chỉ số RSI dài kỳ, thì tín hiệu mua cuối cùng. Thiết kế này chủ yếu là để lọc tiếng ồn và tránh sự điều chỉnh ngắn hạn trong xu hướng dẫn đến giao dịch sai.
Chiến lược này chỉ mở vị trí trong thời gian giao dịch được chỉ định, chủ động thanh toán toàn bộ vị trí 15 phút trước khi đóng cửa, tránh rủi ro qua đêm. Sau khi mở vị trí, nó sẽ sử dụng dừng di chuyển để khóa lợi nhuận.
Chiến lược tổng hợp xem xét xu hướng phán đoán và cross-chứng minh chỉ số, trong khi kiểm soát rủi ro cũng đảm bảo hiệu quả của tín hiệu giao dịch. Bằng cách tối ưu hóa các tham số và điều chỉnh logic, chiến lược có thể tăng thêm lợi nhuận và giảm cơ hội bị bỏ lỡ. Đây là một ý tưởng giao dịch rất tiềm năng.
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
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/
// © rwestbrookjr
//@version=5
strategy("EMA with RSI Cross Strategy", overlay=true)
//EMA
fastLen = input(title='Fast EMA Length', defval=9)
slowLen = input(title='Slow EMA Length', defval=20)
fastEMA = ta.ema(close, fastLen)
slowEMA = ta.ema(close, slowLen)
fema = plot(fastEMA, title='FastEMA', color=color.new(color.green, 0), linewidth=1, style=plot.style_line)
sema = plot(slowEMA, title='SlowEMA', color=color.new(color.red, 0), linewidth=1, style=plot.style_line)
fill(fema, sema, color=fastEMA > slowEMA ? color.new(#417505, 50) : color.new(#890101, 50), title='Cloud')
// Bull and Bear Alerts
//Bull = ta.crossover(fastEMA, slowEMA)
Bull = fastEMA > slowEMA
//Bear = ta.crossunder(fastEMA, slowEMA)
Bear = fastEMA < slowEMA
//RSIs
rsiLength1Input = input.int(9, minval=1, title="RSI Length", group="RSI Settings")
rsiSource1Input = input.source(close, "Source", group="RSI Settings")
rsiLength2Input = input.int(20, minval=1, title="RSI Length", group="RSI Settings")
rsiSource2Input = input.source(close, "Source", group="RSI Settings")
up1 = ta.rma(math.max(ta.change(rsiSource1Input), 0), rsiLength1Input)
down1 = ta.rma(-math.min(ta.change(rsiSource1Input), 0), rsiLength1Input)
rsi = down1 == 0 ? 100 : up1 == 0 ? 0 : 100 - (100 / (1 + up1 / down1))
up2 = ta.rma(math.max(ta.change(rsiSource2Input), 0), rsiLength2Input)
down2 = ta.rma(-math.min(ta.change(rsiSource2Input), 0), rsiLength2Input)
rsi2 = down2 == 0 ? 100 : up2 == 0 ? 0 : 100 - (100 / (1 + up2 / down2))
//CCI
cciLength = input.int(20, minval=1)
src = input(hlc3, title="Source")
ma = ta.sma(src, cciLength)
cci = (src - ma) / (0.015 * ta.dev(src, cciLength))
//Trail Stop Setup
trstp = input.float(title="Trail Loss($)", minval = 0.0, step = 0.01, defval = 0.5)
longStop = 0.0, shortStop = 0.0
longStop := if Bull
stopValue = close - trstp
math.max(stopValue, longStop[1])
else
0.0
shortStop := if Bear
stopValue = close + trstp
math.min(stopValue, shortStop[1])
else
999999
//Session Setup
open_session=input(defval="0930-1545")
session = time("1", open_session)
validSession=(na(session) ? 0 : 1)
//Trade Signals
longCondition = Bull and cci > 100 and ta.crossover(rsi,rsi2) and validSession
if (longCondition)
strategy.entry("Long", strategy.long, 1)
//longExit = close > strategy.opentrades.entry_price(0) + 1.5 or close < strategy.opentrades.entry_price(0) - 0.75
longExit = close < longStop or not validSession
if (longExit)
strategy.close("Long")
shortCondition = Bear and cci < 100 and ta.crossunder(rsi,rsi2) and validSession
if (shortCondition)
strategy.entry("Short", strategy.short, 1)
//shortExit = close < strategy.opentrades.entry_price(0) - 1.5 or close > strategy.opentrades.entry_price(0) + 0.75
shortExit = close > shortStop or not validSession
if (shortExit)
strategy.close("Short")