OPEN-SOURCE SCRIPT
Fractals (VLAD_FX)

//version=5
indicator('Fractals (VLAD_FX)', overlay=true)
var GRP1 = "••••••• FRACTALS •••••••"
showFractals = input.bool(true, title='Show fractal points?', group=GRP1)
filterFractal = input.string(title='Filter 3/5 bar fractal', defval='3', options=['3', '5'], group=GRP1)
// Fractals
isRegularFractal(mode, n) =>
ret = mode == 'Buy' ? high[n - 1] < high[n] and high[n + 1] < high[n] : mode == 'Sell' ? low[n - 1] > low[n] and low[n + 1] > low[n] : false
ret
isBWFractal(mode, n) =>
ret = mode == 'Buy' ? high[n - 2] < high[n] and high[n - 1] < high[n] and high[n + 1] < high[n] and high[n + 2] < high[n] : mode == 'Sell' ? low[n - 2] > low[n] and low[n - 1] > low[n] and low[n + 1] > low[n] and low[n + 2] > low[n] : false
ret
isFractalHigh(i) =>
filterFractal == '3' ? isRegularFractal('Buy', i) : isBWFractal('Buy', i + 1)
isFractalLow(i) =>
filterFractal == '3' ? isRegularFractal('Sell', i) : isBWFractal('Sell', i + 1)
plotshape(showFractals and isFractalHigh(1), title='Fractal High', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), offset=filterFractal == '3' ? -1 : -2, size=size.auto)
plotshape(showFractals and isFractalLow(1), title='Fractal Low', style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), offset=filterFractal == '3' ? -1 : -2, size=size.auto)
//Pivots
var GRP2 = "••••••• PIVOTS •••••••"
ShowPivots = input(title='Show Pivot points?', defval=false, group=GRP2)
lb = input.int(5, title="Left Bars", minval = 1, inline="1", group=GRP2)
rb = input.int(4, title="Right Bars", minval = 1, inline="1", group=GRP2)
showHHLL = input.bool(true, title='Show HH/LL?', group=GRP2)
hhCol = input.color(color.lime, 'HH', inline="2", group=GRP2)
lhCol = input.color(color.red, 'LH', inline="2", group=GRP2)
llCol = input.color(color.red, 'LL', inline="2", group=GRP2)
hlCol = input.color(color.lime, 'HL', inline="2", group=GRP2)
var pivotHighs = array.new_float(3)
var pivotLows = array.new_float(3)
ph = ta.pivothigh(lb, rb)
ph1 = ta.valuewhen(ph, high[rb], 1)
phSince = ta.barssince(ph)
pl = ta.pivotlow(lb, rb)
pl1 = ta.valuewhen(pl, low[rb], 1)
hh = ph > ph1
lh = ph < ph1
ll = pl < pl1
hl = pl > pl1
_transparent = color.new(color.white, 100)
plotshape(ph and ShowPivots and hh, title='HH', style=shape.triangledown, location=location.abovebar, text="HH", textcolor=showHHLL ? hhCol : _transparent, color=hhCol, offset=-rb, size=size.auto)
plotshape(ph and ShowPivots and lh, title='LH', style=shape.triangledown, location=location.abovebar, text="LH", textcolor=showHHLL ? lhCol : _transparent, color=lhCol, offset=-rb, size=size.auto)
plotshape(pl and ShowPivots and ll, title='LL', style=shape.triangleup, location=location.belowbar, text="LL", textcolor=showHHLL ? llCol : _transparent, color=llCol, offset=-rb, size=size.auto)
plotshape(pl and ShowPivots and hl, title='HL', style=shape.triangleup, location=location.belowbar, text="HL", textcolor=showHHLL ? hlCol : _transparent, color=hlCol, offset=-rb, size=size.auto)
var lastPH = "na"
var lastPL = "na"
if ph
if hh
lastPH := 'HH'
else if lh
lastPH := 'LH'
// label.new(bar_index, high, str.tostring(lastPH), style=label.style_none, textcolor=color.white)
indicator('Fractals (VLAD_FX)', overlay=true)
var GRP1 = "••••••• FRACTALS •••••••"
showFractals = input.bool(true, title='Show fractal points?', group=GRP1)
filterFractal = input.string(title='Filter 3/5 bar fractal', defval='3', options=['3', '5'], group=GRP1)
// Fractals
isRegularFractal(mode, n) =>
ret = mode == 'Buy' ? high[n - 1] < high[n] and high[n + 1] < high[n] : mode == 'Sell' ? low[n - 1] > low[n] and low[n + 1] > low[n] : false
ret
isBWFractal(mode, n) =>
ret = mode == 'Buy' ? high[n - 2] < high[n] and high[n - 1] < high[n] and high[n + 1] < high[n] and high[n + 2] < high[n] : mode == 'Sell' ? low[n - 2] > low[n] and low[n - 1] > low[n] and low[n + 1] > low[n] and low[n + 2] > low[n] : false
ret
isFractalHigh(i) =>
filterFractal == '3' ? isRegularFractal('Buy', i) : isBWFractal('Buy', i + 1)
isFractalLow(i) =>
filterFractal == '3' ? isRegularFractal('Sell', i) : isBWFractal('Sell', i + 1)
plotshape(showFractals and isFractalHigh(1), title='Fractal High', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), offset=filterFractal == '3' ? -1 : -2, size=size.auto)
plotshape(showFractals and isFractalLow(1), title='Fractal Low', style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), offset=filterFractal == '3' ? -1 : -2, size=size.auto)
//Pivots
var GRP2 = "••••••• PIVOTS •••••••"
ShowPivots = input(title='Show Pivot points?', defval=false, group=GRP2)
lb = input.int(5, title="Left Bars", minval = 1, inline="1", group=GRP2)
rb = input.int(4, title="Right Bars", minval = 1, inline="1", group=GRP2)
showHHLL = input.bool(true, title='Show HH/LL?', group=GRP2)
hhCol = input.color(color.lime, 'HH', inline="2", group=GRP2)
lhCol = input.color(color.red, 'LH', inline="2", group=GRP2)
llCol = input.color(color.red, 'LL', inline="2", group=GRP2)
hlCol = input.color(color.lime, 'HL', inline="2", group=GRP2)
var pivotHighs = array.new_float(3)
var pivotLows = array.new_float(3)
ph = ta.pivothigh(lb, rb)
ph1 = ta.valuewhen(ph, high[rb], 1)
phSince = ta.barssince(ph)
pl = ta.pivotlow(lb, rb)
pl1 = ta.valuewhen(pl, low[rb], 1)
hh = ph > ph1
lh = ph < ph1
ll = pl < pl1
hl = pl > pl1
_transparent = color.new(color.white, 100)
plotshape(ph and ShowPivots and hh, title='HH', style=shape.triangledown, location=location.abovebar, text="HH", textcolor=showHHLL ? hhCol : _transparent, color=hhCol, offset=-rb, size=size.auto)
plotshape(ph and ShowPivots and lh, title='LH', style=shape.triangledown, location=location.abovebar, text="LH", textcolor=showHHLL ? lhCol : _transparent, color=lhCol, offset=-rb, size=size.auto)
plotshape(pl and ShowPivots and ll, title='LL', style=shape.triangleup, location=location.belowbar, text="LL", textcolor=showHHLL ? llCol : _transparent, color=llCol, offset=-rb, size=size.auto)
plotshape(pl and ShowPivots and hl, title='HL', style=shape.triangleup, location=location.belowbar, text="HL", textcolor=showHHLL ? hlCol : _transparent, color=hlCol, offset=-rb, size=size.auto)
var lastPH = "na"
var lastPL = "na"
if ph
if hh
lastPH := 'HH'
else if lh
lastPH := 'LH'
// label.new(bar_index, high, str.tostring(lastPH), style=label.style_none, textcolor=color.white)
오픈 소스 스크립트
진정한 트레이딩뷰 정신에 따라 이 스크립트 작성자는 트레이더가 기능을 검토하고 검증할 수 있도록 오픈소스로 공개했습니다. 작성자에게 찬사를 보냅니다! 무료로 사용할 수 있지만 코드를 다시 게시할 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.
오픈 소스 스크립트
진정한 트레이딩뷰 정신에 따라 이 스크립트 작성자는 트레이더가 기능을 검토하고 검증할 수 있도록 오픈소스로 공개했습니다. 작성자에게 찬사를 보냅니다! 무료로 사용할 수 있지만 코드를 다시 게시할 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.