Chiến lược giao dịch động lượng hệ thống Dual Track


Ngày tạo: 2023-11-22 15:26:28 sửa đổi lần cuối: 2023-11-22 15:26:28
sao chép: 0 Số nhấp chuột: 623
1
tập trung vào
1617
Người theo dõi

Chiến lược giao dịch động lượng hệ thống Dual Track

[trans]

Tổng quan

Chiến lược này sử dụng hai chỉ số MACD và Stoch RSI để kết hợp, xây dựng hệ thống giao dịch hai chiều, để có thể theo dõi xu hướng và đánh giá mua quá mức. Chiến lược xây dựng chỉ số trên đường mặt trời và đường 4 giờ đồng thời, để có thể đánh giá nhiều khung thời gian, giảm khả năng đánh giá sai.

Nguyên tắc chiến lược

Cấu trúc chiến lược sử dụng hai loại chỉ số kỹ thuật khác nhau là MACD và Stoch RSI để cấu hình. MACD là chỉ số chênh lệch, đánh giá tốc độ thay đổi giá; Stoch RSI là chỉ số quá mua quá bán, đánh giá giá tương đối mạnh.

Chiến lược đầu tiên là xây dựng các chỉ số MACD và Stoch RSI trên đường ngày và đường 4 giờ để phán đoán xu hướng và mua quá bán. Khi các chỉ số của hai chu kỳ thời gian phát ra tín hiệu mua / bán cùng một lúc, hãy thực hiện các hoạt động mua / bán tương ứng.

Cụ thể, việc xây dựng chỉ số MACD, đường DIF và đường DEA tạo thành các ngã ba vàng; xây dựng chỉ số Stoch RSI, đường K và đường D tạo thành ngã ba vàng. Khi hai nhóm chỉ số tạo ra tín hiệu mua khi đồng thời ngã ba vàng và đồng thời ngã ba vàng tạo ra tín hiệu bán.

Do đó, sử dụng các chỉ số hai đường và nhiều khung thời gian để đánh giá toàn diện về tốc độ thay đổi giá và sức mạnh tương đối của chiến lược, giúp tăng độ chính xác của quyết định và thu được lợi nhuận tốt hơn.

Phân tích lợi thế

Chiến lược này có một số ưu điểm:

  1. Kết hợp các chỉ số hai chiều để đưa ra phán đoán toàn diện và cải thiện tính chính xác của quyết định
  2. Sử dụng nhiều khung thời gian để giảm khả năng sai lầm
  3. Sử dụng theo dõi xu hướng và đánh giá quá mua quá bán, cân nhắc tổng hợp tốc độ thay đổi giá và tương đối mạnh
  4. Các tham số chỉ số có thể điều chỉnh để phù hợp với các giống và môi trường thị trường khác nhau
  5. Có cấu trúc mã rõ ràng, dễ hiểu và mở rộng

Phân tích rủi ro

Chiến lược này cũng có một số rủi ro:

  1. Rủi ro hệ thống trên thị trường không thể tránh được hoàn toàn
  2. Cài đặt tham số chỉ số không đúng có thể dẫn đến giao dịch thường xuyên hoặc bỏ lỡ cơ hội tốt
  3. Tỷ lệ đồng thời phát tín hiệu sai của chỉ số hai đường ray tồn tại, nhưng thấp hơn chỉ số đơn
  4. Không thể đối phó với sự thay đổi đột ngột của thị trường, như sự kiện Black Swan lớn

Phản ứng:

  1. Tối ưu hóa các tham số, điều chỉnh các điều kiện giao dịch mua bán, giảm sai lầm
  2. Kết hợp với nhiều chỉ số hơn để tăng cơ sở phán đoán
  3. Tăng chiến lược dừng lỗ, kiểm soát rủi ro lỗ đơn

Hướng tối ưu hóa

Chính sách này cũng có thể được tối ưu hóa theo các khía cạnh sau:

  1. Thêm nhiều chỉ số để kết hợp, xây dựng chiến lược đa chỉ số
  2. Thêm các thuật toán học máy để tối ưu hóa tham số động
  3. Thêm một số yếu tố khác để đánh giá thị trường, bao gồm các chỉ số cảm xúc và tin tức.
  4. Tăng các chiến lược dừng lỗ, ngăn chặn, quản lý tài chính tối ưu
  5. Mở rộng phạm vi giao dịch, tìm kiếm cơ hội tốt hơn

Tóm tắt

Chiến lược này sử dụng sự kết hợp của chỉ số hai đường và đánh giá nhiều khung thời gian, đánh giá toàn diện về tốc độ thay đổi giá cả và sức mạnh tương đối, có thể thu được xu hướng thị trường hiệu quả, cải thiện các lỗ hổng đánh giá sai của chỉ số đơn lẻ. Ngoài ra, nó cũng có các ưu điểm như điều chỉnh tham số linh hoạt, dễ hiểu và mở rộng.

||

Overview

This strategy combines the MACD and Stoch RSI indicators to build a dual-rail trading system for trend tracking and oversold/overbought judgment. The strategy also builds indicators on the daily and 4-hour timeframes to make multi-timeframe judgments to reduce misjudgment probability.

Strategy Principle

The strategy combines the MACD and Stoch RSI indicators, which are different types of technical indicators, for configuration. MACD is a momentum indicator that judges price change velocity; Stoch RSI is an overbought/oversold indicator that judges relative price strength.

The strategy first constructs the MACD and Stoch RSI indicators on the daily and 4-hour timeframes respectively for trend and overbought/oversold judgments. When signals are triggered on both timeframes, corresponding buy/sell operations are performed.

