OTE Structure Flow//@version=6
indicator("OTE • Structure & Flow Map", overlay=true, max_lines_count=500, max_labels_count=500, max_boxes_count=100)
//━━━━━━━━━━━━ INPUTS
pivotLen = input.int(5, "Swing Pivot Length", minval=1)
maxSwings = input.int(40, "Visible Swing Count", minval=10, maxval=100)
extendBars = input.int(120, "Flow Extend Bars", minval=20, maxval=300)
showSwings = input.bool(true, "Show Market Structure")
showOTE = input.bool(true, "Show OTE 0.886")
showTarget = input.bool(true, "Show Target 0.618")
showCore = input.bool(true, "Show Regression Gravity Line")
showLabels = input.bool(true, "Show HH / HL / LH / LL")
regLen = input.int(120, "Regression Length", minval=20, maxval=300)
regSmooth = input.int(5, "Regression Smooth", minval=1)
bullCol = color.lime
bearCol = color.red
oteCol = color.yellow
tpCol = color.aqua
grayCol = color.gray
//━━━━━━━━━━━━ PIVOTS
ph = ta.pivothigh(high, pivotLen, pivotLen)
pl = ta.pivotlow(low, pivotLen, pivotLen)
phBar = bar_index - pivotLen
plBar = bar_index - pivotLen
var float pivPrice = array.new_float()
var int pivBar = array.new_int()
var int pivType = array.new_int() // 1 high, -1 low
addPivot(_price, _bar, _type) =>
sz = array.size(pivType)
if sz == 0
array.push(pivPrice, _price)
array.push(pivBar, _bar)
array.push(pivType, _type)
else
lastType = array.get(pivType, sz - 1)
lastPrice = array.get(pivPrice, sz - 1)
if lastType == _type
replaceHigh = _type == 1 and _price > lastPrice
replaceLow = _type == -1 and _price < lastPrice
if replaceHigh or replaceLow
array.set(pivPrice, sz - 1, _price)
array.set(pivBar, sz - 1, _bar)
else
array.push(pivPrice, _price)
array.push(pivBar, _bar)
array.push(pivType, _type)
while array.size(pivType) > maxSwings
array.shift(pivPrice)
array.shift(pivBar)
array.shift(pivType)
if not na(ph)
addPivot(ph, phBar, 1)
if not na(pl)
addPivot(pl, plBar, -1)
//━━━━━━━━━━━━ REGRESSION FLOW CORE
src = hl2
reg0 = ta.linreg(src, regLen, 0)
reg1 = ta.linreg(src, regLen, 1)
reg2 = ta.linreg(src, regLen, 2)
slope = reg0 - reg1
curve = (reg0 - reg1) - (reg1 - reg2)
gravityRaw = reg0 + slope * 2.0 + curve * regLen * 0.25
gravity = ta.ema(gravityRaw, regSmooth)
gravityBull = gravity > gravity
gravityBear = gravity < gravity
gravityCol = gravityBull ? bullCol : gravityBear ? bearCol : grayCol
plot(showCore ? gravity : na, "Market Gravity Regression Line", color=color.new(gravityCol, 0), linewidth=3)
//━━━━━━━━━━━━ OBJECTS
var line lines = array.new_line()
var label labels = array.new_label()
var box boxes = array.new_box()
clearObjects() =>
while array.size(lines) > 0
line.delete(array.pop(lines))
while array.size(labels) > 0
label.delete(array.pop(labels))
while array.size(boxes) > 0
box.delete(array.pop(boxes))
addLine(_x1, _y1, _x2, _y2, _col, _style, _width) =>
ln = line.new(_x1, _y1, _x2, _y2, xloc=xloc.bar_index, extend=extend.none, color=_col, style=_style, width=_width)
array.push(lines, ln)
addLabel(_x, _y, _txt, _col, _up) =>
if showLabels
lb = label.new(_x, _y, _txt, xloc=xloc.bar_index, style=_up ? label.style_label_up : label.style_label_down, color=_col, textcolor=color.black, size=size.tiny)
array.push(labels, lb)
addBox(_left, _top, _right, _bottom, _col) =>
bx = box.new(_left, _top, _right, _bottom, xloc=xloc.bar_index, bgcolor=color.new(_col, 86), border_color=color.new(_col, 25))
array.push(boxes, bx)
prevSamePrice(_idx, _type) =>
float res = na
for j = _idx - 1 to 0
if array.get(pivType, j) == _type and na(res)
res := array.get(pivPrice, j)
res
//━━━━━━━━━━━━ DRAW STRUCTURE + OTE FLOW
var string mode = "WAIT"
if barstate.islast
clearObjects()
mode := "STRUCTURE FLOW"
sz = array.size(pivType)
if showSwings and sz >= 2
for i = 1 to sz - 1
pA = array.get(pivPrice, i - 1)
pB = array.get(pivPrice, i)
bA = array.get(pivBar, i - 1)
bB = array.get(pivBar, i)
tB = array.get(pivType, i)
prev = prevSamePrice(i, tB)
isHH = tB == 1 and not na(prev) and pB > prev
isLH = tB == 1 and not na(prev) and pB <= prev
isHL = tB == -1 and not na(prev) and pB > prev
isLL = tB == -1 and not na(prev) and pB <= prev
sCol = isHH or isHL ? bullCol : isLH or isLL ? bearCol : grayCol
txt = isHH ? "HH" : isLH ? "LH" : isHL ? "HL" : isLL ? "LL" : tB == 1 ? "H" : "L"
addLine(bA, pA, bB, pB, sCol, line.style_solid, 2)
addLabel(bB, pB, txt, sCol, tB == -1)
if sz >= 4
i1 = sz - 4
i2 = sz - 3
i3 = sz - 2
i4 = sz - 1
t1 = array.get(pivType, i1)
t2 = array.get(pivType, i2)
t3 = array.get(pivType, i3)
t4 = array.get(pivType, i4)
p1 = array.get(pivPrice, i1)
p2 = array.get(pivPrice, i2)
p3 = array.get(pivPrice, i3)
p4 = array.get(pivPrice, i4)
b4 = array.get(pivBar, i4)
bullImpulse = t3 == -1 and t4 == 1 and p4 > p2 and p3 > p1
bearImpulse = t3 == 1 and t4 == -1 and p4 < p2 and p3 < p1
if bullImpulse
mode := "BULL STRUCTURE FLOW"
ote886 = p4 - (p4 - p3) * 0.886
tp618 = p4 - (p4 - p3) * 0.618
boxSize = math.abs(p4 - p3) * 0.025
if showOTE
addLine(b4, ote886, bar_index + extendBars, ote886, oteCol, line.style_dashed, 2)
addBox(b4, ote886 + boxSize, bar_index + extendBars, ote886 - boxSize, oteCol)
addLabel(bar_index + extendBars, ote886, "OTE 0.886", oteCol, true)
if showTarget
addLine(b4, tp618, bar_index + extendBars, tp618, tpCol, line.style_dashed, 2)
addLabel(bar_index + extendBars, tp618, "TARGET 0.618", tpCol, false)
if bearImpulse
mode := "BEAR STRUCTURE FLOW"
ote886 = p4 + (p3 - p4) * 0.886
tp618 = p4 + (p3 - p4) * 0.618
boxSize = math.abs(p3 - p4) * 0.025
if showOTE
addLine(b4, ote886, bar_index + extendBars, ote886, oteCol, line.style_dashed, 2)
addBox(b4, ote886 + boxSize, bar_index + extendBars, ote886 - boxSize, oteCol)
addLabel(bar_index + extendBars, ote886, "OTE 0.886", oteCol, false)
if showTarget
addLine(b4, tp618, bar_index + extendBars, tp618, tpCol, line.style_dashed, 2)
addLabel(bar_index + extendBars, tp618, "TARGET 0.618", tpCol, true)
//━━━━━━━━━━━━ PANEL
var table pan = table.new(position.top_right, 2, 3, border_width=1)
if barstate.islast
table.cell(pan, 0, 0, "OTE", text_color=color.white, bgcolor=color.black)
table.cell(pan, 1, 0, "STRUCTURE FLOW", text_color=oteCol, bgcolor=color.black)
table.cell(pan, 0, 1, "Mode", text_color=color.white)
table.cell(pan, 1, 1, mode, text_color=mode == "BULL STRUCTURE FLOW" ? bullCol : mode == "BEAR STRUCTURE FLOW" ? bearCol : grayCol)
table.cell(pan, 0, 2, "Swings", text_color=color.white)
table.cell(pan, 1, 2, str.tostring(array.size(pivType)), text_color=color.white)
OTE Structure Flow, piyasa yapısını, impulsif hareketleri ve optimal geri çekilme bölgelerini görselleştirmek için tasarlanmış yapısal Fibonacci haritalama aracıdır.
İndikatör, grafik üzerinde sürekli olarak Higher High (HH), Higher Low (HL), Lower High (LH) ve Lower Low (LL) yapılarını tespit ederek canlı bir piyasa yapısı haritası oluşturur.
Manuel Fibonacci çizimlerinden farklı olarak sistem, en son geçerli impulsif hareketi otomatik olarak takip eder ve buna bağlı geri çekilme ile devam hedeflerini hesaplar.
Temel Mantık:
• Swing tepe ve diplerden piyasa yapısı oluşturulur.
• Yapısal ilerleme doğrulandığında impulsif hareket belirlenir.
• Son impulsif hareket üzerinden Fibonacci tabanlı OTE (0.886) bölgeleri hesaplanır.
• Gerekli yapısal şartlar oluştuğunda Fibonacci 0.618 devam hedefleri otomatik olarak oluşturulur.
• Dinamik regresyon tabanlı Gravity Line piyasanın yönsel akışını görselleştirir.
Bu indikatör doğrudan AL veya SAT sinyali üretmez.
Bunun yerine, fiyat yapısını, geri çekilmeleri ve potansiyel devam hedeflerini analiz etmek için objektif bir yapısal harita sunar.
Ana Bileşenler:
• HH / HL / LH / LL Yapı Haritası
• İmpuls Tespiti
• OTE 0.886 Bölgeleri
• Fibonacci 0.618 Hedefleri
• Dinamik Gravity Flow
• Canlı Yapısal Görselleştirme
Gerekli yapısal şartlar oluştuğunda sistem otomatik olarak Fibonacci tabanlı OTE bölgelerini ve hedef seviyelerini hesaplayarak grafik üzerinde gösterir.
Indicador Pine Script®






















