OPEN-SOURCE SCRIPT
SMC Ultra-Fast: ALL-IN & Auto-Signal [Fixed]

//version=5
indicator("SMC Ultra-Fast: ALL-IN & Auto-Signal [Fixed]", overlay=true, max_bars_back=5000)
// ================= Settings =================
group_fast = "Fast Entry Settings"
rr_ratio = input.float(2.0, "Risk:Reward Ratio", group=group_fast)
atr_mult = input.float(1.0, "Tight SL (ATR)", group=group_fast)
line_len = input.int(35, "Line Extension", group=group_fast)
group_vol = "High Volume Accumulation"
vol_look = input.int(100, "Volume Lookback", group=group_vol)
// ================= State Management =================
var float cur_tp = na
var float cur_sl = na
var bool in_trade = false
var line entL = na, var line tpL = na, var line slL = na
var label entLb = na, var label tpLb = na, var label slLb = na
var box res_box = na, var box sup_box = na
var label res_lbl = na, var label sup_lbl = na
// ================= Calculations =================
emaFast = ta.ema(close, 8)
emaSlow = ta.ema(close, 21)
atr = ta.atr(10)
vol_ma = ta.sma(volume, 20)
// --- 1. กล่องแนวรับ-แนวต้าน (High Volume Zones) พร้อมราคา ---
hi_v = ta.highest(high, vol_look)
lo_v = ta.lowest(low, vol_look)
if ta.change(hi_v)
box.delete(res_box), label.delete(res_lbl)
res_box := box.new(bar_index[20], hi_v, bar_index + 15, hi_v - (atr * 0.3), bgcolor=color.new(color.red, 80), border_color=color.red)
res_lbl := label.new(bar_index + 15, hi_v, "แนวต้าน: " + str.tostring(hi_v, "#.#####"), color=color.red, style=label.style_label_left, textcolor=color.white, size=size.small)
if ta.change(lo_v)
box.delete(sup_box), label.delete(sup_lbl)
sup_box := box.new(bar_index[20], lo_v, bar_index + 15, lo_v + (atr * 0.3), bgcolor=color.new(color.green, 80), border_color=color.green)
sup_lbl := label.new(bar_index + 15, lo_v, "แนวรับ: " + str.tostring(lo_v, "#.#####"), color=color.green, style=label.style_label_left, textcolor=color.white, size=size.small)
// --- 2. ระบบสีแท่งเทียนแยกเทรนด์ ---
is_bull = close > emaFast and close > emaSlow
is_bear = close < emaFast and close < emaSlow
barcolor(is_bull ? color.green : is_bear ? color.red : color.orange)
// --- 3. สัญญาณ ALL-IN & Extra Buy/Sell (Fast & Precise) ---
ph = ta.pivothigh(high, 2, 2)
pl = ta.pivotlow(low, 2, 2)
var float last_h = na
var float last_l = na
if not na(ph)
last_h := ph
if not na(pl)
last_l := pl
// จุด ALL-IN: เบรค Pivot + เทรนด์ชัด + โวลุ่มสูง
all_in_buy = ta.crossover(close, last_h) and is_bull and volume > vol_ma * 1.2 and not in_trade
all_in_sell = ta.crossunder(close, last_l) and is_bear and volume > vol_ma * 1.2 and not in_trade
// สัญญาณ Buy/Sell เพิ่มเติม (Fast Signals)
fast_buy = ta.crossover(emaFast, emaSlow) and not all_in_buy
fast_sell = ta.crossunder(emaFast, emaSlow) and not all_in_sell
plotshape(fast_buy, "Fast Buy", shape.triangleup, location.belowbar, color.lime, size=size.tiny, title="Fast Buy Signal")
plotshape(fast_sell, "Fast Sell", shape.triangledown, location.abovebar, color.orange, size=size.tiny, title="Fast Sell Signal")
// ================= 4. การจัดการ TP/SL/Entry (Auto-Reset) =================
if all_in_buy or all_in_sell
line.delete(entL), line.delete(tpL), line.delete(slL)
label.delete(entLb), label.delete(tpLb), label.delete(slLb)
float ep = close
cur_sl := all_in_buy ? (low - (atr * atr_mult)) : (high + (atr * atr_mult))
cur_tp := all_in_buy ? (ep + (math.abs(ep-cur_sl) * rr_ratio)) : (ep - (math.abs(ep-cur_sl) * rr_ratio))
in_trade := true
entL := line.new(bar_index, ep, bar_index + line_len, ep, color=color.gray, style=line.style_dashed, width=2)
tpL := line.new(bar_index, cur_tp, bar_index + line_len, cur_tp, color=color.blue, width=2)
slL := line.new(bar_index, cur_sl, bar_index + line_len, cur_sl, color=color.red, width=2)
entLb := label.new(bar_index + line_len, ep, "ENTRY: " + str.tostring(ep, "#.#####"), color=color.gray, style=label.style_label_left, textcolor=color.white)
tpLb := label.new(bar_index + line_len, cur_tp, "TP: " + str.tostring(cur_tp, "#.#####"), color=color.blue, style=label.style_label_left, textcolor=color.white)
slLb := label.new(bar_index + line_len, cur_sl, "SL: " + str.tostring(cur_sl, "#.#####"), color=color.red, style=label.style_label_left, textcolor=color.white)
label.new(bar_index, all_in_buy ? low : high, all_in_buy ? "🔥 ALL-IN BUY" : "🔥 ALL-IN SELL", color=all_in_buy ? color.green : color.red, style=all_in_buy ? label.style_label_up : label.style_label_down, textcolor=color.white)
// ระบบล้างสถานะอัตโนมัติเมื่อชนเป้าหมาย
if in_trade
hit = (high >= cur_tp and cur_tp > cur_sl) or (low <= cur_tp and cur_tp < cur_sl) or (low <= cur_sl and cur_tp > cur_sl) or (high >= cur_sl and cur_tp < cur_sl)
if hit
label.new(bar_index, close, "X", color=color.white, style=label.style_label_center, size=size.small)
in_trade := false
indicator("SMC Ultra-Fast: ALL-IN & Auto-Signal [Fixed]", overlay=true, max_bars_back=5000)
// ================= Settings =================
group_fast = "Fast Entry Settings"
rr_ratio = input.float(2.0, "Risk:Reward Ratio", group=group_fast)
atr_mult = input.float(1.0, "Tight SL (ATR)", group=group_fast)
line_len = input.int(35, "Line Extension", group=group_fast)
group_vol = "High Volume Accumulation"
vol_look = input.int(100, "Volume Lookback", group=group_vol)
// ================= State Management =================
var float cur_tp = na
var float cur_sl = na
var bool in_trade = false
var line entL = na, var line tpL = na, var line slL = na
var label entLb = na, var label tpLb = na, var label slLb = na
var box res_box = na, var box sup_box = na
var label res_lbl = na, var label sup_lbl = na
// ================= Calculations =================
emaFast = ta.ema(close, 8)
emaSlow = ta.ema(close, 21)
atr = ta.atr(10)
vol_ma = ta.sma(volume, 20)
// --- 1. กล่องแนวรับ-แนวต้าน (High Volume Zones) พร้อมราคา ---
hi_v = ta.highest(high, vol_look)
lo_v = ta.lowest(low, vol_look)
if ta.change(hi_v)
box.delete(res_box), label.delete(res_lbl)
res_box := box.new(bar_index[20], hi_v, bar_index + 15, hi_v - (atr * 0.3), bgcolor=color.new(color.red, 80), border_color=color.red)
res_lbl := label.new(bar_index + 15, hi_v, "แนวต้าน: " + str.tostring(hi_v, "#.#####"), color=color.red, style=label.style_label_left, textcolor=color.white, size=size.small)
if ta.change(lo_v)
box.delete(sup_box), label.delete(sup_lbl)
sup_box := box.new(bar_index[20], lo_v, bar_index + 15, lo_v + (atr * 0.3), bgcolor=color.new(color.green, 80), border_color=color.green)
sup_lbl := label.new(bar_index + 15, lo_v, "แนวรับ: " + str.tostring(lo_v, "#.#####"), color=color.green, style=label.style_label_left, textcolor=color.white, size=size.small)
// --- 2. ระบบสีแท่งเทียนแยกเทรนด์ ---
is_bull = close > emaFast and close > emaSlow
is_bear = close < emaFast and close < emaSlow
barcolor(is_bull ? color.green : is_bear ? color.red : color.orange)
// --- 3. สัญญาณ ALL-IN & Extra Buy/Sell (Fast & Precise) ---
ph = ta.pivothigh(high, 2, 2)
pl = ta.pivotlow(low, 2, 2)
var float last_h = na
var float last_l = na
if not na(ph)
last_h := ph
if not na(pl)
last_l := pl
// จุด ALL-IN: เบรค Pivot + เทรนด์ชัด + โวลุ่มสูง
all_in_buy = ta.crossover(close, last_h) and is_bull and volume > vol_ma * 1.2 and not in_trade
all_in_sell = ta.crossunder(close, last_l) and is_bear and volume > vol_ma * 1.2 and not in_trade
// สัญญาณ Buy/Sell เพิ่มเติม (Fast Signals)
fast_buy = ta.crossover(emaFast, emaSlow) and not all_in_buy
fast_sell = ta.crossunder(emaFast, emaSlow) and not all_in_sell
plotshape(fast_buy, "Fast Buy", shape.triangleup, location.belowbar, color.lime, size=size.tiny, title="Fast Buy Signal")
plotshape(fast_sell, "Fast Sell", shape.triangledown, location.abovebar, color.orange, size=size.tiny, title="Fast Sell Signal")
// ================= 4. การจัดการ TP/SL/Entry (Auto-Reset) =================
if all_in_buy or all_in_sell
line.delete(entL), line.delete(tpL), line.delete(slL)
label.delete(entLb), label.delete(tpLb), label.delete(slLb)
float ep = close
cur_sl := all_in_buy ? (low - (atr * atr_mult)) : (high + (atr * atr_mult))
cur_tp := all_in_buy ? (ep + (math.abs(ep-cur_sl) * rr_ratio)) : (ep - (math.abs(ep-cur_sl) * rr_ratio))
in_trade := true
entL := line.new(bar_index, ep, bar_index + line_len, ep, color=color.gray, style=line.style_dashed, width=2)
tpL := line.new(bar_index, cur_tp, bar_index + line_len, cur_tp, color=color.blue, width=2)
slL := line.new(bar_index, cur_sl, bar_index + line_len, cur_sl, color=color.red, width=2)
entLb := label.new(bar_index + line_len, ep, "ENTRY: " + str.tostring(ep, "#.#####"), color=color.gray, style=label.style_label_left, textcolor=color.white)
tpLb := label.new(bar_index + line_len, cur_tp, "TP: " + str.tostring(cur_tp, "#.#####"), color=color.blue, style=label.style_label_left, textcolor=color.white)
slLb := label.new(bar_index + line_len, cur_sl, "SL: " + str.tostring(cur_sl, "#.#####"), color=color.red, style=label.style_label_left, textcolor=color.white)
label.new(bar_index, all_in_buy ? low : high, all_in_buy ? "🔥 ALL-IN BUY" : "🔥 ALL-IN SELL", color=all_in_buy ? color.green : color.red, style=all_in_buy ? label.style_label_up : label.style_label_down, textcolor=color.white)
// ระบบล้างสถานะอัตโนมัติเมื่อชนเป้าหมาย
if in_trade
hit = (high >= cur_tp and cur_tp > cur_sl) or (low <= cur_tp and cur_tp < cur_sl) or (low <= cur_sl and cur_tp > cur_sl) or (high >= cur_sl and cur_tp < cur_sl)
if hit
label.new(bar_index, close, "X", color=color.white, style=label.style_label_center, size=size.small)
in_trade := false
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.