Specifically, the MACD indicator is constructed with the DIF and DEA lines forming golden/dead crosses for judgment; the Stoch RSI indicator is constructed with the K and D lines forming golden/dead crosses for judgment. When both indicator pairs have golden crosses, buy signals are generated; when both have dead crosses, sell signals are generated.

Thus, by comprehensively applying the dual-indicator system and multi-timeframe judgments, the strategy judges price velocity and relative strength thoroughly, which helps improve decision accuracy and gain better returns.

Advantage Analysis

This strategy has the following advantages:

  1. Combining dual-indicator system for comprehensive judgment and higher decision accuracy
  2. Applying multi-timeframe to reduce misjudgment probability
  3. Adopting trend tracking and overbought/oversold judgment for consideration of both price velocity and relative strength
  4. Flexible indicator parameters adjustable for different products and market environments
  5. Clean code structure easy to understand and expand

Risk Analysis

There are also some risks with this strategy:

  1. There exist systemic market risks that cannot be fully avoided
  2. Inappropriate indicator parameter settings may lead to overtrading or missing opportunities
  3. Dual indicators may still give concurrent wrong signals, but less likely than single ones
  4. Unable to cope with drastic market changes like black swan events

Countermeasures:

  1. Optimize parameters and adjust trading conditions to reduce misjudgments
  2. Incorporate more indicators for combined judgments
  3. Add stop loss mechanisms to control single loss risk

Optimization Directions

This strategy can also be improved in the following aspects:

  1. Incorporate more indicators for multi-indicator strategies
  2. Add machine learning algorithms for dynamic parameter optimization
  3. Combine sentiment indicators, news etc. for more comprehensive market condition judgments
  4. Add stop loss, take profit strategies to optimize money management
  5. Expand to more trading products to discover better opportunities

Conclusion

By combined application of the dual-indicator system and multi-timeframe judgments, this strategy judges price velocity and relative strength thoroughly, which can effectively capture market trends and improve deficiencies of single indicators. It also has advantages like flexible parameter tuning, easy understanding and expansion. Further expansions by multi-indicator combination, dynamic parameter optimization, sentiment indicator incorporation etc. can help boost strategy performance. [trans]

Mã nguồn chiến lược
/*backtest
start: 2023-11-14 00:00:00
end: 2023-11-15 10:00:00
period: 3m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy(title='[RS]Khizon (UWTI) Strategy V0', shorttitle='K', overlay=false, pyramiding=0, initial_capital=100000, currency=currency.USD)
//  ||  Inputs:
macd_src = input(title='MACD Source:',  defval=close)
macd_fast = input(title='MACD Fast Length:',  defval=12)
macd_slow = input(title='MACD Slow Length:',  defval=26)
macd_signal_smooth = input(title='MACD Signal Smoothing:',  defval=9)
srsi_src = input(title='SRSI Source:',  defval=close)
srsi_rsi_length = input(title='SRSI RSI Length:',  defval=14)
srsi_stoch_length = input(title='SRSI Stoch Length:',  defval=14)
srsi_smooth = input(title='SRSI Smoothing:',  defval=3)
srsi_signal_smooth = input(title='SRSI Signal Smoothing:',  defval=3)
//  ||  Strategy Inputs:
trade_size = input(title='Trade Size in USD:', type=float, defval=1)
buy_trade = input(title='Perform buy trading?', type=bool, defval=true)
sel_trade = input(title='Perform sell trading?', type=bool, defval=true)
//  ||  MACD(close, 12, 26, 9):     ||---------------------------------------------||
f_macd_trigger(_src, _fast, _slow, _signal_smooth)=>
    _macd = ema(_src, _fast) - ema(_src, _slow)
    _signal = sma(_macd, _signal_smooth)
    _return_trigger = _macd >= _signal ? true : false
//  ||  Stoch RSI(close, 14, 14, 3, 3)  ||-----------------------------------------||
f_srsi_trigger(_src, _rsi_length, _stoch_length, _smooth, _signal_smooth)=>
    _rsi = rsi(_src, _rsi_length)
    _stoch = sma(stoch(_rsi, _rsi, _rsi, _stoch_length), _smooth)
    _signal = sma(_stoch, _signal_smooth)
    _return_trigger = _stoch >= _signal ? true : false
//  ||-----------------------------------------------------------------------------||
//  ||-----------------------------------------------------------------------------||
//  ||  Check Directional Bias from daily timeframe:
daily_trigger = security('USOIL', 'D', f_macd_trigger(macd_src, macd_fast, macd_slow, macd_signal_smooth) and f_srsi_trigger(srsi_src, srsi_rsi_length, srsi_stoch_length, srsi_smooth, srsi_signal_smooth))
h4_trigger = security('USOIL', '240', f_macd_trigger(macd_src, macd_fast, macd_slow, macd_signal_smooth) and f_srsi_trigger(srsi_src, srsi_rsi_length, srsi_stoch_length, srsi_smooth, srsi_signal_smooth))

plot(title='D1T', series=daily_trigger?0:na, style=circles, color=blue, linewidth=4, transp=65)
plot(title='H4T', series=h4_trigger?0:na, style=circles, color=navy, linewidth=2, transp=0)

sel_open = sel_trade and not daily_trigger and not h4_trigger
buy_open = buy_trade and daily_trigger and h4_trigger
sel_close = not buy_trade and daily_trigger and h4_trigger
buy_close = not sel_trade and not daily_trigger and not h4_trigger
strategy.entry('sel', long=false, qty=trade_size, comment='sel', when=sel_open)
strategy.close('sel', when=sel_close)
strategy.entry('buy', long=true, qty=trade_size, comment='buy', when=buy_open)
strategy.close('buy', when=buy_close)