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}}")
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menjadikannya sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Hormat untuk penulisnya! Meskipun anda dapat menggunakannya secara gratis, ingatlah bahwa penerbitan ulang kode tersebut tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, penulis skrip ini telah menjadikannya sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Hormat untuk penulisnya! Meskipun anda dapat menggunakannya secara gratis, ingatlah bahwa penerbitan ulang kode tersebut tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.