OPEN-SOURCE SCRIPT

Support & Resistance with Hammer/Hanging Man (Day, Week, Month)

//version=5
indicator("Support & Resistance with Hammer/Hanging Man (Day, Week, Month)", overlay=true)

// Swing High and Low Length
swingLength = 3 // Number of bars to the left and right for confirmation

// Hammer Candle Logic (Swing High / Resistance)
isHammer = (close > open) and ((high - math.max(open, close)) <= (0.4 * (high - low))) and ((math.min(open, close) - low) >= (0.5 * (high - low)))

// Hanging Man Logic (Swing Low / Support)
isHangingMan = (open > close) and ((math.min(open, close) - low) <= (0.4 * (high - low))) and ((high - math.max(open, close)) >= (0.5 * (high - low)))

// Swing High and Swing Low Logic
isSwingHigh = high == ta.highest(high, swingLength)
isSwingLow = low == ta.lowest(low, swingLength)

// Plot Support and Resistance Levels for Current Timeframe
var line resistanceLine = na // Variable for storing resistance line
var line supportLine = na // Variable for storing support line

// Draw Resistance Line (Current Timeframe)
if isSwingHigh and isHammer
if not na(resistanceLine)
line.delete(resistanceLine) // Delete previous line
resistanceLine := line.new(bar_index, high, bar_index + 10, high, color=color.red, width=1, extend=extend.right)

// Draw Support Line (Current Timeframe)
if isSwingLow and isHangingMan
if not na(supportLine)
line.delete(supportLine) // Delete previous line
supportLine := line.new(bar_index, low, bar_index + 10, low, color=color.green, width=1, extend=extend.right)

// Resistance and Support for Daily Timeframe
daily_high = request.security(syminfo.tickerid, "D", high)
daily_low = request.security(syminfo.tickerid, "D", low)

// Resistance and Support for Weekly Timeframe
weekly_high = request.security(syminfo.tickerid, "W", high)
weekly_low = request.security(syminfo.tickerid, "W", low)

// Resistance and Support for Monthly Timeframe
monthly_high = request.security(syminfo.tickerid, "M", high)
monthly_low = request.security(syminfo.tickerid, "M", low)

// Plot Resistance and Support for Daily, Weekly, and Monthly Timeframes
plot(daily_high, color=color.red, linewidth=1, title="Daily Resistance", style=plot.style_line)
plot(daily_low, color=color.green, linewidth=1, title="Daily Support", style=plot.style_line)

plot(weekly_high, color=color.red, linewidth=2, title="Weekly Resistance", style=plot.style_line)
plot(weekly_low, color=color.green, linewidth=2, title="Weekly Support", style=plot.style_line)

plot(monthly_high, color=color.red, linewidth=3, title="Monthly Resistance", style=plot.style_line)
plot(monthly_low, color=color.green, linewidth=3, title="Monthly Support", style=plot.style_line)

// Plot Markers for Swing High and Low (Current Timeframe)
plotshape(isSwingHigh and isHammer, style=shape.triangleup, location=location.abovebar, color=color.red, size=size.small, title="Resistance - Hammer")
plotshape(isSwingLow and isHangingMan, style=shape.triangledown, location=location.belowbar, color=color.green, size=size.small, title="Support - Hanging Man")
Chart patterns

نص برمجي مفتوح المصدر

قام مؤلف هذا النص البرمجي بنشره وجعله مفتوح المصدر، بحيث يمكن للمتداولين فهمه والتحقق منه، وهو الأمر الذي يدخل ضمن قيم TradingView. تحياتنا للمؤلف! يمكنك استخدامه مجانًا، ولكن إعادة استخدام هذا الرمز في المنشور يخضع لقواعد‎‎قوانين الموقع. يمكنك جعله مفضلاً لاستخدامه على الرسم البياني.

هل تريد استخدام هذا النص البرمجي على الرسم البياني؟

إخلاء المسؤولية