Signal 4 — Delta Divergence
| Thuộc tính | Giá trị |
|---|---|
| Phân loại | Order Flow |
| Khung thời gian | 15–60 phút |
| Paper gốc | Hasbrouck (1991); biến thể từ Volume Profile literature |
| Loại dữ liệu | Tick với side classification |
| Hướng giao dịch | Mean Reversion / Reversal |
| Capacity | Trung bình |
Logic. Delta = cumulative buy_volume − sell_volume. Bearish divergence: giá tạo higher-high nhưng delta tạo lower-high → áp lực mua suy yếu → SELL. Bullish divergence: giá lower-low nhưng delta higher-low → BUY. Confirm bằng RSI(14) ở vùng cực đoan.
Code Python.
python
def detect_divergence(price, delta, lookback=20):
"""Return: +1 bullish, -1 bearish, 0 none."""
p_hh = price.iloc[-1] > price.iloc[-lookback:-1].max()
p_ll = price.iloc[-1] < price.iloc[-lookback:-1].min()
d_lh = delta.iloc[-1] < delta.iloc[-lookback:-1].max()
d_hl = delta.iloc[-1] > delta.iloc[-lookback:-1].min()
if p_hh and d_lh:
return -1
if p_ll and d_hl:
return 1
return 0QuantConnect setup. Maintain cumulative delta trong OnData bằng cách phân loại từng trade với Lee-Ready hoặc tick rule. Reset delta mỗi đầu phiên. Lưu rolling buffer 60 thanh nến 5 phút để detect swing high/low.