Chiến lược chỉ số ngược

Tác giả:ChaoZhang, Ngày: 2023-12-13 14:45:51
Tags:

img

Tổng quan

Đây là một chiến lược giao dịch chuyển nhượng dựa trên nhiều chỉ số kỹ thuật. Nó kết hợp CCI, chỉ số Động lực, RSI và các chỉ số khác để xác định các cơ hội giao dịch dài và ngắn tiềm năng. Chiến lược tạo ra các tín hiệu giao dịch khi các chỉ số hiển thị tín hiệu mua quá mức / bán quá mức và giá rút lui.

Chiến lược logic

Các tín hiệu giao dịch của chiến lược đến từ một chỉ số tùy chỉnh có tên là Edri Extreme Points Buy & Sell. Nó tính đến CCI, chỉ số Động lực và chéo RSI.

Điều kiện tín hiệu dài:

  1. Chỉ số Edri Extreme Points Buy & Sell kích hoạt tín hiệu mua, tức là CCI vượt trên 0 hoặc Momentum vượt trên 0, và RSI dưới mức bán quá mức.
  2. Giá kéo trở lại hoặc dưới đường EMA 100 giai đoạn.

Điều kiện tín hiệu ngắn:

  1. Chỉ số Edri Extreme Points Buy & Sell kích hoạt tín hiệu bán, tức là CCI vượt dưới 0 hoặc Momentum vượt dưới 0, và RSI nằm trên mức mua quá mức.
  2. Giá kéo trở lại hoặc trên EMA 100 giai đoạn.

Chiến lược cũng có thể được cấu hình để tìm ra các chênh lệch tăng / giảm thường xuyên, tạo ra các tín hiệu giao dịch chỉ khi RSI khác biệt đáng kể với giá.

Khi các tín hiệu giao dịch được kích hoạt, chiến lược thiết lập stop loss ở mức giá nhập cảnh ± 2ATR, lấy lợi nhuận ở mức giá nhập cảnh ± 4ATR. Điều này cho phép phạm vi stop loss và take profit hợp lý dựa trên sự biến động của thị trường.

Phân tích lợi thế

  1. Kết hợp nhiều chỉ số tránh các tín hiệu sai từ một chỉ số duy nhất.
  2. Phong cách giao dịch đảo ngược nắm bắt các cơ hội trung hạn trong các thị trường giới hạn phạm vi.
  3. Các lệnh dừng lỗ và lấy lợi nhuận dựa trên ATR có thể điều chỉnh các vị trí dựa trên biến động thị trường.
  4. Việc tìm ra sự khác biệt tránh mở các vị trí mà không có mức mua quá mức / bán quá mức.

Phân tích rủi ro

  1. Các thông số chỉ số không chính xác có thể dẫn đến việc bỏ lỡ cơ hội hoặc quá nhiều tín hiệu sai.
  2. Giao dịch đảo ngược có thể gây ra lỗ dừng liên tiếp trong các thị trường xu hướng.
  3. ATR có hiệu ứng chậm trễ và không thể cập nhật dừng lỗ / lấy lợi nhuận kịp thời trong các thị trường chuyển động nhanh.

Giải pháp:

  1. Kiểm tra lại và tối ưu hóa các thông số chỉ số để tìm ra sự kết hợp tốt nhất.
  2. Xem xét việc đình chỉ chiến lược khi xu hướng mạnh.
  3. Kết hợp với các phương pháp dừng lỗ khác như dừng lỗ di chuyển hoặc dừng lỗ ngược lại.

Hướng dẫn tối ưu hóa

  1. Kiểm tra các kết hợp tham số khác nhau của CCI, độ dài động lực, tham số RSI, nhân ATR v.v.
  2. Thêm các điều kiện lọc khác như mô hình giá, thay đổi khối lượng v.v.
  3. Điều chỉnh quy tắc định kích thước vị trí như tỷ lệ vị trí dựa trên ATR.
  4. Thiết lập mẫu tham số cho các sản phẩm và khung thời gian khác nhau.
  5. Xem xét thêm theo dõi xu hướng để đình chỉ giao dịch đảo ngược trên thị trường xu hướng.

Tóm lại

Chiến lược này chủ yếu hoạt động cho các thị trường giới hạn trong phạm vi, nắm bắt sự đảo ngược trung hạn để có lợi nhuận tương đối ổn định. Nó giúp xác định các mức giá ngắn hạn và tạo ra các tín hiệu giao dịch dựa trên nhiều chỉ số. Với tối ưu hóa và quản lý rủi ro thích hợp, những lợi thế của nó có thể được sử dụng hiệu quả.


