OPEN-SOURCE SCRIPT
HH/LL ZigZag with S/R, EMA, FVG

//version=5
indicator('HH/LL + EMA + FVG с Надписи', overlay = true, max_lines_count = 500, max_labels_count = 500)
// === INPUTS ===
zigzagLen = input.int(10, 'ZigZag Period', minval = 1)
sourceType = input.string('High/Low', 'Source', options = ['Close', 'High/Low'])
showZigzag = input.bool(true, 'Show ZigZag')
showHHLL = input.bool(true, 'Show HH/LL')
showSR = input.bool(true, 'Show Support/Resistance')
changeColorSR = input.bool(true, 'Change Bar Color if S/R Broken')
showFVG = input.bool(true, "Show FVG Zones with Labels")
// === EMA SETTINGS ===
showEMA = input.bool(true, "Show EMAs")
ema20 = ta.ema(close, 20)
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
plot(showEMA ? ema20 : na, color=color.orange, title="EMA 20", linewidth=1)
plot(showEMA ? ema50 : na, color=color.blue, title="EMA 50", linewidth=1)
plot(showEMA ? ema200 : na, color=color.purple, title="EMA 200", linewidth=2)
// === ZIGZAG POINTS ===
isHigh = sourceType == 'High/Low' ? high == ta.highest(high, zigzagLen) : close == ta.highest(close, zigzagLen)
isLow = sourceType == 'High/Low' ? low == ta.lowest(low, zigzagLen) : close == ta.lowest(close, zigzagLen)
var float lastPivotHigh = na
var float lastPivotLow = na
var int lastHighIndex = na
var int lastLowIndex = na
if isHigh
if not na(lastPivotLow) and showZigzag
line.new(lastLowIndex, lastPivotLow, bar_index, high, color=color.green, width=2)
lastPivotHigh := high
lastHighIndex := bar_index
if showHHLL
if na(lastPivotHigh[1]) or high > lastPivotHigh[1]
label.new(bar_index, high, 'HH', style=label.style_label_down, color=color.green, textcolor=color.white)
else
label.new(bar_index, high, 'LH', style=label.style_label_down, color=color.red, textcolor=color.white)
if isLow
if not na(lastPivotHigh) and showZigzag
line.new(lastHighIndex, lastPivotHigh, bar_index, low, color=color.red, width=2)
lastPivotLow := low
lastLowIndex := bar_index
if showHHLL
if na(lastPivotLow[1]) or low > lastPivotLow[1]
label.new(bar_index, low, 'HL', style=label.style_label_up, color=color.green, textcolor=color.white)
else
label.new(bar_index, low, 'LL', style=label.style_label_up, color=color.red, textcolor=color.white)
// === SUPPORT / RESISTANCE LEVELS ===
var float supportLevel = na
var float resistanceLevel = na
if isLow and showSR
supportLevel := low
line.new(bar_index, supportLevel, bar_index + 10, supportLevel, extend=extend.right, color=color.green, style=line.style_dashed)
if isHigh and showSR
resistanceLevel := high
line.new(bar_index, resistanceLevel, bar_index + 10, resistanceLevel, extend=extend.right, color=color.red, style=line.style_dashed)
// === BAR COLOR IF S/R BROKEN ===
barcolor(changeColorSR and not na(resistanceLevel) and close > resistanceLevel ? color.lime :
changeColorSR and not na(supportLevel) and close < supportLevel ? color.fuchsia :
na)
// === FVG ===
if showFVG
// Bullish FVG: Low[2] > High
if bar_index > 2 and low[2] > high
box.new(left=bar_index - 2, right=bar_index, top=low[2], bottom=high,
bgcolor=color.new(color.green, 85), border_color=color.green)
label.new(x=bar_index, y=low[2], text="Bullish FVG", style=label.style_label_up, textcolor=color.white, color=color.green)
// Bearish FVG: High[2] < Low
if bar_index > 2 and high[2] < low
box.new(left=bar_index - 2, right=bar_index, top=high[2], bottom=low,
bgcolor=color.new(color.red, 85), border_color=color.red)
label.new(x=bar_index, y=high[2], text="Bearish FVG", style=label.style_label_down, textcolor=color.white, color=color.red)
indicator('HH/LL + EMA + FVG с Надписи', overlay = true, max_lines_count = 500, max_labels_count = 500)
// === INPUTS ===
zigzagLen = input.int(10, 'ZigZag Period', minval = 1)
sourceType = input.string('High/Low', 'Source', options = ['Close', 'High/Low'])
showZigzag = input.bool(true, 'Show ZigZag')
showHHLL = input.bool(true, 'Show HH/LL')
showSR = input.bool(true, 'Show Support/Resistance')
changeColorSR = input.bool(true, 'Change Bar Color if S/R Broken')
showFVG = input.bool(true, "Show FVG Zones with Labels")
// === EMA SETTINGS ===
showEMA = input.bool(true, "Show EMAs")
ema20 = ta.ema(close, 20)
ema50 = ta.ema(close, 50)
ema200 = ta.ema(close, 200)
plot(showEMA ? ema20 : na, color=color.orange, title="EMA 20", linewidth=1)
plot(showEMA ? ema50 : na, color=color.blue, title="EMA 50", linewidth=1)
plot(showEMA ? ema200 : na, color=color.purple, title="EMA 200", linewidth=2)
// === ZIGZAG POINTS ===
isHigh = sourceType == 'High/Low' ? high == ta.highest(high, zigzagLen) : close == ta.highest(close, zigzagLen)
isLow = sourceType == 'High/Low' ? low == ta.lowest(low, zigzagLen) : close == ta.lowest(close, zigzagLen)
var float lastPivotHigh = na
var float lastPivotLow = na
var int lastHighIndex = na
var int lastLowIndex = na
if isHigh
if not na(lastPivotLow) and showZigzag
line.new(lastLowIndex, lastPivotLow, bar_index, high, color=color.green, width=2)
lastPivotHigh := high
lastHighIndex := bar_index
if showHHLL
if na(lastPivotHigh[1]) or high > lastPivotHigh[1]
label.new(bar_index, high, 'HH', style=label.style_label_down, color=color.green, textcolor=color.white)
else
label.new(bar_index, high, 'LH', style=label.style_label_down, color=color.red, textcolor=color.white)
if isLow
if not na(lastPivotHigh) and showZigzag
line.new(lastHighIndex, lastPivotHigh, bar_index, low, color=color.red, width=2)
lastPivotLow := low
lastLowIndex := bar_index
if showHHLL
if na(lastPivotLow[1]) or low > lastPivotLow[1]
label.new(bar_index, low, 'HL', style=label.style_label_up, color=color.green, textcolor=color.white)
else
label.new(bar_index, low, 'LL', style=label.style_label_up, color=color.red, textcolor=color.white)
// === SUPPORT / RESISTANCE LEVELS ===
var float supportLevel = na
var float resistanceLevel = na
if isLow and showSR
supportLevel := low
line.new(bar_index, supportLevel, bar_index + 10, supportLevel, extend=extend.right, color=color.green, style=line.style_dashed)
if isHigh and showSR
resistanceLevel := high
line.new(bar_index, resistanceLevel, bar_index + 10, resistanceLevel, extend=extend.right, color=color.red, style=line.style_dashed)
// === BAR COLOR IF S/R BROKEN ===
barcolor(changeColorSR and not na(resistanceLevel) and close > resistanceLevel ? color.lime :
changeColorSR and not na(supportLevel) and close < supportLevel ? color.fuchsia :
na)
// === FVG ===
if showFVG
// Bullish FVG: Low[2] > High
if bar_index > 2 and low[2] > high
box.new(left=bar_index - 2, right=bar_index, top=low[2], bottom=high,
bgcolor=color.new(color.green, 85), border_color=color.green)
label.new(x=bar_index, y=low[2], text="Bullish FVG", style=label.style_label_up, textcolor=color.white, color=color.green)
// Bearish FVG: High[2] < Low
if bar_index > 2 and high[2] < low
box.new(left=bar_index - 2, right=bar_index, top=high[2], bottom=low,
bgcolor=color.new(color.red, 85), border_color=color.red)
label.new(x=bar_index, y=high[2], text="Bearish FVG", style=label.style_label_down, textcolor=color.white, color=color.red)
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.