커뮤니티

지표 부탁 드립니다

프로필 이미지
매치다2
2025-12-23 22:43:35
97
글번호 229318
답변완료

//@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

안녕하세요 예스스탁입니다. input : n(2); input : showLabels(true); input : showShapes(true); input : buyOffsetTicks(25); input : sellOffsetTicks(25); input : buyLabelBgColor(Blue); input : sellLabelBgColor(Red); input : buyTextColor(White) ; input : sellTextColor(yellow); input : labelSizeOpt(20); var : upPivot(0),downPivot(0),upFractal(False),downFractal(False); var : tx(0),tx1(0); upPivot = SwingHigh(1,h,n,n,n*2+1); downPivot = Swinglow(1,l,n,n,n*2+1); upFractal = upPivot > 0; downFractal = downPivot > 0; if showLabels and downFractal Then { tx = Text_New(sDate[n],sTime[n],low[n] - buyOffsetTicks * PriceScale, "BUY"); Text_SetStyle(tx,2,0); Text_SetColor(tx,buyTextColor); Text_SetSize(tx,labelSizeOpt); tx1 = Text_New(sDate[n],sTime[n],Low[n],"▲"); Text_SetStyle(tx1,2,0); Text_SetColor(tx,buyLabelBgColor); Text_SetSize(tx,labelSizeOpt); } if showLabels and upFractal Then { tx = Text_New(sDate[n],sTime[n],high[n] + sellOffsetTicks * PriceScale, "SELL"); Text_SetStyle(tx,2,1); Text_SetColor(tx,buyTextColor); Text_SetSize(tx,labelSizeOpt); tx1 = Text_New(sDate[n],sTime[n],high[n],"▼"); Text_SetStyle(tx1,2,1); Text_SetColor(tx,sellLabelBgColor); Text_SetSize(tx,labelSizeOpt); } 즐거운 하루되세요