
Chiến lược này là một hệ thống giao dịch dựa trên động thái giá và khối lượng giao dịch, tập trung vào việc xác định các cơ hội điều chỉnh nhỏ sau khi tăng mạnh. Chiến lược này hoạt động bằng cách theo dõi các điều chỉnh ngắn hạn sau khi đường xanh tăng mạnh, và tham gia giao dịch khi có tín hiệu đảo ngược giá. Hệ thống sử dụng nhiều điều kiện lọc, bao gồm khối lượng giao dịch, tỷ lệ biến động ATR và giới hạn mức độ điều chỉnh để tăng độ chính xác của giao dịch.
Lập luận cốt lõi của chiến lược dựa trên nguyên tắc tiếp tục động lực thị trường, bao gồm các yếu tố quan trọng sau:
Đây là một chiến lược theo dõi xu hướng được thiết kế hợp lý, có thể nắm bắt cơ hội giao dịch chất lượng trong thị trường thông qua lọc điều kiện nghiêm ngặt và quản lý rủi ro. Chìa khóa thành công của chiến lược là tối ưu hóa các tham số và điều chỉnh thích ứng với môi trường thị trường.
/*backtest
start: 2024-02-19 00:00:00
end: 2025-02-17 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"BNB_USDT"}]
*/
//@version=6
strategy(title="Micropullback Detector w/ Stop Buy & Exits", shorttitle="MicroPB Det+Exits", overlay=true)
// USER INPUTS
volLookback = input.int(20, "Volume SMA Period", minval=1)
volMultiplier = input.float(1.5, "Volume Multiplier for High Volume", minval=1.0)
largeCandleATR = input.float(0.5, "Fraction of ATR to define 'Large Candle'", minval=0.1)
maxRedPullback = input.int(3, "Max Consecutive Red Candles in Pullback")
maxRetracementPc = input.float(50, "Max Retracement % for pullback", minval=1.0, maxval=100.0)
// CALCULATIONS
fastAtr = ta.atr(14)
avgVolume = ta.sma(volume, volLookback)
isLargeGreenCandle = (close > open) and ((close - open) > fastAtr * largeCandleATR) and (volume > avgVolume * volMultiplier) and (volume > 200000)
// HELPER FLAGS
isGreen = close >= open
isRed = close < open
// STATE VARIABLES
var int state = 0
var float waveStartPrice = na
var float waveHighestPrice = na
var float largestGreenVol = na
var int consecutiveRedPulls = 0
var bool triggerSignal = false
var float wavePullbackLow = na
if barstate.isnew
triggerSignal:=false
if state==0
wavePullbackLow:=na
if isLargeGreenCandle
state:=1
waveStartPrice:=open
waveHighestPrice:=high
largestGreenVol:=volume
consecutiveRedPulls:=0
else if state==1
if isGreen
waveHighestPrice:=math.max(waveHighestPrice,high)
if volume>largestGreenVol
largestGreenVol:=volume
else
state:=2
consecutiveRedPulls:=1
wavePullbackLow:=low
else if state==2
if isRed
if volume>largestGreenVol
state:=0
consecutiveRedPulls+=1
if consecutiveRedPulls>=maxRedPullback+1
state:=0
retracementLevel=waveStartPrice+(maxRetracementPc/100.0)*(waveHighestPrice-waveStartPrice)
wavePullbackLow:=math.min(wavePullbackLow,low)
if close<retracementLevel
state:=0
else
consecutiveRedPulls:=0
if high>high[1]
triggerSignal:=true
state:=3
else if state==3
state:=0
// Plot shapes for signals (last 1440 bars ~ 1 day at 1-min TF)
plotshape(isLargeGreenCandle, title="Large Green Candle", style=shape.diamond, location=location.belowbar, color=color.new(color.blue, 0), offset=0, size=size.small, show_last=1440)
plotshape(triggerSignal, title="MicroPB Entry", style=shape.arrowdown, location=location.abovebar, color=color.new(color.green, 0), offset=0, size=size.large, show_last=1440)
// ENTRY & EXITS
if triggerSignal
// Stop Buy above the previous bar's high
entryPrice = high[1]
strategy.order("MicroPullback Long", strategy.long, limit=entryPrice, oca_name="MicroPullback")
// Stoploss slightly below pullback low
stopPrice = wavePullbackLow - 2*syminfo.mintick
// Risk & take-profit calculations
risk = entryPrice - stopPrice
tpPrice = entryPrice + 2 * risk
// Exit: stop or TP
strategy.exit("SL+TP", "MicroPullback Long", stop=stopPrice, limit=tpPrice, qty_percent=100)
// ALERT
alertcondition(triggerSignal, title="MicroPullback LONG", message="Micropullback Long Signal Detected!")