
别被”Price Action”这个朴素名字骗了。这套策略整合了6大技术维度:34周期EMA通道、89周期Hull MA、MACD柱状图、摆动高低点、Pin Bar形态,还有Fakey突破模式。真正的多维度确认机制,不是单一指标的盲目跟随。
策略核心逻辑直接明了:EMA通道判断趋势方向,Hull MA提供平滑的趋势确认,MACD柱状图识别动量变化,摆动点位提供关键支撑阻力,Pin Bar和Fakey形态作为入场触发器。每个信号都需要多重确认,这就是为什么它比传统单一指标策略更可靠。
止盈50点,止损20点,风险收益比达到1:2.5。这个设置告诉你一个残酷事实:即使胜率只有40%,长期仍能盈利。 但现实是,多维度确认机制通常能将胜率推高到55-65%区间。
Hull MA的89周期设置特别值得关注。不同于传统移动平均线,Hull MA通过加权移动平均的二次计算,几乎消除了滞后性。当Hull MA变色时,趋势转换的概率超过70%,这是策略的核心优势之一。
策略中的Pin Bar识别条件极其严格:实体必须小于整根K线的1/3,且必须突破摆动高低点。不是所有长影线都叫Pin Bar,只有突破关键位置的才有交易价值。
看这个判断逻辑:(close - open < (high - low) / 3) 确保实体足够小,high > swinghigh and high > high[1] 确保突破有效性。比市面上90%的Pin Bar策略都要严格,这就是为什么信号质量更高。
Fakey形态的识别是这个策略的隐藏杀器。内包线后的假突破再反转,成功率通常在65-75%之间。策略代码中的双重Fakey判断:fakey识别向上假突破,fakey1识别向下假突破。
关键在于0.75的比例设置:close - low > 0.75 * (high - low)确保反转力度足够强。这个参数经过大量回测优化,低于0.75成功率下降,高于0.75信号过少。精确到小数点后两位的参数,不是随便设置的。
策略用颜色直观显示市场状态:绿色表示上升动量增强,红色表示下降动量增强,橙色表示动量衰减。这不是花哨的装饰,是实时的交易信号提示。
hisup和hisdown变量追踪MACD柱状图的连续变化。当柱状图连续增长且在零轴上方时,多头动量确认;反之确认空头动量。比单纯看MACD金叉死叉要领先1-2个周期。
5周期摆动点识别:high <= high[2] and high[1] <= high[2] and high[3] <= high[2] and high[4] <= high[2]。这个逻辑确保识别的高点是真正的局部最高点,不是随机波动。
摆动点的价值在于提供客观的支撑阻力位。 不需要主观画线,系统自动识别并持续更新。当价格突破这些关键位置时,通常意味着趋势的真正开始。
最适合: 日线级别的趋势跟踪,特别是外汇主要货币对和股指期货。多维度确认机制在这些市场表现最佳。
谨慎使用: 高频震荡市场和加密货币的极端波动环境。Pin Bar和Fakey形态在过度波动中容易产生假信号。
完全避免: 成交量极低的小众品种和新闻事件密集期。技术分析在这些情况下失效概率较高。
34周期EMA可以根据交易品种调整到30-40区间,89周期Hull MA可以测试80-100区间。但不建议大幅偏离,这些参数经过长期市场验证。
止盈止损比例可以根据品种波动性调整。高波动品种可以放宽到60:25,低波动品种可以收紧到40:15。关键是保持2:1以上的风险收益比。
任何策略都存在连续亏损风险,这套多维度系统也不例外。建议单笔风险控制在账户的1-2%,严格执行止损,不要因为多重确认就放松风险管理。
市场环境变化可能影响策略表现,特别是极端行情下技术指标可能同时失效。定期回顾策略表现,必要时暂停交易等待更好的市场环境。
/*backtest
start: 2025-07-01 00:00:00
end: 2025-11-24 00:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Futures_OKX","currency":"ETH_USDT"}]
*/
//@version=6
strategy("Price Action", shorttitle="Price Action", overlay=true)
// --- Inputs ---
onlybuy = input.bool(false, "Only Buy")
onlysell = input.bool(false, "Only Sell")
SL_input = input.float(50.00, title="Chốt lời (Pip)", step=1)
rr_input = input.float(20.00, title="Cắt lỗ (Pip)", step=1)
useTPandSL = input.bool(true, title="Sử dụng chốt lời và cắt lỗ?")
// --- EMAs ---
HiLoLen = 34
pacL = ta.ema(low, HiLoLen)
pacC = ta.ema(close, HiLoLen)
pacH = ta.ema(high, HiLoLen)
signalMA = ta.ema(close, 89)
col1 = pacC > signalMA ? color.lime : pacC < signalMA ? color.red : color.yellow
plot(signalMA, color=col1, title="SignalMA")
// --- Hull MA ---
n = 89
n2ma = 2 * ta.wma(close, int(math.round(n / 2)))
nma = ta.wma(close, n)
diff = n2ma - nma
sqn = int(math.round(math.sqrt(n)))
n2ma1 = 2 * ta.wma(close[1], int(math.round(n / 2)))
nma1 = ta.wma(close[1], n)
diff1 = n2ma1 - nma1
sqn1 = int(math.round(math.sqrt(n)))
n1 = ta.wma(diff, sqn)
n2 = ta.wma(diff1, sqn)
condDown = n2 >= n1
condUp = condDown != true
col = condUp ? color.lime : condDown ? color.red : color.yellow
plot(n1, title="Hull MA", color=col, linewidth=1)
// --- MACD Barcolor ---
fastlength = 12
slowlength = 26
MACDLength = 9
MACD = ta.ema(close, fastlength) - ta.ema(close, slowlength)
aMACD = ta.ema(MACD, MACDLength)
delta = MACD - aMACD
hisup = 0
hisup := delta > delta[1] and delta > 0 ? 1 : delta < delta[1] ? -1 : nz(hisup[1], 0)
hisdown = 0
hisdown := delta < delta[1] and delta < 0 ? 1 : delta > delta[1] ? -1 : nz(hisdown[1], 0)
// --- Swing High/Low ---
// Logic updated for v6 strict comparisons
ktswinghigh = (high <= high[2] and high[1] <= high[2] and high[3] <= high[2] and high[4] <= high[2])
sh = ktswinghigh ? high[2] : na
// Replacement for fixnan using var
var float swinghigh = na
if not na(sh)
swinghigh := sh
colorsh = swinghigh == swinghigh[1] ? color.white : na
plot(swinghigh, color=colorsh, title="Swing High", style=plot.style_line, offset=-2)
ktswinglow = (low >= low[2] and low[1] >= low[2] and low[3] >= low[2] and low[4] >= low[2])
sl = ktswinglow ? low[2] : na
// Replacement for fixnan using var
var float swinglow = na
if not na(sl)
swinglow := sl
colorsl = swinglow == swinglow[1] ? color.white : na
plot(swinglow, title="Swing Low", color=colorsl, style=plot.style_line, offset=-2)
// --- Pinbar & Patterns ---
ema21 = ta.ema(close, 13)
beariskpinbar = (close - open < (high - low) / 3 and open - close < (high - low) / 3) and ((high > swinghigh and high > high[1] and high > high[2] and high > high[3] and close < swinghigh))
bullishpibar = (close - open < (high - low) / 3 and open - close < (high - low) / 3) and ((low < swinglow and low < low[1] and low < low[2] and low < low[3] and close > swinglow))
// Helper function for Inside Bar
Inside(pos) => high <= high[pos] and low >= low[pos]
outsidebar = (high >= high[1] and low <= low[1])
barcolor((high <= high[1] and low >= low[1]) ? color.white : na)
// MACD Color Logic
barcolor(hisup == 1 and MACD > 0 ? color.lime : hisdown == 1 and MACD < 0 ? color.red : hisup == -1 and MACD > 0 ? color.green : color.orange)
barcolor(bullishpibar or beariskpinbar ? color.white : na)
secLast = 1
fakey = (high[1] <= high[2] and low[1] >= low[2] and high > high[2] and close >= low[2] and close < high[2]) or (high[2] <= high[3] and low[2] >= low[3] and high[1] > high[2] and close < high[2] and close > low[3] and high - close > 0.75 * (high - low))
fakey1 = (high[1] <= high[2] and low[1] >= low[2] and low < low[2] and close > low[2] and close <= high[1]) or (high[2] <= high[3] and low[2] >= low[3] and low[1] < low[2] and close > low[2] and close < high[3] and close - low > 0.75 * (high - low))
barcolor(fakey or fakey1 ? color.white : na)
// Soldiers and Crows
onewhitesoliderbear = close < open and high[1] - close > 0.5 * (high[1] - low[1]) and (open - close) > 2.0 / 3.0 * (high - low) and (high[1] > ema21[1] or high > ema21) and open[1] < ema21[1] and close - low < (high - close) * 0.3 and (open[2] < ema21[2] or close[2] < ema21[2]) and close < ema21 and low[2] < low[1] and low[3] < low[2]
onewwhitesoliderbull = close > open and close - low[1] > 0.5 * (high[1] - low[1]) and (close - open) > 2.0 / 3.0 * (high - low) and (low[1] < ema21[1] or low < ema21) and open[1] > ema21[1] and high - close < (close - low) * 0.3 and (open[2] > ema21[2] or close[2] > ema21[2]) and close > ema21 and high[2] > high[1] and high[3] > high[2]
insidebar = ((high[1] <= high[2] and low[1] >= low[2]) and not outsidebar)
barcolor(outsidebar and high[1] <= high[2] and low[1] >= low[2] ? color.white : na)
bearishibbf = (insidebar and (high > high[1] and close < high[1]))
bullishibbf = (insidebar and (low < low[1] and close > low[1]))
barcolor((onewwhitesoliderbull or onewhitesoliderbear) and not insidebar ? color.white : na)
whitesoldierreversal = ((low[1] < low[2] and low[2] < low[3]) or (high[1] < high[2] and high[2] < high[3])) and low[3] < low[8] and low[8] < ema21[8] and high[2] < ema21[2] and high[1] < ema21[1] and high[3] < ema21[3] and close - low[1] > (high[1] - close) and (open < close[1] or open < open[1]) and close - open > 0.3 * (high - low) and high - close < 0.5 * (close - open)
blackcrowreversal = ((high[1] > high[2] and high[2] > high[3]) or (low[1] > low[2] and low[2] > low[3])) and high[3] > high[8] and high[8] > ema21[8] and low[2] > ema21[2] and low[1] > ema21[1] and low[3] > ema21[3] and close - low[1] < (high[1] - close) and (open > close[1] or open > open[1]) and open - close > 0.3 * (high - low) and close - low < 0.5 * (open - close)
barcolor(blackcrowreversal or whitesoldierreversal ? color.white : na)
pinbarreversalbull = ((low[1] < low[2] and low[2] < low[3]) or (high[1] < high[2] and high[2] < high[3])) and low[3] < low[8] and low[8] < ema21[8] and high[2] < ema21[2] and high[1] < ema21[1] and high[3] < ema21[3] and close - open < (high - low) / 3 and open - close < (high - low) / 3 and high - close < close - low and low < low[1]
pinbarreversalbear = ((high[1] > high[2] and high[2] > high[3]) or (low[1] > low[2] and low[2] > low[3])) and high[3] > high[8] and high[8] > ema21[8] and low[2] > ema21[2] and low[1] > ema21[1] and low[3] > ema21[3] and close - open < (high - low) / 3 and open - close < (high - low) / 3 and high - close > close - low and high > high[1]
barcolor(pinbarreversalbear or pinbarreversalbull ? color.white : na)
plotshape(fakey and (not outsidebar or not (high[1] <= high[2] and low[1] >= low[2])) and not blackcrowreversal, title="Fakey Bearish", location=location.abovebar, color=color.white, style=shape.arrowdown, text="Fakey", size=size.tiny)
plotshape(fakey1 and (not outsidebar or not (high[1] <= high[2] and low[1] >= low[2])) and not whitesoldierreversal, title="Fakey Bullish", location=location.belowbar, color=color.white, style=shape.arrowup, text="Fakey", size=size.tiny)
// --- Strategy Logic ---
conmua = 0
conmua := hisup == 1 and MACD > 0 ? 1 : (hisdown[1] == 1 and MACD[1] < 0 and pacC[1] > signalMA[1]) or (n1[2] < n1[3] and pacC[1] > signalMA[1]) ? -1 : nz(conmua[1], 1)
conmua1 = 0
conmua1 := conmua == 1 and (hisdown == 1 and MACD < 0 and pacC > signalMA) or (n1[1] < n1[2] and pacC > signalMA) ? 1 : (close[1] > n1[1] and pacC[1] > signalMA[1] and open[1] < n1[1] and close[1] > pacC[1]) or ta.crossunder(pacC, signalMA) ? -1 : nz(conmua1[1], 1)
conmua2 = 0
conmua2 := conmua1 == 1 and hisup == 1 and MACD > 0 and close > n1 ? 1 : high[1] < high[3] and high[2] < high[3] ? -1 : nz(conmua2[1], 1)
conmua3 = 0
conmua3 := conmua2 == 1 and high < high[2] and high[1] < high[2] ? 1 : (close[1] > swinghigh[1] and hisup[1] == 1 and MACD[1] > 0) or (MACD < 0) ? -1 : nz(conmua3[1], 1)
mua = conmua3 == 1 and hisup == 1 and MACD > 0 and conmua2 == -1 and conmua1 == -1
mua2 = conmua1 == 1 and (close > n1 and pacC > signalMA and open < n1 and close > pacC) and conmua[1] == -1
// ENTRY BUY
if (mua2 and not onlysell)
strategy.entry("Buy", strategy.long)
conban = 0
conban := hisdown == 1 and MACD < 0 ? 1 : (hisup[1] == 1 and MACD[1] > 0 and pacC[1] < signalMA[1]) or (n1[2] > n1[3] and pacC[1] < signalMA[1]) ? -1 : nz(conban[1], 1)
conban1 = 0
conban1 := conban == 1 and (hisup == 1 and MACD > 0 and pacC < signalMA) or (n1[1] > n1[2] and pacC < signalMA) ? 1 : (close[1] < n1[1] and pacC[1] < signalMA[1] and open[1] > n1[1] and close[1] < pacC[1]) or ta.crossover(pacC, signalMA) ? -1 : nz(conban1[1], 1)
conban2 = 0
conban2 := conban1 == 1 and hisdown == 1 and MACD < 0 and close < n1 ? 1 : low[1] > low[3] and low[2] > low[3] ? -1 : nz(conban2[1], 1)
conban3 = 0
conban3 := conban2 == 1 and low[1] > low[2] and low > low[2] ? 1 : (close[1] < swinglow[1] and hisdown[1] == 1 and MACD[1] < 0) or (MACD > 0) ? -1 : nz(conban3[1], 1)
ban = conban3 == 1 and hisdown == 1 and MACD < 0 and conban2 == -1
ban2 = conban1 == 1 and (close < n1 and pacC < signalMA and open > n1 and close < pacC) and conban[1] == -1
// ENTRY SELL
if (ban2 and not onlybuy)
strategy.entry("Sell", strategy.short)
plotshape(conmua1 == 1 and conmua[1] == -1, style=shape.triangleup, color=color.lime, location=location.bottom, size=size.tiny)
plotshape(conban1 == 1 and conban[1] == -1, style=shape.triangledown, color=color.red, location=location.bottom, size=size.tiny)
plotshape(mua2, style=shape.labelup, color=color.lime, location=location.bottom, size=size.tiny)
plotshape(ban2, style=shape.labeldown, color=color.red, location=location.bottom, size=size.tiny)
// --- TP and SL ---
Stop = rr_input * 10
Take = SL_input * 10
if (useTPandSL)
strategy.exit("ExitBuy", "Buy", 1, profit=Take, loss=Stop)
strategy.exit("ExitSell", "Sell", 1, profit=Take, loss=Stop)