OPEN-SOURCE SCRIPT
TomiChoro SPY-OPTIONS 5m

//version=5
indicator("OM SPY A+ Confirm (Fib 1H + Filters)", shorttitle="OM A+", overlay=true, max_labels_count=500, max_lines_count=500)
// ══════════════════════════════════════════════════════════════════════════════
// ORIGINAL OptionsMillionaire BASE (mantiene toda la funcionalidad)
// ══════════════════════════════════════════════════════════════════════════════
priceSource = input(close, title="Price Source For The Moving Averages", group="General")
IgnoreExtendedHours = input(true, title="Ignore Extended Hours", group="General")
resolution = timeframe.period
price = request.security(syminfo.tickerid, resolution, priceSource)
shortMAPeriod = input.int(8, title="Short Moving Average Period & Type:", group="Crossover Moving Averages", inline="short")
shortMAType = input.string("EMA", title="", options=["EMA","SMA","WMA","HMA","ALMA","LIN","ZLMA"], group="Crossover Moving Averages", inline="short")
longMAPeriod = input.int(21, title=" Long Moving Average Period & Type :", group="Crossover Moving Averages", inline="long")
longMAType = input.string("EMA", title="", options=["EMA","SMA","WMA","HMA","ALMA","LIN","ZLMA"], group="Crossover Moving Averages", inline="long")
i_timeframe_signal = input.timeframe("", title="Crossover MAs Timeframe", group="Crossover Moving Averages")
useTextLabels = input.bool(true, title="Use Text-Based Crossover Labels?", group="Crossover Moving Averages")
showBonusMA1 = input.bool(true, title="Bonus MA", group="Bonus Moving Averages", inline="bma1")
bonusMA1Period = input.int(34, title="", group="Bonus Moving Averages", inline="bma1")
bonus1MAType = input.string("EMA", title="", options=["EMA","SMA","WMA","HMA","ALMA","LIN","ZLMA"], group="Bonus Moving Averages", inline="bma1")
i_timeframe_bma1 = input.timeframe("", title="", group="Bonus Moving Averages", inline="bma1")
showBonusMA2 = input.bool(false, title="Bonus MA", group="Bonus Moving Averages", inline="bma2")
bonusMA2Period = input.int(50, title="", group="Bonus Moving Averages", inline="bma2")
bonus2MAType = input.string("SMA", title="", options=["EMA","SMA","WMA","HMA","ALMA","LIN","ZLMA"], group="Bonus Moving Averages", inline="bma2")
i_timeframe_bma2 = input.timeframe("", title="", group="Bonus Moving Averages", inline="bma2")
showBonusMA3 = input.bool(false, title="Bonus MA", group="Bonus Moving Averages", inline="bma3")
bonusMA3Period = input.int(100, title="", group="Bonus Moving Averages", inline="bma3")
bonus3MAType = input.string("SMA", title="", options=["EMA","SMA","WMA","HMA","ALMA","LIN","ZLMA"], group="Bonus Moving Averages", inline="bma3")
i_timeframe_bma3 = input.timeframe("", title="", group="Bonus Moving Averages", inline="bma3")
ZLMASmooth = 3
f_security(_sym, _res, _src) =>
request.security(_sym, _res, _src[barstate.isrealtime ? 1 : 0], barmerge.gaps_off, barmerge.lookahead_off)[barstate.isrealtime ? 0 : 1]
ticker = ticker.new(syminfo.prefix, syminfo.ticker, IgnoreExtendedHours ? session.regular : syminfo.session)
// MA calculation
f_ma(_src, _len, _type) =>
switch _type
"SMA" => ta.sma(_src, _len)
"EMA" => ta.ema(_src, _len)
"WMA" => ta.wma(_src, _len)
"HMA" => ta.hma(_src, _len)
"ALMA" => ta.alma(_src, _len, 0.85, 6)
"LIN" => ta.linreg(_src, _len, 0)
"ZLMA" => (2 * ta.wma(ta.wma(_src, _len), ZLMASmooth)) - ta.wma(ta.wma(ta.wma(_src, _len), ZLMASmooth), _len)
=> ta.ema(_src, _len)
short = f_security(ticker, i_timeframe_signal, f_ma(price, shortMAPeriod, shortMAType))
long = f_security(ticker, i_timeframe_signal, f_ma(price, longMAPeriod, longMAType))
bonus1 = f_security(ticker, i_timeframe_bma1, f_ma(price, bonusMA1Period, bonus1MAType))
bonus2 = f_security(ticker, i_timeframe_bma2, f_ma(price, bonusMA2Period, bonus2MAType))
bonus3 = f_security(ticker, i_timeframe_bma3, f_ma(price, bonusMA3Period, bonus3MAType))
// Crossover signals (base)
Bull = ta.crossover(short, long)
Bear = ta.crossunder(short, long)
trendColor = short >= long ? color.new(color.red, 85) : color.new(color.blue, 85)
MA1 = plot(short, title="Short Period Moving Average", color=#FF00FF, linewidth=2)
MA2 = plot(long, title="Long Period Moving Average", color=#00FF00, linewidth=1)
fill(MA1, MA2, color=trendColor, title="Short/Long Divergence Fill")
plot(showBonusMA1 ? bonus1 : na, title="Bonus Moving Average 1", color=#FFFF00, linewidth=1)
plot(showBonusMA2 ? bonus2 : na, title="Bonus Moving Average 2", color=#0000FF, linewidth=1)
plot(showBonusMA3 ? bonus3 : na, title="Bonus Moving Average 3", color=#FFFFFF, linewidth=1)
plotshape(Bull, title="Calls Label", color=color.new(color.green, 25),
textcolor=useTextLabels ? color.white : color.new(color.white, 100),
style=useTextLabels ? shape.labelup : shape.triangleup,
text="Call", location=location.belowbar)
plotshape(Bear, title="Puts Label", color=color.new(color.red, 25),
textcolor=useTextLabels ? color.white : color.new(color.white, 100),
style=useTextLabels ? shape.labeldown : shape.triangledown,
text="Put", location=location.abovebar)
if Bull
alert("Call Alert: 8ema crossed over 21ema", alert.freq_once_per_bar_close)
if Bear
alert("Put Alert: 8ema crossed under 21ema", alert.freq_once_per_bar_close)
// -- VWAP -- //
showVWAP = input.bool(true, title="Show VWAP?", group="VWAP")
vwapSource = input(hlc3, title="VWAP Source", group="VWAP")
vwapAnchor = input.string("Session", title="VWAP Anchor Period", options=["Session", "Week", "Month", "Quarter", "Year", "Decade", "Century"], group="VWAP")
vwapSD1 = input.float(1.00, minval=0, step=0.5, title="Standard Deviation 1", group="VWAP")
vwapSD2 = input.float(2.00, minval=0, step=0.5, title="Standard Deviation 2", group="VWAP")
vwapSD3 = input.float(3.00, minval=0, step=0.5, title="Standard Deviation 3", group="VWAP")
showVWAPSD1Band = input.bool(false, title="Show VWAP Standard Deviation 1?", group="VWAP")
showVWAPSD2Band = input.bool(false, title="Show VWAP Standard Deviation 2?", group="VWAP")
showVWAPSD3Band = input.bool(false, title="Show VWAP Standard Deviation 3?", group="VWAP")
timeChange(period) =>
ret = 0
if period == "Session"
ret := time("D")
if period == "Week"
ret := time("W")
if period == "Month"
ret := time("M")
if period == "Quarter"
ret := time("3M")
if period == "Year"
ret := time("12M")
if period == "Decade"
ret := time("12M") % time("120M") == 0 ? 1 : 0
if period == "Century"
ret := time("12M") % time("1200M") == 0 ? 1 : 0
ret
isNewPeriod = ta.change(timeChange(vwapAnchor))
isFirstBarOfNewPeriod = isNewPeriod and not isNewPeriod[1]
var float vwapSum = 0.0
vwapSum := isFirstBarOfNewPeriod ? vwapSource * volume : vwapSource * volume + vwapSum[1]
var float volumeSum = 0.0
volumeSum := isFirstBarOfNewPeriod ? volume : volume + volumeSum[1]
var float v2Sum = 0.0
v2Sum := isFirstBarOfNewPeriod ? volume * vwapSource * vwapSource : volume * vwapSource * vwapSource + v2Sum[1]
mVWAP = vwapSum / volumeSum
variance = v2Sum / volumeSum - mVWAP * mVWAP
variance := variance < 0 ? 0 : variance
standard_deviation = math.sqrt(variance)
vwapUpperBand1 = mVWAP + (vwapSD1 * standard_deviation)
vwapLowerBand1 = mVWAP - (vwapSD1 * standard_deviation)
vwapUpperBand2 = mVWAP + (vwapSD2 * standard_deviation)
vwapLowerBand2 = mVWAP - (vwapSD2 * standard_deviation)
vwapUpperBand3 = mVWAP + (vwapSD3 * standard_deviation)
vwapLowerBand3 = mVWAP - (vwapSD3 * standard_deviation)
plot(showVWAP ? mVWAP : na, title="VWAP", color=color.orange, linewidth=1)
vwapSD1Plot1 = plot(showVWAPSD1Band ? vwapUpperBand1 : na, title="VWAP SD1 Upper", color=color.gray, linewidth=1)
vwapSD1Plot2 = plot(showVWAPSD1Band ? vwapLowerBand1 : na, title="VWAP SD1 Lower", color=color.gray, linewidth=1)
fill(vwapSD1Plot1, vwapSD1Plot2, color=color.new(color.gray, 90), title="VWAP SD1 Fill")
vwapSD2Plot1 = plot(showVWAPSD2Band ? vwapUpperBand2 : na, title="VWAP SD2 Upper", color=color.gray, linewidth=1)
vwapSD2Plot2 = plot(showVWAPSD2Band ? vwapLowerBand2 : na, title="VWAP SD2 Lower", color=color.gray, linewidth=1)
fill(vwapSD2Plot1, vwapSD2Plot2, color=color.new(color.gray, 85), title="VWAP SD2 Fill")
vwapSD3Plot1 = plot(showVWAPSD3Band ? vwapUpperBand3 : na, title="VWAP SD3 Upper", color=color.gray, linewidth=1)
vwapSD3Plot2 = plot(showVWAPSD3Band ? vwapLowerBand3 : na, title="VWAP SD3 Lower", color=color.gray, linewidth=1)
fill(vwapSD3Plot1, vwapSD3Plot2, color=color.new(color.gray, 80), title="VWAP SD3 Fill")
// ══════════════════════════════════════════════════════════════════════════════
// MÓDULO A+ (Fibonacci 1H + Filtros)
// ══════════════════════════════════════════════════════════════════════════════
// Inputs A+
grpAPlus = "═══ A+ Filters (Fib 1H + VWAP + Volume) ═══"
enableAPlus = input.bool(true, title="Enable A+ Signals", group=grpAPlus)
fibTF = input.timeframe("60", title="Fibonacci Timeframe", group=grpAPlus)
pivotLen = input.int(5, title="Pivot Length (1H swing)", minval=1, group=grpAPlus)
tolPct = input.float(0.05, title="Fib Zone Tolerance (%)", minval=0.0, step=0.01, group=grpAPlus)
volLen = input.int(20, title="Volume SMA Length", minval=1, group=grpAPlus)
showFibLines = input.bool(true, title="Show Fib 0.5 & 0.618 Lines", group=grpAPlus)
// Pivot detection en 1H
f_pivH_1h = request.security(syminfo.tickerid, fibTF, ta.pivothigh(high, pivotLen, pivotLen), lookahead=barmerge.lookahead_off)
f_pivL_1h = request.security(syminfo.tickerid, fibTF, ta.pivotlow(low, pivotLen, pivotLen), lookahead=barmerge.lookahead_off)
var float lastPH = na
var float lastPL = na
var int lastPH_seq = 0
var int lastPL_seq = 0
var int seq = 0
seq := seq + 1
if not na(f_pivH_1h)
lastPH := f_pivH_1h
lastPH_seq := seq
if not na(f_pivL_1h)
lastPL := f_pivL_1h
lastPL_seq := seq
// Swing definition
var float swingA = na
var float swingB = na
var bool swingUp = na
haveBoth = not na(lastPH) and not na(lastPL)
if haveBoth
if lastPH_seq > lastPL_seq
// Upswing: low → high
swingA := lastPL
swingB := lastPH
swingUp := true
else
// Downswing: high → low
swingA := lastPH
swingB := lastPL
swingUp := false
// Fib levels
rng = haveBoth ? math.abs(swingB - swingA) : na
var float fib50 = na
var float fib618 = na
if haveBoth and not na(rng) and rng > 0
if swingUp
fib50 := swingB - rng * 0.50
fib618 := swingB - rng * 0.618
else
fib50 := swingB + rng * 0.50
fib618 := swingB + rng * 0.618
// Zone check (0.5–0.618 con tolerancia en %)
tol = close * (tolPct / 100.0)
zoneLow = math.min(fib50, fib618)
zoneHigh = math.max(fib50, fib618)
inFibZone = haveBoth and not na(zoneLow) and not na(zoneHigh) and (close >= (zoneLow - tol)) and (close <= (zoneHigh + tol))
// VWAP filter
vwapCallOk = close > mVWAP
vwapPutOk = close < mVWAP
// Volume filter
volOk = volume > ta.sma(volume, volLen)
// A+ conditions
AplusCall = enableAPlus and Bull and inFibZone and vwapCallOk and volOk
AplusPut = enableAPlus and Bear and inFibZone and vwapPutOk and volOk
// Plots
plot(showFibLines ? fib50 : na, color=color.yellow, linewidth=1, title="Fib 0.5 (1H)", style=plot.style_circles)
plot(showFibLines ? fib618 : na, color=color.orange, linewidth=1, title="Fib 0.618 (1H)", style=plot.style_circles)
plotshape(AplusCall, title="A+ CALL", style=shape.labelup, text="A+ CALL", color=color.new(color.lime, 0), textcolor=color.black, location=location.belowbar, size=size.small)
plotshape(AplusPut, title="A+ PUT", style=shape.labeldown, text="A+ PUT", color=color.new(color.fuchsia, 0), textcolor=color.white, location=location.abovebar, size=size.small)
// Alerts A+
alertcondition(AplusCall, title="A+ CALL", message="A+ CALL confirmed (OM cross + Fib 1H 0.5-0.618 + VWAP + Volume) on {{ticker}} @ {{close}}")
alertcondition(AplusPut, title="A+ PUT", message="A+ PUT confirmed (OM cross + Fib 1H 0.5-0.618 + VWAP + Volume) on {{ticker}} @ {{close}}")
indicator("OM SPY A+ Confirm (Fib 1H + Filters)", shorttitle="OM A+", overlay=true, max_labels_count=500, max_lines_count=500)
// ══════════════════════════════════════════════════════════════════════════════
// ORIGINAL OptionsMillionaire BASE (mantiene toda la funcionalidad)
// ══════════════════════════════════════════════════════════════════════════════
priceSource = input(close, title="Price Source For The Moving Averages", group="General")
IgnoreExtendedHours = input(true, title="Ignore Extended Hours", group="General")
resolution = timeframe.period
price = request.security(syminfo.tickerid, resolution, priceSource)
shortMAPeriod = input.int(8, title="Short Moving Average Period & Type:", group="Crossover Moving Averages", inline="short")
shortMAType = input.string("EMA", title="", options=["EMA","SMA","WMA","HMA","ALMA","LIN","ZLMA"], group="Crossover Moving Averages", inline="short")
longMAPeriod = input.int(21, title=" Long Moving Average Period & Type :", group="Crossover Moving Averages", inline="long")
longMAType = input.string("EMA", title="", options=["EMA","SMA","WMA","HMA","ALMA","LIN","ZLMA"], group="Crossover Moving Averages", inline="long")
i_timeframe_signal = input.timeframe("", title="Crossover MAs Timeframe", group="Crossover Moving Averages")
useTextLabels = input.bool(true, title="Use Text-Based Crossover Labels?", group="Crossover Moving Averages")
showBonusMA1 = input.bool(true, title="Bonus MA", group="Bonus Moving Averages", inline="bma1")
bonusMA1Period = input.int(34, title="", group="Bonus Moving Averages", inline="bma1")
bonus1MAType = input.string("EMA", title="", options=["EMA","SMA","WMA","HMA","ALMA","LIN","ZLMA"], group="Bonus Moving Averages", inline="bma1")
i_timeframe_bma1 = input.timeframe("", title="", group="Bonus Moving Averages", inline="bma1")
showBonusMA2 = input.bool(false, title="Bonus MA", group="Bonus Moving Averages", inline="bma2")
bonusMA2Period = input.int(50, title="", group="Bonus Moving Averages", inline="bma2")
bonus2MAType = input.string("SMA", title="", options=["EMA","SMA","WMA","HMA","ALMA","LIN","ZLMA"], group="Bonus Moving Averages", inline="bma2")
i_timeframe_bma2 = input.timeframe("", title="", group="Bonus Moving Averages", inline="bma2")
showBonusMA3 = input.bool(false, title="Bonus MA", group="Bonus Moving Averages", inline="bma3")
bonusMA3Period = input.int(100, title="", group="Bonus Moving Averages", inline="bma3")
bonus3MAType = input.string("SMA", title="", options=["EMA","SMA","WMA","HMA","ALMA","LIN","ZLMA"], group="Bonus Moving Averages", inline="bma3")
i_timeframe_bma3 = input.timeframe("", title="", group="Bonus Moving Averages", inline="bma3")
ZLMASmooth = 3
f_security(_sym, _res, _src) =>
request.security(_sym, _res, _src[barstate.isrealtime ? 1 : 0], barmerge.gaps_off, barmerge.lookahead_off)[barstate.isrealtime ? 0 : 1]
ticker = ticker.new(syminfo.prefix, syminfo.ticker, IgnoreExtendedHours ? session.regular : syminfo.session)
// MA calculation
f_ma(_src, _len, _type) =>
switch _type
"SMA" => ta.sma(_src, _len)
"EMA" => ta.ema(_src, _len)
"WMA" => ta.wma(_src, _len)
"HMA" => ta.hma(_src, _len)
"ALMA" => ta.alma(_src, _len, 0.85, 6)
"LIN" => ta.linreg(_src, _len, 0)
"ZLMA" => (2 * ta.wma(ta.wma(_src, _len), ZLMASmooth)) - ta.wma(ta.wma(ta.wma(_src, _len), ZLMASmooth), _len)
=> ta.ema(_src, _len)
short = f_security(ticker, i_timeframe_signal, f_ma(price, shortMAPeriod, shortMAType))
long = f_security(ticker, i_timeframe_signal, f_ma(price, longMAPeriod, longMAType))
bonus1 = f_security(ticker, i_timeframe_bma1, f_ma(price, bonusMA1Period, bonus1MAType))
bonus2 = f_security(ticker, i_timeframe_bma2, f_ma(price, bonusMA2Period, bonus2MAType))
bonus3 = f_security(ticker, i_timeframe_bma3, f_ma(price, bonusMA3Period, bonus3MAType))
// Crossover signals (base)
Bull = ta.crossover(short, long)
Bear = ta.crossunder(short, long)
trendColor = short >= long ? color.new(color.red, 85) : color.new(color.blue, 85)
MA1 = plot(short, title="Short Period Moving Average", color=#FF00FF, linewidth=2)
MA2 = plot(long, title="Long Period Moving Average", color=#00FF00, linewidth=1)
fill(MA1, MA2, color=trendColor, title="Short/Long Divergence Fill")
plot(showBonusMA1 ? bonus1 : na, title="Bonus Moving Average 1", color=#FFFF00, linewidth=1)
plot(showBonusMA2 ? bonus2 : na, title="Bonus Moving Average 2", color=#0000FF, linewidth=1)
plot(showBonusMA3 ? bonus3 : na, title="Bonus Moving Average 3", color=#FFFFFF, linewidth=1)
plotshape(Bull, title="Calls Label", color=color.new(color.green, 25),
textcolor=useTextLabels ? color.white : color.new(color.white, 100),
style=useTextLabels ? shape.labelup : shape.triangleup,
text="Call", location=location.belowbar)
plotshape(Bear, title="Puts Label", color=color.new(color.red, 25),
textcolor=useTextLabels ? color.white : color.new(color.white, 100),
style=useTextLabels ? shape.labeldown : shape.triangledown,
text="Put", location=location.abovebar)
if Bull
alert("Call Alert: 8ema crossed over 21ema", alert.freq_once_per_bar_close)
if Bear
alert("Put Alert: 8ema crossed under 21ema", alert.freq_once_per_bar_close)
// -- VWAP -- //
showVWAP = input.bool(true, title="Show VWAP?", group="VWAP")
vwapSource = input(hlc3, title="VWAP Source", group="VWAP")
vwapAnchor = input.string("Session", title="VWAP Anchor Period", options=["Session", "Week", "Month", "Quarter", "Year", "Decade", "Century"], group="VWAP")
vwapSD1 = input.float(1.00, minval=0, step=0.5, title="Standard Deviation 1", group="VWAP")
vwapSD2 = input.float(2.00, minval=0, step=0.5, title="Standard Deviation 2", group="VWAP")
vwapSD3 = input.float(3.00, minval=0, step=0.5, title="Standard Deviation 3", group="VWAP")
showVWAPSD1Band = input.bool(false, title="Show VWAP Standard Deviation 1?", group="VWAP")
showVWAPSD2Band = input.bool(false, title="Show VWAP Standard Deviation 2?", group="VWAP")
showVWAPSD3Band = input.bool(false, title="Show VWAP Standard Deviation 3?", group="VWAP")
timeChange(period) =>
ret = 0
if period == "Session"
ret := time("D")
if period == "Week"
ret := time("W")
if period == "Month"
ret := time("M")
if period == "Quarter"
ret := time("3M")
if period == "Year"
ret := time("12M")
if period == "Decade"
ret := time("12M") % time("120M") == 0 ? 1 : 0
if period == "Century"
ret := time("12M") % time("1200M") == 0 ? 1 : 0
ret
isNewPeriod = ta.change(timeChange(vwapAnchor))
isFirstBarOfNewPeriod = isNewPeriod and not isNewPeriod[1]
var float vwapSum = 0.0
vwapSum := isFirstBarOfNewPeriod ? vwapSource * volume : vwapSource * volume + vwapSum[1]
var float volumeSum = 0.0
volumeSum := isFirstBarOfNewPeriod ? volume : volume + volumeSum[1]
var float v2Sum = 0.0
v2Sum := isFirstBarOfNewPeriod ? volume * vwapSource * vwapSource : volume * vwapSource * vwapSource + v2Sum[1]
mVWAP = vwapSum / volumeSum
variance = v2Sum / volumeSum - mVWAP * mVWAP
variance := variance < 0 ? 0 : variance
standard_deviation = math.sqrt(variance)
vwapUpperBand1 = mVWAP + (vwapSD1 * standard_deviation)
vwapLowerBand1 = mVWAP - (vwapSD1 * standard_deviation)
vwapUpperBand2 = mVWAP + (vwapSD2 * standard_deviation)
vwapLowerBand2 = mVWAP - (vwapSD2 * standard_deviation)
vwapUpperBand3 = mVWAP + (vwapSD3 * standard_deviation)
vwapLowerBand3 = mVWAP - (vwapSD3 * standard_deviation)
plot(showVWAP ? mVWAP : na, title="VWAP", color=color.orange, linewidth=1)
vwapSD1Plot1 = plot(showVWAPSD1Band ? vwapUpperBand1 : na, title="VWAP SD1 Upper", color=color.gray, linewidth=1)
vwapSD1Plot2 = plot(showVWAPSD1Band ? vwapLowerBand1 : na, title="VWAP SD1 Lower", color=color.gray, linewidth=1)
fill(vwapSD1Plot1, vwapSD1Plot2, color=color.new(color.gray, 90), title="VWAP SD1 Fill")
vwapSD2Plot1 = plot(showVWAPSD2Band ? vwapUpperBand2 : na, title="VWAP SD2 Upper", color=color.gray, linewidth=1)
vwapSD2Plot2 = plot(showVWAPSD2Band ? vwapLowerBand2 : na, title="VWAP SD2 Lower", color=color.gray, linewidth=1)
fill(vwapSD2Plot1, vwapSD2Plot2, color=color.new(color.gray, 85), title="VWAP SD2 Fill")
vwapSD3Plot1 = plot(showVWAPSD3Band ? vwapUpperBand3 : na, title="VWAP SD3 Upper", color=color.gray, linewidth=1)
vwapSD3Plot2 = plot(showVWAPSD3Band ? vwapLowerBand3 : na, title="VWAP SD3 Lower", color=color.gray, linewidth=1)
fill(vwapSD3Plot1, vwapSD3Plot2, color=color.new(color.gray, 80), title="VWAP SD3 Fill")
// ══════════════════════════════════════════════════════════════════════════════
// MÓDULO A+ (Fibonacci 1H + Filtros)
// ══════════════════════════════════════════════════════════════════════════════
// Inputs A+
grpAPlus = "═══ A+ Filters (Fib 1H + VWAP + Volume) ═══"
enableAPlus = input.bool(true, title="Enable A+ Signals", group=grpAPlus)
fibTF = input.timeframe("60", title="Fibonacci Timeframe", group=grpAPlus)
pivotLen = input.int(5, title="Pivot Length (1H swing)", minval=1, group=grpAPlus)
tolPct = input.float(0.05, title="Fib Zone Tolerance (%)", minval=0.0, step=0.01, group=grpAPlus)
volLen = input.int(20, title="Volume SMA Length", minval=1, group=grpAPlus)
showFibLines = input.bool(true, title="Show Fib 0.5 & 0.618 Lines", group=grpAPlus)
// Pivot detection en 1H
f_pivH_1h = request.security(syminfo.tickerid, fibTF, ta.pivothigh(high, pivotLen, pivotLen), lookahead=barmerge.lookahead_off)
f_pivL_1h = request.security(syminfo.tickerid, fibTF, ta.pivotlow(low, pivotLen, pivotLen), lookahead=barmerge.lookahead_off)
var float lastPH = na
var float lastPL = na
var int lastPH_seq = 0
var int lastPL_seq = 0
var int seq = 0
seq := seq + 1
if not na(f_pivH_1h)
lastPH := f_pivH_1h
lastPH_seq := seq
if not na(f_pivL_1h)
lastPL := f_pivL_1h
lastPL_seq := seq
// Swing definition
var float swingA = na
var float swingB = na
var bool swingUp = na
haveBoth = not na(lastPH) and not na(lastPL)
if haveBoth
if lastPH_seq > lastPL_seq
// Upswing: low → high
swingA := lastPL
swingB := lastPH
swingUp := true
else
// Downswing: high → low
swingA := lastPH
swingB := lastPL
swingUp := false
// Fib levels
rng = haveBoth ? math.abs(swingB - swingA) : na
var float fib50 = na
var float fib618 = na
if haveBoth and not na(rng) and rng > 0
if swingUp
fib50 := swingB - rng * 0.50
fib618 := swingB - rng * 0.618
else
fib50 := swingB + rng * 0.50
fib618 := swingB + rng * 0.618
// Zone check (0.5–0.618 con tolerancia en %)
tol = close * (tolPct / 100.0)
zoneLow = math.min(fib50, fib618)
zoneHigh = math.max(fib50, fib618)
inFibZone = haveBoth and not na(zoneLow) and not na(zoneHigh) and (close >= (zoneLow - tol)) and (close <= (zoneHigh + tol))
// VWAP filter
vwapCallOk = close > mVWAP
vwapPutOk = close < mVWAP
// Volume filter
volOk = volume > ta.sma(volume, volLen)
// A+ conditions
AplusCall = enableAPlus and Bull and inFibZone and vwapCallOk and volOk
AplusPut = enableAPlus and Bear and inFibZone and vwapPutOk and volOk
// Plots
plot(showFibLines ? fib50 : na, color=color.yellow, linewidth=1, title="Fib 0.5 (1H)", style=plot.style_circles)
plot(showFibLines ? fib618 : na, color=color.orange, linewidth=1, title="Fib 0.618 (1H)", style=plot.style_circles)
plotshape(AplusCall, title="A+ CALL", style=shape.labelup, text="A+ CALL", color=color.new(color.lime, 0), textcolor=color.black, location=location.belowbar, size=size.small)
plotshape(AplusPut, title="A+ PUT", style=shape.labeldown, text="A+ PUT", color=color.new(color.fuchsia, 0), textcolor=color.white, location=location.abovebar, size=size.small)
// Alerts A+
alertcondition(AplusCall, title="A+ CALL", message="A+ CALL confirmed (OM cross + Fib 1H 0.5-0.618 + VWAP + Volume) on {{ticker}} @ {{close}}")
alertcondition(AplusPut, title="A+ PUT", message="A+ PUT confirmed (OM cross + Fib 1H 0.5-0.618 + VWAP + Volume) on {{ticker}} @ {{close}}")
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.