/*backtest
start: 2023-11-12 00:00:00
end: 2023-12-02 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/
// © MagicStrategies

//@version=5
strategy("Reversal Indicator Strategy", overlay = true)

// Input settings
ccimomCross = input.string('CCI', 'Entry Signal Source', options=['CCI', 'Momentum'], tooltip='CCI or Momentum will be the final source of the Entry signal if selected.')
ccimomLength = input.int(10, minval=1, title='CCI/Momentum Length')
useDivergence = input.bool(true, title='Find Regular Bullish/Bearish Divergence', tooltip='If checked, it will only consider an overbought or oversold condition that has a regular bullish or bearish divergence formed inside that level.')
rsiOverbought = input.int(65, minval=1, title='RSI Overbought Level', tooltip='Adjusting the level to extremely high may filter out some signals especially when the option to find divergence is checked.')
rsiOversold = input.int(35, minval=1, title='RSI Oversold Level', tooltip='Adjusting this level extremely low may filter out some signals especially when the option to find divergence is checked.')
rsiLength = input.int(14, minval=1, title='RSI Length')
plotMeanReversion = input.bool(false, 'Plot Mean Reversion Bands on the chart', tooltip='This function doesn\'t affect the entry of signal but it suggests buying when the price is at the lower band, and then sell it on the next bounce at the higher bands.')
emaPeriod = input(200, title='Lookback Period (EMA)')
bandMultiplier = input.float(1.8, title='Outer Bands Multiplier', tooltip='Multiplier for both upper and lower bands')


// CCI and Momentum calculation
momLength = ccimomCross == 'Momentum' ? ccimomLength : 10
mom = close - close[momLength]
cci = ta.cci(close, ccimomLength)
ccimomCrossUp = ccimomCross == 'Momentum' ? ta.cross(mom, 0) : ta.cross(cci, 0)
ccimomCrossDown = ccimomCross == 'Momentum' ? ta.cross(0, mom) : ta.cross(0, cci)

// RSI calculation
src = close
up = ta.rma(math.max(ta.change(src), 0), rsiLength)
down = ta.rma(-math.min(ta.change(src), 0), rsiLength)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
oversoldAgo = rsi[0] <= rsiOversold or rsi[1] <= rsiOversold or rsi[2] <= rsiOversold or rsi[3] <= rsiOversold
overboughtAgo = rsi[0] >= rsiOverbought or rsi[1] >= rsiOverbought or rsi[2] >= rsiOverbought or rsi[3] >= rsiOverbought

// Regular Divergence Conditions
bullishDivergenceCondition = rsi[0] > rsi[1] and rsi[1] < rsi[2]
bearishDivergenceCondition = rsi[0] < rsi[1] and rsi[1] > rsi[2]

// Entry Conditions
longEntryCondition = ccimomCrossUp and oversoldAgo and (not useDivergence or bullishDivergenceCondition)
shortEntryCondition = ccimomCrossDown and overboughtAgo and (not useDivergence or bearishDivergenceCondition)


// Mean Reversion Indicator
meanReversion = plotMeanReversion ? ta.ema(close, emaPeriod) : na
stdDev = plotMeanReversion ? ta.stdev(close, emaPeriod) : na
upperBand = plotMeanReversion ? meanReversion + stdDev * bandMultiplier : na
lowerBand = plotMeanReversion ? meanReversion - stdDev * bandMultiplier : na


// Plotting
plotshape(longEntryCondition, title='BUY', style=shape.triangleup, text='B', location=location.belowbar, color=color.new(color.lime, 0), textcolor=color.new(color.white, 0), size=size.tiny)
plotshape(shortEntryCondition, title='SELL', style=shape.triangledown, text='S', location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.tiny)

plot(upperBand, title='Upper Band', color=color.new(color.fuchsia, 0), linewidth=1)
plot(meanReversion, title='Mean', color=color.new(color.gray, 0), linewidth=1)
plot(lowerBand, title='Lower Band', color=color.new(color.blue, 0), linewidth=1)

// Entry signal alerts
alertcondition(longEntryCondition, title='BUY Signal', message='Buy Entry Signal')
alertcondition(shortEntryCondition, title='SELL Signal', message='Sell Entry Signal')
alertcondition(longEntryCondition or shortEntryCondition, title='BUY or SELL Signal', message='Entry Signal')

ema100 = ta.ema(close, 100)
plot(ema100, color=color.red)

// Define trading signals based on the original indicator's entry conditions
// Buy if long condition is met and price has pulled back to or below the 100 EMA
longCondition  = longEntryCondition and close <= ema100
// Sell if short condition is met and price has pulled back to or above the 100 EMA
shortCondition = shortEntryCondition and close >= ema100

// Strategy Entries
if longCondition
    strategy.entry("Buy", strategy.long)
if shortCondition
    strategy.entry("Sell", strategy.short)

Thêm nữa