//version=5
strategy("SMC Trading Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// 定义 Swing High 和 Swing Low
swingHigh = ta.highest(high, 5)
swingLow = ta.lowest(low, 5)
// 识别 BOS(结构突破)
bosUp = ta.crossover(high, ta.highest(high, 20))
bosDown = ta.crossunder(low, ta.lowest(low, 20))
// 识别 CHoCH(结构变化)
chochUp = ta.crossover(high, ta.lowest(low, 20))
chochDown = ta.crossunder(low, ta.highest(high, 20))
// 订单块(Order Block, OB)检测
bullishOB = ta.valuewhen(bosUp, low[1], 0) // 看涨订单块
bearishOB = ta.valuewhen(bosDown, high[1], 0) // 看跌订单块
// FVG(Fair Value Gap)
fvgUp = high[2] < low[0]
fvgDown = low[2] > high[0]
// 交易规则
longEntry = bosUp and fvgUp and close > bullishOB
shortEntry = bosDown and fvgDown and close < bearishOB
// 进场
if longEntry
strategy.entry("Buy", strategy.long)
strategy.exit("Take Profit", from_entry="Buy", limit=close + (close - bullishOB) * 2, stop=low)
if shortEntry
strategy.entry("Sell", strategy.short)
strategy.exit("Take Profit", from_entry="Sell", limit=close - (bearishOB - close) * 2, stop=high)
// 画出 OB 区域
plot(bullishOB, color=color.green, style=plot.style_stepline, title="Bullish OB")
plot(bearishOB, color=color.red, style=plot.style_stepline, title="Bearish OB")
strategy("SMC Trading Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// 定义 Swing High 和 Swing Low
swingHigh = ta.highest(high, 5)
swingLow = ta.lowest(low, 5)
// 识别 BOS(结构突破)
bosUp = ta.crossover(high, ta.highest(high, 20))
bosDown = ta.crossunder(low, ta.lowest(low, 20))
// 识别 CHoCH(结构变化)
chochUp = ta.crossover(high, ta.lowest(low, 20))
chochDown = ta.crossunder(low, ta.highest(high, 20))
// 订单块(Order Block, OB)检测
bullishOB = ta.valuewhen(bosUp, low[1], 0) // 看涨订单块
bearishOB = ta.valuewhen(bosDown, high[1], 0) // 看跌订单块
// FVG(Fair Value Gap)
fvgUp = high[2] < low[0]
fvgDown = low[2] > high[0]
// 交易规则
longEntry = bosUp and fvgUp and close > bullishOB
shortEntry = bosDown and fvgDown and close < bearishOB
// 进场
if longEntry
strategy.entry("Buy", strategy.long)
strategy.exit("Take Profit", from_entry="Buy", limit=close + (close - bullishOB) * 2, stop=low)
if shortEntry
strategy.entry("Sell", strategy.short)
strategy.exit("Take Profit", from_entry="Sell", limit=close - (bearishOB - close) * 2, stop=high)
// 画出 OB 区域
plot(bullishOB, color=color.green, style=plot.style_stepline, title="Bullish OB")
plot(bearishOB, color=color.red, style=plot.style_stepline, title="Bearish OB")
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
