OPEN-SOURCE SCRIPT

Fractal FU

55
//version=5
indicator("Fractal FU", shorttitle="Fractal FU", overlay=true, max_labels_count=500)

// ===== Inputs
showBull = input.bool(true, "Show aligned bullish balls")
showBear = input.bool(true, "Show aligned bearish balls")
bullCol = input.color(color.blue, "Bull ball color")
bearCol = input.color(color.red, "Bear ball color")
ballSize = input.string("small", "Ball size", options=["tiny","small","normal","large","huge"])
gateTo15 = input.bool(true, "Gate to 15m close (clean, fewer signals)")
showDebug = input.bool(false, "Show per-timeframe debug dots")

// ===== Helpers
// one-liner you asked for:
f_sig(res) => request.security(syminfo.tickerid, res, (high > high[1] and low < low[1]) ? (close > open ? 1 : close < open ? -1 : 0) : 0, barmerge.gaps_off, barmerge.lookahead_off)

// Pull confirmed signals from each TF
sig1 = f_sig("1")
sig5 = f_sig("5")
sig10 = f_sig("10")
sig15 = f_sig("15")

// Alignment (all four agree)
bullAll = showBull and (sig1 == 1 and sig5 == 1 and sig10 == 1 and sig15 == 1)
bearAll = showBear and (sig1 == -1 and sig5 == -1 and sig10 == -1 and sig15 == -1)

// Emit control
emit15 = ta.change(time("15"))
emit = gateTo15 ? emit15 : barstate.isconfirmed // if not gated, show wherever alignment is true

// ===== Debug (tiny dots at bar to verify which TFs are firing)
plotshape(showDebug and sig1 == 1, title="1m bull", style=shape.circle, size=size.tiny, color=color.new(color.blue, 0), location=location.bottom)
plotshape(showDebug and sig5 == 1, title="5m bull", style=shape.circle, size=size.tiny, color=color.new(color.aqua, 0), location=location.bottom)
plotshape(showDebug and sig10 == 1, title="10m bull", style=shape.circle, size=size.tiny, color=color.new(color.teal, 0), location=location.bottom)
plotshape(showDebug and sig15 == 1, title="15m bull", style=shape.circle, size=size.tiny, color=color.new(color.navy, 0), location=location.bottom)
plotshape(showDebug and sig1 == -1, title="1m bear", style=shape.circle, size=size.tiny, color=color.new(color.red, 0), location=location.top)
plotshape(showDebug and sig5 == -1, title="5m bear", style=shape.circle, size=size.tiny, color=color.new(color.orange, 0), location=location.top)
plotshape(showDebug and sig10 == -1, title="10m bear", style=shape.circle, size=size.tiny, color=color.new(color.maroon, 0), location=location.top)
plotshape(showDebug and sig15 == -1, title="15m bear", style=shape.circle, size=size.tiny, color=color.new(color.purple, 0), location=location.top)

// ===== Markers (size must be const → gate each size)
off = gateTo15 ? -1 : 0 // when gated, place on the just-closed 15m bar

// ── Marker offset control stays the same ──
off2 = gateTo15 ? -1 : 0

// ── Bullish balls exactly at LOW ──
plot(bullAll and emit and ballSize == "tiny" ? low : na, title="Bullish tiny", style=plot.style_circles, color=bullCol, linewidth=1, offset=off2)
plot(bullAll and emit and ballSize == "small" ? low : na, title="Bullish small", style=plot.style_circles, color=bullCol, linewidth=2, offset=off2)
plot(bullAll and emit and ballSize == "normal" ? low : na, title="Bullish normal", style=plot.style_circles, color=bullCol, linewidth=3, offset=off2)
plot(bullAll and emit and ballSize == "large" ? low : na, title="Bullish large", style=plot.style_circles, color=bullCol, linewidth=4, offset=off2)
plot(bullAll and emit and ballSize == "huge" ? low : na, title="Bullish huge", style=plot.style_circles, color=bullCol, linewidth=5, offset=off2)

// ── Bearish balls exactly at HIGH ──
plot(bearAll and emit and ballSize == "tiny" ? high : na, title="Bearish tiny", style=plot.style_circles, color=bearCol, linewidth=1, offset=off2)
plot(bearAll and emit and ballSize == "small" ? high : na, title="Bearish small", style=plot.style_circles, color=bearCol, linewidth=2, offset=off2)
plot(bearAll and emit and ballSize == "normal" ? high : na, title="Bearish normal", style=plot.style_circles, color=bearCol, linewidth=3, offset=off2)
plot(bearAll and emit and ballSize == "large" ? high : na, title="Bearish large", style=plot.style_circles, color=bearCol, linewidth=4, offset=off2)
plot(bearAll and emit and ballSize == "huge" ? high : na, title="Bearish huge", style=plot.style_circles, color=bearCol, linewidth=5, offset=off2)



// Alerts
alertcondition(bullAll and emit, title="Aligned Bullish Outside (1/5/10/15)", message="Aligned bullish outside bar on 1/5/10/15m")
alertcondition(bearAll and emit, title="Aligned Bearish Outside (1/5/10/15)", message="Aligned bearish outside bar on 1/5/10/15m")
alertcondition((bullAll or bearAll) and emit, title="Aligned Any (1/5/10/15)", message="Aligned outside bar (bull or bear) on 1/5/10/15m")

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.