
Chiến lược này sử dụng vùng cung ứng và nhu cầu, chỉ số di chuyển trung bình ((EMA) và phạm vi biến động thực trung bình ((ATR) để đánh giá tín hiệu giao dịch. Người dùng có thể điều chỉnh cài đặt tham số EMA và khả năng hiển thị của tín hiệu mua bán. Các vùng cung cấp có dấu hiệu cao hơn cao hơn ((HH), thấp hơn thấp hơn (LL), thấp hơn cao hơn (LH) và cao hơn thấp hơn (HL).
Chỉ số chuyển động trung bình EMA:
Tỷ lệ biến động thực tế trung bình của ATR:
Các tính toán này được sử dụng để xác định định xu hướng EMA và thiết lập ATR di động dừng lỗ dựa trên biến động thị trường. Chiến lược này nhằm cung cấp tín hiệu mua và bán dựa trên mối quan hệ giữa giá đóng cửa, EMA và giá trị ATR.
Chiến lược sử dụng các thuật ngữ như HH ((cao hơn cao hơn), LL ((thấp hơn thấp hơn), HL ((cao hơn thấp hơn) và LH ((thấp hơn cao hơn) để xác định các mô hình hành vi giá khác nhau, thường được sử dụng để phân tích xu hướng:
Cao hơn cao hơnGiá cao nhất hiện tại cao hơn mức cao nhất trước đó, cho thấy động lực tăng tiềm năng.
Thêm thấp hơn (LL)Giá thấp hiện tại thấp hơn mức thấp trước đó, cho thấy động lực giảm tiềm năng.
Cao hơn, thấp hơnGiá thấp hiện tại cao hơn mức thấp trước đó, cho thấy xu hướng tăng tiềm năng tiếp tục.
Thêm thấp hơn, cao hơnGiá cao nhất hiện tại thấp hơn mức cao nhất trước đó, cho thấy xu hướng giảm tiềm năng tiếp tục.
Các mô hình này được sử dụng kết hợp với các chỉ số kỹ thuật khác để xác định sự đảo ngược hoặc tiếp tục của xu hướng tiềm năng. Chiến lược sử dụng các mô hình này để xác định thời gian nhập hoặc thoát.
Kích hiệu vào cửa: K-line thứ ba sẽ tạo ra tín hiệu mua/bán khi giá đóng cửa cao hơn/thấp hơn giá cao nhất/thấp nhất ngày trước.
Phương pháp dừng lỗ: sử dụng một số lần số ATR (đặc biệt là 2 lần) làm điểm dừng lùi.
Chiến lược sử dụng tổng hợp nhiều chỉ số kỹ thuật và định hình giá, chẳng hạn như xu hướng, đảo ngược, biến động, trong phản hồi. Tuy nhiên, sự thay đổi phức tạp, tối ưu hóa và lọc đúng các tín hiệu vào thị trường vẫn cần thiết. Chiến lược này là chiến lược cơ bản, có thể mở rộng dựa trên nó, kết hợp với các yếu tố hoặc mô hình khác.
/*backtest
start: 2023-12-18 00:00:00
end: 2024-01-17 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Supply and Demand Zones with EMA and Trailing Stop", shorttitle="SD Zones", overlay=true)
showBuySignals = input(true, title="Show Buy Signals", group="Signals")
showSellSignals = input(true, title="Show Sell Signals", group="Signals")
showHLZone = input(true, title="Show HL Zone", group="Zones")
showLHZone = input(true, title="Show LH Zone", group="Zones")
showHHZone = input(true, title="Show HH Zone", group="Zones")
showLLZone = input(true, title="Show LL Zone", group="Zones")
emaLength = input(200, title="EMA Length", group="EMA Settings")
atrLength = input(14, title="ATR Length", group="Trailing Stop")
atrMultiplier = input(2, title="ATR Multiplier", group="Trailing Stop")
// Function to identify supply and demand zones
getZones(src, len, mult) =>
base = request.security(syminfo.tickerid, "D", close)
upper = request.security(syminfo.tickerid, "D", high)
lower = request.security(syminfo.tickerid, "D", low)
multiplier = request.security(syminfo.tickerid, "D", mult)
zonetype = base + multiplier * len
zone = src >= zonetype
[zone, upper, lower]
// Identify supply and demand zones
[supplyZone, _, _] = getZones(close, high[1] - low[1], 1)
[demandZone, _, _] = getZones(close, high[1] - low[1], -1)
// Plot supply and demand zones
bgcolor(supplyZone ? color.new(color.red, 80) : na)
bgcolor(demandZone ? color.new(color.green, 80) : na)
// EMA with Linear Weighted method
ema = ta.ema(close, emaLength)
// Color code EMA based on its relation to candles
emaColor = close > ema ? color.new(color.green, 0) : close < ema ? color.new(color.red, 0) : color.new(color.yellow, 0)
// Plot EMA
plot(ema, color=emaColor, title="EMA")
// Entry Signal Conditions after the third candle
longCondition = ta.crossover(close, high[1]) and bar_index >= 2
shortCondition = ta.crossunder(close, low[1]) and bar_index >= 2
// Trailing Stop using ATR
atrValue = ta.atr(atrLength)
trailStop = close - atrMultiplier * atrValue
// Strategy Entry and Exit
if (longCondition)
strategy.entry("Buy", strategy.long)
strategy.exit("TrailStop", from_entry="Buy", loss=trailStop)
if (shortCondition)
strategy.entry("Sell", strategy.short)
strategy.exit("TrailStop", from_entry="Sell", loss=trailStop)
// Plot Entry Signals
plotshape(series=showBuySignals ? longCondition : na, title="Buy Signal", color=color.new(color.green, 0), style=shape.triangleup, location=location.belowbar)
plotshape(series=showSellSignals ? shortCondition : na, title="Sell Signal", color=color.new(color.red, 0), style=shape.triangledown, location=location.abovebar)
// Plot Trailing Stop
plot(trailStop, color=color.new(color.red, 0), title="Trailing Stop")
// Plot HH, LL, LH, and HL zones
plotshape(series=showHHZone and ta.highest(high, 2)[1] and ta.highest(high, 2)[2] ? 1 : na, title="HH Zone", color=color.new(color.blue, 80), style=shape.triangleup, location=location.abovebar)
plotshape(series=showLLZone and ta.lowest(low, 2)[1] and ta.lowest(low, 2)[2] ? 1 : na, title="LL Zone", color=color.new(color.blue, 80), style=shape.triangledown, location=location.belowbar)
plotshape(series=showLHZone and ta.highest(high, 2)[1] and ta.lowest(low, 2)[2] ? 1 : na, title="LH Zone", color=color.new(color.orange, 80), style=shape.triangleup, location=location.abovebar)
plotshape(series=showHLZone and ta.lowest(low, 2)[1] and ta.highest(high, 2)[2] ? 1 : na, title="HL Zone", color=color.new(color.orange, 80), style=shape.triangledown, location=location.belowbar)