Fibonacci Pro + Intraday Momentum | Albert Setups

AlbertSetups · study · 115 行 · 点赞 27 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AlbertSetups
 
 
 //@version=6
indicator("Fibonacci Pro + Intraday Momentum | Albert Setups", overlay=true, max_labels_count=200)
 
// ───── INPUTS ─────
swingLen = input.int(10, "Fibonacci Swing Length", minval=2)
fastLen = input.int(9, "Fast EMA", minval=1)
slowLen = input.int(21, "Slow EMA", minval=1)
rsiLen = input.int(14, "RSI Length", minval=1)
rsiBull = input.int(55, "Bullish RSI Level", minval=1, maxval=99)
rsiBear = input.int(45, "Bearish RSI Level", minval=1, maxval=99)
showFib = input.bool(true, "Show Fibonacci Levels")
showEMA = input.bool(true, "Show EMAs")
showSignals = input.bool(true, "Show BUY/SELL Signals")
colorCandles = input.bool(true, "Color Trend Candles")
 
// ───── TREND & MOMENTUM ─────
emaFast = ta.ema(close, fastLen)
emaSlow = ta.ema(close, slowLen)
rsiValue = ta.rsi(close, rsiLen)
 
bullTrend = emaFast > emaSlow
bearTrend = emaFast < emaSlow
 
bullMomentum = rsiValue > rsiBull
bearMomentum = rsiValue < rsiBear
 
bullCandle = close > open
bearCandle = close < open
 
plot(showEMA ? emaFast : na, "Fast EMA", color=color.aqua, linewidth=2)
plot(showEMA ? emaSlow : na, "Slow EMA", color=color.orange, linewidth=2)
 
barcolor(colorCandles ? bullTrend and bullMomentum ? color.lime : bearTrend and bearMomentum ? color.red : color.gray : na)
 
// ───── CONFIRMED SWING POINTS ─────
pivotHigh = ta.pivothigh(high, swingLen, swingLen)
pivotLow = ta.pivotlow(low, swingLen, swingLen)
 
var float lastHigh = na
var int lastHighBar = na
var float lastLow = na
var int lastLowBar = na
 
if not na(pivotHigh)
    lastHigh := pivotHigh
    lastHighBar := bar_index - swingLen
 
if not na(pivotLow)
    lastLow := pivotLow
    lastLowBar := bar_index - swingLen
 
// ───── FIBONACCI LEVELS ─────
var float fib0 = na
var float fib236 = na
var float fib382 = na
var float fib500 = na
var float fib618 = na
var float fib786 = na
var float fib100 = na
var int fibDirection = 0
 
if not na(pivotHigh) and not na(lastLow) and not na(lastLowBar) and lastLowBar < bar_index - swingLen
    if na(lastHighBar) or lastLowBar < lastHighBar
        fibRange = pivotHigh - lastLow
        if fibRange > 0
            fib0 := pivotHigh
            fib236 := pivotHigh - fibRange * 0.236
            fib382 := pivotHigh - fibRange * 0.382
            fib500 := pivotHigh - fibRange * 0.5
            fib618 := pivotHigh - fibRange * 0.618
            fib786 := pivotHigh - fibRange * 0.786
            fib100 := lastLow
            fibDirection := 1
 
if not na(pivotLow) and not na(lastHigh) and not na(lastHighBar) and lastHighBar < bar_index - swingLen
    if na(lastLowBar) or lastHighBar < lastLowBar
        fibRange = lastHigh - pivotLow
        if fibRange > 0
            fib0 := lastHigh
            fib236 := lastHigh - fibRange * 0.236
            fib382 := lastHigh - fibRange * 0.382
            fib500 := lastHigh - fibRange * 0.5
            fib618 := lastHigh - fibRange * 0.618
            fib786 := lastHigh - fibRange * 0.786
            fib100 := pivotLow
            fibDirection := -1
 
plot(showFib ? fib0 : na, "Fib 0.0%", color=color.gray, linewidth=1, style=plot.style_stepline)
plot(showFib ? fib236 : na, "Fib 23.6%", color=color.blue, style=plot.style_stepline)
plot(showFib ? fib382 : na, "Fib 38.2%", color=color.teal, style=plot.style_stepline)
plot(showFib ? fib500 : na, "Fib 50.0%", color=color.orange, linewidth=1, style=plot.style_stepline)
plot(showFib ? fib618 : na, "Fib 61.8%", color=color.purple, linewidth=2, style=plot.style_stepline)
plot(showFib ? fib786 : na, "Fib 78.6%", color=color.red, style=plot.style_stepline)
plot(showFib ? fib100 : na, "Fib 100%", color=color.gray, linewidth=1, style=plot.style_stepline)
 
// ───── ENTRY CONDITIONS ─────
inFibBuyZone = not na(fib382) and not na(fib618) and close <= fib382 and close >= fib618
inFibSellZone = not na(fib382) and not na(fib618) and close >= fib382 and close <= fib618
 
buySetup = fibDirection == 1 and bullTrend and bullMomentum and bullCandle and inFibBuyZone
sellSetup = fibDirection == -1 and bearTrend and bearMomentum and bearCandle and inFibSellZone
 
buySignal = buySetup and not buySetup[1] and barstate.isconfirmed
sellSignal = sellSetup and not sellSetup[1] and barstate.isconfirmed
 
plotshape(showSignals and buySignal, title="BUY Signal", text="BUY", style=shape.labelup, location=location.belowbar, color=color.green, textcolor=color.white, size=size.small)
plotshape(showSignals and sellSignal, title="SELL Signal", text="SELL", style=shape.labeldown, location=location.abovebar, color=color.red, textcolor=color.white, size=size.small)
 
// ───── ALERTS ─────
alertcondition(buySignal, title="Fibonacci BUY", message="Potential Fibonacci momentum BUY on {{ticker}} at {{close}}")
alertcondition(sellSignal, title="Fibonacci SELL", message="Potential Fibonacci momentum SELL on {{ticker}} at {{close}}")

← 返回列表