Overview
A setup that looks clean on a 5-minute chart can be directly counter to what the daily chart is doing — and lower-timeframe structure loses far more often than it wins when it's fighting the direction the higher timeframe is actually flowing. The core institutional discipline isn't a better lower-timeframe entry; it's refusing to take that entry when it runs against the macro flow.
Multi-Timeframe Trend integrates directional data from your current chart interval with a macro timeframe
of your choosing — fetched directly via request.security — and only displays a directional
bullish or bearish state when both agree. Any disagreement between the two is treated as noise and shown
as neutral, stripping out the lower-timeframe signals that would otherwise pull you into a countertrend
position.
Features of This Indicator
-
Dynamic Multi-Timeframe Smoothing Computes an independent fast/slow EMA trend read on both the current chart timeframe and a user-defined macro timeframe via request.security, then aligns the two into a single directional state.
-
Noise Reduction Confirmation Filter Requires a configurable number of consecutive agreeing bars before the displayed trend is allowed to flip, filtering out single-bar EMA crosses and short-lived noise from the signal you actually see.
-
Institutional Trend Confluence The indicator only shows a directional (bullish/bearish) state when the current-timeframe read and the macro-timeframe read agree; any disagreement is shown as neutral rather than forcing a side.
-
Full Interval Flexibility The macro timeframe is fully configurable — intraday, daily, weekly, or any custom interval — so the same engine adapts to scalping, day trading, or swing timeframes without modification.
How to Use
- Copy the script into TradingView's Pine Editor and click Add to Chart.
- Set the Macro Timeframe input to the higher timeframe you want confluence against — Daily for an intraday chart, Weekly for a daily chart, and so on.
- Read the background shading and EMA color: green means both timeframes are aligned bullish, red means aligned bearish, and no shading means the timeframes disagree — treat that as a no-trade signal.
- Check the small macro-state label in the corner for a direct readout of the higher timeframe's independent trend, separate from the aligned signal.
The Pine Script V5 Code
//@version=5
indicator("Multi-Timeframe Trend — Crypto Indicator Pro", shorttitle="MTF Trend [CIP]", overlay=true)
// ============================================================================
// MULTI-TIMEFRAME TREND
// Combines a fast/slow EMA trend read on the current chart timeframe with the
// same read computed on a higher, macro timeframe via request.security.
// Trend is only displayed as directional when both timeframes agree,
// filtering out lower-timeframe noise that runs counter to the macro flow.
// A persistence filter additionally requires several consecutive bars of
// agreement before the displayed trend state flips, further reducing
// whipsaw caused by single-bar EMA crosses.
// ============================================================================
// ---------------------------- INPUTS ----------------------------
macroTimeframe = input.timeframe("D", "Macro Timeframe", group="Multi-Timeframe")
fastLength = input.int(21, "Fast EMA Length", minval=2, group="Trend Calculation")
slowLength = input.int(50, "Slow EMA Length", minval=5, group="Trend Calculation")
confirmBars = input.int(3, "Confirmation Bars (Noise Filter)", minval=1, maxval=20, group="Trend Calculation",
tooltip="Number of consecutive agreeing bars required before the displayed trend state is allowed to flip.")
bullBg = input.color(color.new(color.teal, 85), "Bullish Background", group="Display")
bearBg = input.color(color.new(color.red, 85), "Bearish Background", group="Display")
// ---------------------------- SHARED TREND FUNCTION (used on both timeframes) ----------------------------
f_trendData() =>
emaFast = ta.ema(close, fastLength)
emaSlow = ta.ema(close, slowLength)
trend = emaFast > emaSlow ? 1 : emaFast < emaSlow ? -1 : 0
[emaFast, emaSlow, trend]
// ---------------------------- CURRENT TIMEFRAME TREND ----------------------------
[emaFastPlot, emaSlowPlot, currentTrend] = f_trendData()
// ---------------------------- MACRO TIMEFRAME TREND (via request.security) ----------------------------
// gaps_off + lookahead_off ensure no future-bar lookahead and no repainting of the current bar.
[macroFast, macroSlow, macroTrend] = request.security(syminfo.tickerid, macroTimeframe, f_trendData(),
gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
// ---------------------------- MULTI-TIMEFRAME ALIGNMENT ----------------------------
// Directional only when both the current and macro timeframe agree; otherwise neutral (noise/conflict).
rawTrend = (currentTrend == macroTrend) ? currentTrend : 0
// ---------------------------- PERSISTENCE / NOISE FILTER ----------------------------
var int displayedTrend = 0
var int pendingTrend = 0
var int consecCount = 0
if rawTrend != 0 and rawTrend == pendingTrend
consecCount += 1
else
pendingTrend := rawTrend
consecCount := 1
if consecCount >= confirmBars and pendingTrend != 0
displayedTrend := pendingTrend
// ---------------------------- VISUALIZATION ----------------------------
plot(emaFastPlot, "Fast EMA", color = displayedTrend == 1 ? color.teal : displayedTrend == -1 ? color.red : color.gray, linewidth=2)
plot(emaSlowPlot, "Slow EMA", color = color.new(color.gray, 40), linewidth=1)
bgcolor(displayedTrend == 1 ? bullBg : displayedTrend == -1 ? bearBg : na)
// Macro-timeframe state label, refreshed on the last bar for a quick independent readout
var label macroLabel = na
if barstate.islast
if not na(macroLabel)
label.delete(macroLabel)
macroText = macroTrend == 1 ? "Macro: Bullish" : macroTrend == -1 ? "Macro: Bearish" : "Macro: Neutral"
macroLabel := label.new(bar_index, high, macroText,
style=label.style_label_down,
color=macroTrend == 1 ? color.teal : macroTrend == -1 ? color.red : color.gray,
textcolor=color.white, size=size.small)
// ---------------------------- ALERTS ----------------------------
alertcondition(displayedTrend == 1 and displayedTrend[1] != 1, title="Trend Turned Bullish", message="Multi-timeframe trend aligned bullish.")
alertcondition(displayedTrend == -1 and displayedTrend[1] != -1, title="Trend Turned Bearish", message="Multi-timeframe trend aligned bearish.")