//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")
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
