커뮤니티
지표 부탁 드립니다
//@version=6
indicator("Williams Fractals — Goldilocks Edition [NPR21]", shorttitle="Fractals Goldilocks [NPR21]", overlay=true, precision=0, format=format.price)
// ===================== Inputs =====================
n = input.int(title="Periods (n)", defval=2, minval=2)
showLabels = input.bool(title="Show BUY/SELL Labels", defval=true)
showShapes = input.bool(title="Show Shapes", defval=true)
// Offset: 25 is the middle ground between 'too short' and 'too wide'
buyOffsetTicks = input.int(title="BUY offset (ticks)", defval=25, minval=0)
sellOffsetTicks = input.int(title="SELL offset (ticks)", defval=25, minval=0)
// High-contrast colors
buyLabelBgColor = input.color(title="BUY label background", defval=color.rgb(0, 50, 45))
sellLabelBgColor = input.color(title="SELL label background", defval=color.rgb(80, 0, 0))
buyTextColor = input.color(title="BUY text color", defval=color.white)
sellTextColor = input.color(title="SELL text color", defval=color.yellow)
labelSizeOpt = input.string(title="Label size", defval="normal", options=["tiny","small","normal","large","huge"])
lblSize = labelSizeOpt == "tiny" ? size.tiny :
labelSizeOpt == "small" ? size.small :
labelSizeOpt == "normal" ? size.normal :
labelSizeOpt == "large" ? size.large : size.huge
// ===================== Fractals Logic =====================
upPivot = ta.pivothigh(high, n, n)
downPivot = ta.pivotlow(low, n, n)
upFractal = not na(upPivot)
downFractal = not na(downPivot)
// ===================== Labels =====================
// Removed extra character spacing for better readability
if showLabels and downFractal
label.new(bar_index - n, low[n] - buyOffsetTicks * syminfo.mintick, "BUY", xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_up, color=buyLabelBgColor, textcolor=buyTextColor, size=lblSize)
if showLabels and upFractal
label.new(bar_index - n, high[n] + sellOffsetTicks * syminfo.mintick, "SELL", xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_down, color=sellLabelBgColor, textcolor=sellTextColor, size=lblSize)
// ===================== The "Long V" Extensions =====================
plotshape(showLabels and upFractal, title="Long V Sell", style=shape.arrowdown, location=location.abovebar, offset=-n, color=sellLabelBgColor, size=size.normal)
plotshape(showLabels and downFractal, title="Long V Buy", style=shape.arrowup, location=location.belowbar, offset=-n, color=buyLabelBgColor, size=size.normal)
답변 1
예스스탁 예스스탁 답변
2025-12-24 10:49:47