OPEN-SOURCE SCRIPT
5m Hammer Detector Pro (Clean View)

//version=5
indicator("5m Hammer Detector Pro (Clean View)", overlay=true)
// ===== Inputs =====
tf_detect = input.timeframe("5", "Detection timeframe (keep 5 for 5-min)")
min_lower_to_body = input.float(2.0, "Min lower-wick / body ratio", step=0.1)
max_upper_to_body = input.float(0.5, "Max upper-wick / body ratio", step=0.1)
max_body_to_range = input.float(0.30, "Max body / total-range ratio", step=0.01)
min_lower_to_range = input.float(0.45, "Min lower-wick / total-range ratio", step=0.01)
use_bullish_only = input.bool(true, "Only bullish hammer (close > open)?")
vol_mult = input.float(1.5, "Volume threshold multiplier (x avg volume)", step=0.1)
confirm_next_candle = input.bool(true, "Require next bullish candle for confirmation?")
// ===== Hammer Logic =====
f_is_hammer(o, h, l, c) =>
body = math.abs(c - o)
lower = math.min(o, c) - l
upper = h - math.max(o, c)
rng = h - l
body := body == 0 ? 0.0000001 : body
rng := rng == 0 ? 0.0000001 : rng
cond1 = (lower / body) >= min_lower_to_body
cond2 = (upper / body) <= max_upper_to_body
cond3 = (body / rng) <= max_body_to_range
cond4 = (lower / rng) >= min_lower_to_range
cond5 = use_bullish_only ? (c > o) : true
cond1 and cond2 and cond3 and cond4 and cond5
// ===== 5-Min Data =====
[ro, rh, rl, rc, rv] = request.security(syminfo.tickerid, tf_detect, [open, high, low, close, volume])
vol_avg = ta.sma(rv, 20)
vol_ok = rv > (vol_avg * vol_mult)
hammer_raw = f_is_hammer(ro, rh, rl, rc)
hammer_with_vol = hammer_raw and vol_ok
[no, nh, nl, nc] = request.security(syminfo.tickerid, tf_detect, [open[1], high[1], low[1], close[1]])
confirmed = confirm_next_candle ? (hammer_with_vol and rc > ro and nc > rh) : hammer_with_vol
new_candle_5m = ta.change(rc) != 0
hammer_final = confirmed and new_candle_5m
// ===== Plot hammer mark only =====
plotshape(hammer_final, title="Hammer Signal", location=location.belowbar,
style=shape.labelup, text="✅ HAMMER 5m", color=color.new(color.green, 0),
textcolor=color.white, size=size.tiny)
bgcolor(hammer_final ? color.new(color.green, 85) : na)
// ===== Alert =====
alertcondition(hammer_final, title="5m Hammer Confirmed Alert",
message="🔥 {{ticker}} | 5m Confirmed Hammer at {{time}} | Vol OK | Close: {{close}}")
indicator("5m Hammer Detector Pro (Clean View)", overlay=true)
// ===== Inputs =====
tf_detect = input.timeframe("5", "Detection timeframe (keep 5 for 5-min)")
min_lower_to_body = input.float(2.0, "Min lower-wick / body ratio", step=0.1)
max_upper_to_body = input.float(0.5, "Max upper-wick / body ratio", step=0.1)
max_body_to_range = input.float(0.30, "Max body / total-range ratio", step=0.01)
min_lower_to_range = input.float(0.45, "Min lower-wick / total-range ratio", step=0.01)
use_bullish_only = input.bool(true, "Only bullish hammer (close > open)?")
vol_mult = input.float(1.5, "Volume threshold multiplier (x avg volume)", step=0.1)
confirm_next_candle = input.bool(true, "Require next bullish candle for confirmation?")
// ===== Hammer Logic =====
f_is_hammer(o, h, l, c) =>
body = math.abs(c - o)
lower = math.min(o, c) - l
upper = h - math.max(o, c)
rng = h - l
body := body == 0 ? 0.0000001 : body
rng := rng == 0 ? 0.0000001 : rng
cond1 = (lower / body) >= min_lower_to_body
cond2 = (upper / body) <= max_upper_to_body
cond3 = (body / rng) <= max_body_to_range
cond4 = (lower / rng) >= min_lower_to_range
cond5 = use_bullish_only ? (c > o) : true
cond1 and cond2 and cond3 and cond4 and cond5
// ===== 5-Min Data =====
[ro, rh, rl, rc, rv] = request.security(syminfo.tickerid, tf_detect, [open, high, low, close, volume])
vol_avg = ta.sma(rv, 20)
vol_ok = rv > (vol_avg * vol_mult)
hammer_raw = f_is_hammer(ro, rh, rl, rc)
hammer_with_vol = hammer_raw and vol_ok
[no, nh, nl, nc] = request.security(syminfo.tickerid, tf_detect, [open[1], high[1], low[1], close[1]])
confirmed = confirm_next_candle ? (hammer_with_vol and rc > ro and nc > rh) : hammer_with_vol
new_candle_5m = ta.change(rc) != 0
hammer_final = confirmed and new_candle_5m
// ===== Plot hammer mark only =====
plotshape(hammer_final, title="Hammer Signal", location=location.belowbar,
style=shape.labelup, text="✅ HAMMER 5m", color=color.new(color.green, 0),
textcolor=color.white, size=size.tiny)
bgcolor(hammer_final ? color.new(color.green, 85) : na)
// ===== Alert =====
alertcondition(hammer_final, title="5m Hammer Confirmed Alert",
message="🔥 {{ticker}} | 5m Confirmed Hammer at {{time}} | Vol OK | Close: {{close}}")
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.