PHP Code:
//@version=6
indicator('EĞİTİM ÇALIŞMASIDIR. ASLA YATIRIM TAVSİYESİ OLARAK KULLANILAMAZ. YATIRIM TAVSİYESİ DEĞİLDİR. @yörük@ 2026', overlay = true, max_lines_count = 500, max_boxes_count = 500)
// --- 1. VISUAL SETTINGS ---
i_boxColor = input.color(color.new(#787b86, 92), 'Range Background', group = 'Visuals')
i_gpBullishColor = input.color(color.new(#4caf50, 60), 'Bullish GP Color', group = 'Visuals')
i_gpBearishColor = input.color(color.new(#f44336, 60), 'Bearish GP Color', group = 'Visuals')
i_liqColor = input.color(color.new(#ffeb3b, 85), 'Liquidity Zones Color', group = 'Visuals')
i_lineColor = input.color(color.white, 'Boundary Line Color', group = 'Visuals')
i_whiteText = color.white
// Range Settings
i_autoFit = input.bool(true, 'Auto-Fit Box to last high and low', group = 'Range Settings')
i_lookback = input.int(100, 'Lookback Period', minval = 2, group = 'Range Settings')
i_offsetR = input.int(10, 'Box Offset Right', minval = 0, group = 'Range Settings')
// FVG Settings
i_showFVG = input.bool(true, 'Show Fair Value Gaps (FVG)', group = 'FVG Settings')
i_fvgLen = input.int(10, 'FVG Extension (Bars)', minval = 1, group = 'FVG Settings')
i_bullFVGColor = input.color(color.new(#4caf4f, 100), 'Bullish FVG Color', group = 'FVG Settings')
i_bearFVGColor = input.color(color.new(#f44336, 100), 'Bearish FVG Color', group = 'FVG Settings')
i_showLabels = input.bool(true, 'Show Price Lines & Labels', group = 'Visuals')
// --- 2. CORE CALCULATIONS ---
int hOff = ta.highestbars(high, i_lookback)
int lOff = ta.lowestbars(low, i_lookback)
float rHigh = high[-hOff]
float rLow = low[-lOff]
float rDiff = rHigh - rLow
// KORREKTUR: anchorBar nutzt nun die korrekten Identifier lOff und hOff
int anchorBar = i_autoFit ? bar_index + math.min(hOff, lOff) : bar_index - i_lookback
float bUp = rLow + rDiff * 0.382
float bLo = rLow + rDiff * 0.35
float sUp = rHigh - rDiff * 0.35
float sLo = rHigh - rDiff * 0.382
// --- 3. FVG LOGIC ---
if i_showFVG
if low > high[2]
box.new(bar_index[1], low, bar_index + i_fvgLen, high[2], bgcolor = i_bullFVGColor, border_color = na)
if high < low[2]
box.new(bar_index[1], high, bar_index + i_fvgLen, low[2], bgcolor = i_bearFVGColor, border_color = na)
// --- 4. VISUALS (BOXES) ---
var box b_Range = box.new(na, na, na, na, xloc = xloc.bar_index, bgcolor = i_boxColor, border_color = color.gray)
var box b_Bullish = box.new(na, na, na, na, xloc = xloc.bar_index, bgcolor = i_gpBullishColor, border_color = na, text = 'LONG ALAN', text_color = color.white, text_size = size.small)
var box b_Bearish = box.new(na, na, na, na, xloc = xloc.bar_index, bgcolor = i_gpBearishColor, border_color = na, text = 'SHORT ALAN', text_color = color.white, text_size = size.small)
var box b_LiqTop = box.new(na, na, na, na, xloc = xloc.bar_index, bgcolor = i_liqColor, border_color = na, text = ' SHORT STOP ALAN', text_color = i_whiteText, text_size = size.small)
var box b_LiqBot = box.new(na, na, na, na, xloc = xloc.bar_index, bgcolor = i_liqColor, border_color = na, text = 'LONG STOP ALAN', text_color = i_whiteText, text_size = size.small)
var array<line> l_levels = array.new_line()
var array<label> lb_prices = array.new_label()
if barstate.isfirst
for i = 0 to 7 by 1
array.push(l_levels, line.new(na, na, na, na, xloc = xloc.bar_index, color = i_lineColor))
array.push(lb_prices, label.new(na, na, '', xloc = xloc.bar_index, color = color.new(color.black, 100), textcolor = i_lineColor, size = size.normal, style = label.style_label_left))
if barstate.islast
int rightBar = bar_index + i_offsetR
box.set_lefttop(b_Range, anchorBar, rHigh)
box.set_rightbottom(b_Range, rightBar, rLow)
box.set_lefttop(b_Bullish, anchorBar, bUp)
box.set_rightbottom(b_Bullish, rightBar, bLo)
box.set_lefttop(b_Bearish, anchorBar, sUp)
box.set_rightbottom(b_Bearish, rightBar, sLo)
box.set_lefttop(b_LiqTop, anchorBar, rHigh)
box.set_rightbottom(b_LiqTop, rightBar, rHigh - rDiff * 0.05)
box.set_lefttop(b_LiqBot, anchorBar, rLow + rDiff * 0.05)
box.set_rightbottom(b_LiqBot, rightBar, rLow)
if i_showLabels
array<float> p_vals = array.from(rHigh, rHigh - rDiff * 0.05, sUp, sLo, bUp, bLo, rLow + rDiff * 0.05, rLow)
for i = 0 to 7 by 1
float v = array.get(p_vals, i)
line.set_xy1(array.get(l_levels, i), anchorBar, v)
line.set_xy2(array.get(l_levels, i), rightBar, v)
label.set_xy(array.get(lb_prices, i), rightBar, v)
label.set_text(array.get(lb_prices, i), ' ' + str.tostring(v, format.mintick))
// --- 5. SIGNAL LOGIC ---
bool sfpShort = high > rHigh and close < rHigh
bool sfpLong = low < rLow and close > rLow
var bool tBear = false
var bool tBull = false
if high >= sLo and low <= sUp
tBear := true
tBear
if low <= bUp and high >= bLo
tBull := true
tBull
bool pL = close[2] < open[2] and close[1] > open[1] and close > high[1]
bool pS = close[2] > open[2] and close[1] < open[1] and close < low[1]
bool signalLongOnly = tBull and pL
bool signalShortOnly = tBear and pS
if signalShortOnly or tBear and high > rHigh
tBear := false
tBear
if signalLongOnly or tBull and low < rLow
tBull := false
tBull
// --- 6. ALERTS ---
alertcondition(ta.crossover(high, sLo) or ta.crossunder(low, bUp), '1. GP Touch', 'Price entered Golden Pocket.')
alertcondition(signalLongOnly, '2. Long: 2-Candle Pattern', 'Long confirmed in BULLISH GP.')
alertcondition(signalShortOnly, '3. Short: 2-Candle Pattern', 'Short confirmed in BEARISH GP.')
alertcondition(sfpLong, '4. SFP Long (Liquidity Grab)', 'SFP: Liquidity grab below Low.')
alertcondition(sfpShort, '5. SFP Short (Liquidity Grab)', 'SFP: Liquidity grab above High.')
/////////////////////////
// ─────────────────────────────
// SETTINGS
// ─────────────────────────────
grp_logic = "Logic Settings"
backBars = input.int(300, "Bars to Apply", minval = 50, group = grp_logic, tooltip = "Historical bars scanned for pivots.")
pivotSrc = input.string("High/Low", "Pivot Source", options = ["High/Low", "Close"], group = grp_logic)
pivotStrength = input.int(10, "Pivot Strength", minval = 5, maxval = 15, group = grp_logic, tooltip = "Range limited to 5-15.")
minTouches = input.int(3, "Min Pivot Confirmation", minval = 2, maxval = 8, group = grp_logic, tooltip = "Range limited to 2-8.")
grp_style = "Styling"
resColor = input.color(color.red, "Resistance Color", group = grp_style)
supColor = input.color(color.green, "Support Color", group = grp_style)
transpSR = input.int(50, "Zone Transparency", minval = 0, maxval = 100, group = grp_style)
// ─────────────────────────────
// INTERNAL CONSTANTS (Hidden Settings)
// ─────────────────────────────
float FIXED_ATR_MULT = 0.5 // Fixed Zone Width
int FIXED_STABILITY = 5 // Fixed Stability Buffer (Bars)
// ─────────────────────────────
// DATA STORAGE
// ─────────────────────────────
float atr = ta.atr(14)
float maxThreshold = atr * FIXED_ATR_MULT
float srcHigh = pivotSrc == "Close" ? close : high
float srcLow = pivotSrc == "Close" ? close : low
var float[] phPrices = array.new_float(0)
var int[] phBarIdx = array.new_int(0)
var float[] plPrices = array.new_float(0)
var int[] plBarIdx = array.new_int(0)
var line[] allLines = array.new_line(0)
var linefill[] allFills = array.new_linefill(0)
// Alert States
var int[] zoneStates = array.from(0, 0)
var float[] zoneTops = array.from(0.0, 0.0)
var float[] zoneBots = array.from(0.0, 0.0)
// ─────────────────────────────
// PIVOT COLLECTION
// ─────────────────────────────
ph = ta.pivothigh(srcHigh, pivotStrength, pivotStrength)
pl = ta.pivotlow(srcLow, pivotStrength, pivotStrength)
if not na(ph)
array.push(phPrices, ph)
array.push(phBarIdx, bar_index - pivotStrength)
if not na(pl)
array.push(plPrices, pl)
array.push(plBarIdx, bar_index - pivotStrength)
// ─────────────────────────────
// FILTERING & DRAWING LOGIC
// ─────────────────────────────
clearDrawings() =>
if array.size(allLines) > 0
for l in allLines
line.delete(l)
array.clear(allLines)
if array.size(allFills) > 0
for f in allFills
linefill.delete(f)
array.clear(allFills)
findClosestZone(float[] pPrices, int[] pIndices, color col, bool isResistance) =>
int size = array.size(pPrices)
int lookbackThreshold = last_bar_index - backBars
int stabilityThreshold = last_bar_index - FIXED_STABILITY
// Logic: Look for the zone with the smallest distance to the current price
float minDistanceToPrice = 1e10
// Variables to store the winner
int bestP1x = 0
float bestP1y = 0.0
float bestSlopeVal = 0.0
float bestMaxUp = 0.0
float bestMaxDown = 0.0
bool foundAny = false
if size >= minTouches
for i = 0 to size - 2
if array.get(pIndices, i) < lookbackThreshold
continue
float p1_y = array.get(pPrices, i)
int p1_x = array.get(pIndices, i)
for j = i + 1 to size - 1
float p2_y = array.get(pPrices, j)
int p2_x = array.get(pIndices, j)
float currentSlope = (p2_y - p1_y) / (p2_x - p1_x)
int touches = 0
bool isBroken = false
float currentMaxUp = 0.0
float currentMaxDown = 0.0
for k = 0 to size - 1
int pk_x = array.get(pIndices, k)
if pk_x < p1_x
continue
float pk_y = array.get(pPrices, k)
float expected_y = p1_y + currentSlope * (pk_x - p1_x)
float diff = pk_y - expected_y
if math.abs(diff) <= maxThreshold
touches += 1
if diff > currentMaxUp
currentMaxUp := diff
if diff < currentMaxDown
currentMaxDown := diff
// Stability Breach Logic: Only discard if breach is OLDER than fixed buffer (5 bars)
if pk_x < stabilityThreshold
if isResistance and diff > maxThreshold
isBroken := true
break
if not isResistance and diff < -maxThreshold
isBroken := true
break
if touches >= minTouches and not isBroken
// CALCULATE DISTANCE TO CURRENT PRICE
float current_projected_y = p1_y + currentSlope * (last_bar_index - p1_x)
float dist = math.abs(current_projected_y - close)
// IF this valid line is CLOSER than the previous best, keep it
if dist < minDistanceToPrice
minDistanceToPrice := dist
bestP1x := p1_x
bestP1y := p1_y
bestSlopeVal := currentSlope
bestMaxUp := currentMaxUp
bestMaxDown := currentMaxDown
foundAny := true
if foundAny
float endY = bestP1y + bestSlopeVal * (last_bar_index - bestP1x)
l_top = line.new(bestP1x, bestP1y + bestMaxUp, last_bar_index, endY + bestMaxUp, color=color.new(col, 50), extend=extend.right)
l_bot = line.new(bestP1x, bestP1y + bestMaxDown, last_bar_index, endY + bestMaxDown, color=color.new(col, 50), extend=extend.right)
fill = linefill.new(l_top, l_bot, color.new(col, transpSR))
array.push(allLines, l_top)
array.push(allLines, l_bot)
array.push(allFills, fill)
int idx = isResistance ? 0 : 1
array.set(zoneTops, idx, endY + bestMaxUp)
array.set(zoneBots, idx, endY + bestMaxDown)
foundAny
// Execute
clearDrawings()
findClosestZone(phPrices, phBarIdx, resColor, true)
findClosestZone(plPrices, plBarIdx, supColor, false)
// ─────────────────────────────
// ALERT LOGIC
// ─────────────────────────────
bool alertBreakout = false
bool alertTouch = false
checkAlerts(int idx) =>
float top = array.get(zoneTops, idx)
float bot = array.get(zoneBots, idx)
int prevState = array.get(zoneStates, idx)
bool bOut = false
bool tCh = false
if top > 0
if close > top
if prevState == -1
bOut := true
array.set(zoneStates, idx, 1)
else if close < bot
if prevState == 1
bOut := true
array.set(zoneStates, idx, -1)
if (high >= bot and high <= top) or (low <= top and low >= bot)
tCh := true
[bOut, tCh]
[rB, rT] = checkAlerts(0)
[sB, sT] = checkAlerts(1)
alertBreakout := rB or sB
alertTouch := rT or sT
alertcondition(alertBreakout, "Zone Breakout", "Price broke the zone")
alertcondition(alertTouch, "Zone Touch", "Price touched the zone")
//////////////////////
// -----------------------------------------------------------------------------
// SETTINGS
// -----------------------------------------------------------------------------
grp_sett = "General Settings"
len = input.int(5, "Short-Term Sensitivity", minval=2, group=grp_sett)
color_up = input.color(#089981, "Historical Wave Color", group=grp_sett)
grp_cast = "Short-Term Forecast"
show_ext_bull = input.bool(true, "Show Bullish Extension (Up)", group=grp_cast)
show_ext_bear = input.bool(true, "Show Bearish Extension (Down)", group=grp_cast)
color_cont = input.color(#ff9800, "Extension Color", group=grp_cast)
link_scenarios = input.bool(false, "Start Reversal after Extension?", group=grp_cast)
show_reversal = input.bool(true, "Show Reversal", group=grp_cast)
color_rev = input.color(#2962ff, "Reversal Color", group=grp_cast)
grp_macro = "Long-Term Forecast (1 Year)"
show_macro = input.bool(false, "Show 1-Year Macro Projection", group=grp_macro)
len_macro = input.int(21, "Macro Sensitivity", minval=10, group=grp_macro)
macro_spacing = input.int(50, "Bars per Wave (Time)", minval=5, group=grp_macro)
color_macro = input.color(#9c27b0, "Macro Color", group=grp_macro)
grp_vis = "Dashboard & Visuals"
show_table = input.bool(true, "Show Target Table", group=grp_vis)
show_labels = input.bool(true, "Show Chart Labels", group=grp_vis)
show_grid = input.bool(true, "Show Horizontal Fib Levels", group=grp_vis)
show_inv = input.bool(true, "Show Invalidation Line", group=grp_vis)
show_div = input.bool(true, "Show RSI Divergence (⚡)", group=grp_vis, tooltip="Highlights setups where Price and RSI disagree (Divergence), indicating a stronger reversal signal.")
// -----------------------------------------------------------------------------
// STORAGE
// -----------------------------------------------------------------------------
var float[] pPrices = array.new_float()
var int[] pBars = array.new_int()
var bool[] pDirs = array.new_bool()
var float[] pRSI = array.new_float() // NEW: Store RSI values
var float[] pPricesM = array.new_float()
var int[] pBarsM = array.new_int()
var bool[] pDirsM = array.new_bool()
var line[] ghostLines = array.new_line()
var label[] ghostLabels = array.new_label()
var table infoTable = table.new(position.top_right, 4, 20, border_width = 1)
// -----------------------------------------------------------------------------
// FUNCTIONS
// -----------------------------------------------------------------------------
// Updated to store RSI
addPivot(float p, int b, bool d, float r, float[] prices, int[] bars, bool[] dirs, float[] rsis) =>
array.unshift(prices, p)
array.unshift(bars, b)
array.unshift(dirs, d)
array.unshift(rsis, r) // Store RSI
if array.size(prices) > 20
array.pop(prices)
array.pop(bars)
array.pop(dirs)
array.pop(rsis)
// Overload for Macro (no RSI tracking needed yet)
addPivotMacro(float p, int b, bool d, float[] prices, int[] bars, bool[] dirs) =>
array.unshift(prices, p)
array.unshift(bars, b)
array.unshift(dirs, d)
if array.size(prices) > 20
array.pop(prices)
array.pop(bars)
array.pop(dirs)
drawPred(int t1, float p1, int t2, float p2, string txt, string fib, color col, int width) =>
l = line.new(t1, p1, t2, p2, color=col, style=line.style_dashed, width=width)
array.push(ghostLines, l)
if show_grid
l_hor = line.new(t2, p2, t2 + 10, p2, color=color.new(col, 50), style=line.style_dotted, width=1)
array.push(ghostLines, l_hor)
if show_labels
lbl_text = txt + "\n" + str.tostring(p2, format.mintick)
lb = label.new(t2, p2, text=lbl_text, color=color.new(color.white, 100), textcolor=col, style=label.style_label_left, size=size.small)
array.push(ghostLabels, lb)
fillRow(int r, string t, string f, float p, color c) =>
pct_diff = (p - close) / close * 100
pct_str = (pct_diff > 0 ? "+" : "") + str.tostring(pct_diff, "#.##") + "%"
pct_col = pct_diff >= 0 ? #089981 : #f23645
table.cell(infoTable, 0, r, t, text_color=color.white, bgcolor=c, text_size=size.small)
table.cell(infoTable, 1, r, f, text_color=color.white, bgcolor=color.new(c, 20), text_size=size.small)
table.cell(infoTable, 2, r, str.tostring(p, format.mintick), text_color=color.white, bgcolor=color.new(color.black, 20), text_size=size.small)
table.cell(infoTable, 3, r, pct_str, text_color=pct_col, bgcolor=color.new(color.black, 20), text_size=size.small)
// -----------------------------------------------------------------------------
// MAIN LOGIC
// -----------------------------------------------------------------------------
// Calculate RSI for Divergence Checks
my_rsi = ta.rsi(close, 14)
ph77 = ta.pivothigh(high, len, len)
pl77 = ta.pivotlow(low, len, len)
if not na(ph77)
// Pass RSI at the time of the pivot (offset by len)
addPivot(ph77, bar_index[len], true, my_rsi[len], pPrices, pBars, pDirs, pRSI)
if not na(pl77)
addPivot(pl77, bar_index[len], false, my_rsi[len], pPrices, pBars, pDirs, pRSI)
phM = ta.pivothigh(high, len_macro, len_macro)
plM = ta.pivotlow(low, len_macro, len_macro)
if not na(phM)
addPivotMacro(phM, bar_index[len_macro], true, pPricesM, pBarsM, pDirsM)
if not na(plM)
addPivotMacro(plM, bar_index[len_macro], false, pPricesM, pBarsM, pDirsM)
if (not na(ph77) or not na(pl77)) and array.size(pPrices) > 1
p1_val = array.get(pPrices, 0)
p1_bar = array.get(pBars, 0)
p2_val = array.get(pPrices, 1)
p2_bar = array.get(pBars, 1)
line.new(p2_bar, p2_val, p1_bar, p1_val, color=color_up, width=2)
// 3. PREDICTIVE LOGIC & TABLE
if barstate.islast
for l in ghostLines
line.delete(l)
for lb in ghostLabels
label.delete(lb)
array.clear(ghostLines)
array.clear(ghostLabels)
table.clear(infoTable, 0, 0, 3, 19)
if show_table
table.cell(infoTable, 0, 0, "Wave", bgcolor=color.gray, text_color=color.white)
table.cell(infoTable, 1, 0, "Fib", bgcolor=color.gray, text_color=color.white)
table.cell(infoTable, 2, 0, "Target", bgcolor=color.gray, text_color=color.white)
table.cell(infoTable, 3, 0, "% +/-", bgcolor=color.gray, text_color=color.white)
int tbl_row = 1
if array.size(pPrices) > 0
last_conf_val = array.get(pPrices, 0)
last_conf_bar = array.get(pBars, 0)
last_conf_dir = array.get(pDirs, 0)
int bars_elapsed = bar_index - last_conf_bar
float live_pivot_val = 0.0
int live_pivot_bar = 0
bool live_pivot_dir = bool(na)
float live_pivot_rsi = 50.0 // Default
if last_conf_dir
lowest_val = 1000000.0
lowest_idx = 0
for i = 0 to bars_elapsed
if low[i] < lowest_val
lowest_val := low[i]
lowest_idx := bar_index[i]
live_pivot_rsi := my_rsi[i] // Capture RSI at lowest point
live_pivot_val := lowest_val
live_pivot_bar := lowest_idx
live_pivot_dir := false
else
highest_val = 0.0
highest_idx = 0
for i = 0 to bars_elapsed
if high[i] > highest_val
highest_val := high[i]
highest_idx := bar_index[i]
live_pivot_rsi := my_rsi[i] // Capture RSI at highest point
live_pivot_val := highest_val
live_pivot_bar := highest_idx
live_pivot_dir := true
float vol = math.abs(last_conf_val - live_pivot_val)
if vol == 0
vol := syminfo.mintick * 100
float rev_start_price = live_pivot_val
int rev_start_bar = live_pivot_bar
// =========================================================
// SCENARIO 1: EXTENSION
// =========================================================
float pExt = na
int tExt = bar_index + 10
bool drawing_ext = false
if not live_pivot_dir
if show_ext_bear
calc_price = live_pivot_val - (vol * 0.5)
pExt := math.max(0.01, calc_price)
drawPred(live_pivot_bar, live_pivot_val, tExt, pExt, "(Ext)", "0.5", color_cont, 2)
if show_table
fillRow(tbl_row, "Bear Ext", "0.5 Vol", pExt, color_cont)
tbl_row += 1
drawing_ext := true
else
if show_ext_bull
pExt := live_pivot_val + (vol * 0.5)
drawPred(live_pivot_bar, live_pivot_val, tExt, pExt, "(Ext)", "0.5", color_cont, 2)
if show_table
fillRow(tbl_row, "Bull Ext", "0.5 Vol", pExt, color_cont)
tbl_row += 1
drawing_ext := true
if link_scenarios and drawing_ext
rev_start_price := pExt
rev_start_bar := tExt
// =========================================================
// SCENARIO 2: REVERSAL + RSI DIVERGENCE CHECK
// =========================================================
if show_reversal
int t_step = 5
// --- RSI DIVERGENCE LOGIC ---
bool has_div = false
// Check if we have history
if array.size(pPrices) > 1
// If Live is Low, compare to Previous Low (index 1)
if not live_pivot_dir
prev_low_val = array.get(pPrices, 1)
prev_low_rsi = array.get(pRSI, 1)
// BULLISH DIV: Lower Price + Higher RSI
if live_pivot_val < prev_low_val and live_pivot_rsi > prev_low_rsi
has_div := true
// If Live is High, compare to Previous High (index 1)
else
prev_high_val = array.get(pPrices, 1)
prev_high_rsi = array.get(pRSI, 1)
// BEARISH DIV: Higher Price + Lower RSI
if live_pivot_val > prev_high_val and live_pivot_rsi < prev_high_rsi
has_div := true
// Invalidation Line
if show_inv
inv_col = color.red
inv_y = rev_start_price
l_inv = line.new(rev_start_bar, inv_y, rev_start_bar + 30, inv_y, color=inv_col, width=2, style=line.style_solid)
array.push(ghostLines, l_inv)
// Add Lightning Bolt if Divergence Detected
inv_txt = "INV" + (has_div and show_div ? " ⚡" : "")
inv_txt_col = has_div and show_div ? color.yellow : inv_col
if show_labels
lb_inv = label.new(rev_start_bar + 30, inv_y, text=inv_txt, color=color.new(color.white, 100), textcolor=inv_txt_col, style=label.style_label_left, size=size.small)
array.push(ghostLabels, lb_inv)
if show_table
fillRow(tbl_row, "INVALIDATION", (has_div and show_div ? "DIV ⚡" : "Start"), inv_y, color.red)
tbl_row += 1
if not live_pivot_dir
p1 = math.max(0.01, rev_start_price + (vol * 0.382))
t1 = rev_start_bar + 5
drawPred(rev_start_bar, rev_start_price, t1, p1, "(1)", "0.382", color_rev, 2)
if show_table
fillRow(tbl_row, "Wave 1", "0.382", p1, color_rev)
tbl_row += 1
p2 = math.max(0.01, p1 - ((p1 - rev_start_price) * 0.618))
t2 = t1 + t_step
drawPred(t1, p1, t2, p2, "(2)", "0.618", color_rev, 2)
if show_table
fillRow(tbl_row, "Wave 2", "0.618", p2, color_rev)
tbl_row += 1
p3 = math.max(0.01, p2 + ((p1 - rev_start_price) * 1.618))
t3 = t2 + t_step
drawPred(t2, p2, t3, p3, "(3)", "1.618", color_rev, 2)
if show_table
fillRow(tbl_row, "Wave 3", "1.618", p3, color_rev)
tbl_row += 1
p4 = math.max(0.01, p3 - ((p3 - p2) * 0.382))
t4 = t3 + t_step
drawPred(t3, p3, t4, p4, "(4)", "0.382", color_rev, 2)
if show_table
fillRow(tbl_row, "Wave 4", "0.382", p4, color_rev)
tbl_row += 1
p5 = math.max(0.01, p4 + (p1 - rev_start_price))
t5 = t4 + t_step
drawPred(t4, p4, t5, p5, "(5)", "1.0", color_rev, 2)
if show_table
fillRow(tbl_row, "Wave 5", "1.0", p5, color_rev)
tbl_row += 1
else
pA = math.max(0.01, rev_start_price - (vol * 0.382))
tA = rev_start_bar + 5
drawPred(rev_start_bar, rev_start_price, tA, pA, "(A)", "0.382", color_rev, 2)
if show_table
fillRow(tbl_row, "Wave A", "0.382", pA, color_rev)
tbl_row += 1
pB = math.max(0.01, pA + ((rev_start_price - pA) * 0.618))
tB = tA + t_step
drawPred(tA, pA, tB, pB, "(B)", "0.618", color_rev, 2)
if show_table
fillRow(tbl_row, "Wave B", "0.618", pB, color_rev)
tbl_row += 1
pC = math.max(0.01, pB - ((rev_start_price - pA) * 1.272))
tC = tB + t_step
drawPred(tB, pB, tC, pC, "(C)", "1.272", color_rev, 2)
if show_table
fillRow(tbl_row, "Wave C", "1.272", pC, color_rev)
tbl_row += 1
// =========================================================
// SCENARIO 3: MACRO
// =========================================================
if show_macro and array.size(pPricesM) > 0
last_M_val = array.get(pPricesM, 0)
last_M_bar = array.get(pBarsM, 0)
last_M_dir = array.get(pDirsM, 0)
int M_elapsed = bar_index - last_M_bar
float live_M_val = 0.0
int live_M_bar = 0
bool live_M_dir = bool(na)
if last_M_dir
lowest_val = 1000000.0
lowest_idx = 0
for i = 0 to M_elapsed
if low[i] < lowest_val
lowest_val := low[i]
lowest_idx := bar_index[i]
live_M_val := lowest_val
live_M_bar := lowest_idx
live_M_dir := false
else
highest_val = 0.0
highest_idx = 0
for i = 0 to M_elapsed
if high[i] > highest_val
highest_val := high[i]
highest_idx := bar_index[i]
live_M_val := highest_val
live_M_bar := highest_idx
live_M_dir := true
float volM = math.abs(last_M_val - live_M_val)
if volM == 0
volM := syminfo.mintick * 100
int t_step_M = macro_spacing
if show_table
table.cell(infoTable, 0, tbl_row, "MACRO (1Y)", bgcolor=color.gray, text_color=color.white)
table.merge_cells(infoTable, 0, tbl_row, 3, tbl_row)
tbl_row += 1
if not live_M_dir
p1 = math.max(0.01, live_M_val + (volM * 0.382))
t1 = live_M_bar + t_step_M
drawPred(live_M_bar, live_M_val, t1, p1, "M(1)", "Start", color_macro, 4)
if show_table
fillRow(tbl_row, "Macro 1", "Start", p1, color_macro)
tbl_row += 1
p2 = math.max(0.01, p1 - ((p1 - live_M_val) * 0.618))
t2 = t1 + t_step_M
drawPred(t1, p1, t2, p2, "M(2)", "0.618", color_macro, 4)
if show_table
fillRow(tbl_row, "Macro 2", "0.618", p2, color_macro)
tbl_row += 1
p3 = math.max(0.01, p2 + ((p1 - live_M_val) * 1.618))
t3 = t2 + t_step_M
drawPred(t2, p2, t3, p3, "M(3)", "1.618", color_macro, 4)
if show_table
fillRow(tbl_row, "Macro 3", "1.618", p3, color_macro)
tbl_row += 1
p4 = math.max(0.01, p3 - ((p3 - p2) * 0.382))
t4 = t3 + t_step_M
drawPred(t3, p3, t4, p4, "M(4)", "0.382", color_macro, 4)
if show_table
fillRow(tbl_row, "Macro 4", "0.382", p4, color_macro)
tbl_row += 1
p5 = math.max(0.01, p4 + (p1 - live_M_val))
t5 = t4 + t_step_M
drawPred(t4, p4, t5, p5, "M(5)", "1.0", color_macro, 4)
if show_table
fillRow(tbl_row, "Macro 5", "1.0", p5, color_macro)
tbl_row += 1
else
pA = math.max(0.01, live_M_val - (volM * 0.382))
tA = live_M_bar + t_step_M
drawPred(live_M_bar, live_M_val, tA, pA, "M(A)", "Start", color_macro, 4)
if show_table
fillRow(tbl_row, "Macro A", "Start", pA, color_macro)
tbl_row += 1
pB = math.max(0.01, pA + ((live_M_val - pA) * 0.618))
tB = tA + t_step_M
drawPred(tA, pA, tB, pB, "M(B)", "0.618", color_macro, 4)
if show_table
fillRow(tbl_row, "Macro B", "0.618", pB, color_macro)
tbl_row += 1
pC = math.max(0.01, pB - ((live_M_val - pA) * 1.272))
tC = tB + t_step_M
drawPred(tB, pB, tC, pC, "M(C)", "1.272", color_macro, 4)
if show_table
fillRow(tbl_row, "Macro C", "1.272", pC, color_macro)
tbl_row += 1
Yer İmleri