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)
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.