Imagine two traders with the same moving-average crossover strategy. One trades looking only at the M5 and takes trades in every direction. The other only accepts the M5 signals that are in line with the H1 trend. The second one will trade less — and better. That's the essence of multi-timeframe: use the higher chart as a compass and the lower one as a trigger. It's one of the most effective ways to filter out bad trades.
01The single-timeframe mistake
Anyone trading off a single chart falls into a trap: a buy signal on the M5 may be perfectly aligned in the short term, but be just a bounce inside a downtrend on the H1. You buy, the bounce ends, and the larger trend swallows you. A single timeframe leaves you blind to context.
The tide metaphor: think of the higher timeframe as the tide and the lower one as the waves. You might see a wave rising (a buy signal on the M5), but if the tide is going out (a downtrend on the H1), betting on the wave is risky. Multi-timeframe makes you swim with the tide.
02The concept: higher trend, lower entry
The structure is always the same — two (sometimes three) timeframes with distinct roles:
Higher timeframe → DIRECTION
Defines whether you only look for buys or only sells. E.g. H1.
"Is price above the 200 average on the H1? Then I only look for buys."
Lower timeframe → TRIGGER
Gives the exact moment to enter, in the already-defined direction. E.g. M15.
"Was there a pullback and a bullish crossover on the M15? I go long."
03Which timeframes to combine
The practical rule is a ratio of about 4 to 6 times between them — large enough to give different context, close enough to make sense. Common combinations:
- Day trading: M15 (trend) + M3 or M5 (entry)
- Wider intraday: H1 (trend) + M15 (entry)
- Swing: Daily (trend) + H4 (entry)
Some traders use three: a top one (macro direction), a middle one (operational trend) and a low one (trigger). More than three becomes paralysis — too much information, too little decision.
04Coding the confluence
The bot needs to pull two timeframes and cross-reference the information. Here it is on both platforms:
//@version=5 strategy("Multi-Timeframe", overlay=true) // trend on the HIGHER timeframe (e.g. 60 min) htf = input.timeframe("60", "Trend timeframe") ma200_htf = request.security(syminfo.tickerid, htf, ta.sma(close, 200)) close_htf = request.security(syminfo.tickerid, htf, close) uptrend = close_htf > ma200_htf // trigger on the CURRENT timeframe (the chart's, lower) fast_ma = ta.ema(close, 9) slow_ma = ta.ema(close, 21) buy_trigger = ta.crossover(fast_ma, slow_ma) // CONFLUENCE: only buy if trigger AND higher trend agree if buy_trigger and uptrend strategy.entry("Buy", strategy.long)
# multi_timeframe.py def trend_direction(df_htf): # trend on the higher chart: price vs the 200 average ma200 = df_htf["close"].rolling(200).mean().iloc[-1] return "UP" if df_htf["close"].iloc[-1] > ma200 else "DOWN" def entry_trigger(df_ltf): # trigger on the lower chart: EMA crossover f = df_ltf["close"].ewm(span=9).mean() s = df_ltf["close"].ewm(span=21).mean() crossed_up = f.iloc[-2] < s.iloc[-2] and f.iloc[-1] > s.iloc[-1] return "BUY" if crossed_up else "WAIT" # confluence df_h1 = fetch_candles("ES", timeframe_H1) df_m15 = fetch_candles("ES", timeframe_M15) if trend_direction(df_h1) == "UP" and entry_trigger(df_m15) == "BUY": print("Confluence confirmed — buy")
In Pine, the key function is request.security — it fetches data from another timeframe within the same script. In Python, you simply pull two DataFrames of different periods (via the MT5 API or Binance) and cross-reference them.
Combine with the right indicators
The 200 average defines the higher trend; the EMA crossover gives the trigger. See the moving-averages guide.
05Cautions in automation
- Repaint: in Pine, beware of
request.securityusing the still-forming candle of the higher timeframe — it can "repaint" and mislead the backtest. Use the value of the already-closed candle ([1]) for reliable data. - Fewer trades is the goal: multi-timeframe will sharply reduce the number of trades. That's a feature, not a bug — you're filtering out the bad ones. Don't "loosen" the filter just to trade more.
- Synchronization: make sure both timeframes are of the same asset and updated at the same moment. Lagged data between them generates false signals.
06Why it works
Multi-timeframe works because it attacks the biggest enemy of most strategies: trading against the dominant trend. Statistically, trades in the direction of the higher trend have better expectancy. By filtering out everything that goes against the "tide," you cut a large slice of the losing trades — while keeping the same entry strategy. It's one of the few adjustments that improves results without adding fragile complexity.
The larger principle: this connects to everything we preach — management and context matter more than the strategy itself. Multi-timeframe is, at heart, a context filter. And a context filter is what separates a bot that survives from a bot that bleeds.
07Frequently asked questions
What is multi-timeframe analysis?
It's analyzing the same asset across several periods: a higher one to define the trend direction and a lower one for entry timing. Trading in the direction of the higher trend filters out many bad trades.
Which timeframes should you combine?
Common rule: a ratio of 4 to 6 times. E.g. H1 (trend) + M15 (entry), or Daily + H4 for swing. The higher gives context, the lower gives the trigger. Up to three timeframes works; more than that becomes paralysis.
How do you automate multi-timeframe?
The bot pulls two periods: it computes the trend on the higher one (e.g. price above the 200 average) and only looks for entries on the lower one in that direction. In Pine, use request.security; in Python, pull two DataFrames and cross-reference.
Multi-timeframe reduces my trades — is that bad?
No, it's the goal. You're filtering out the trades against the trend (usually the worst ones). Fewer trades, better quality. Don't loosen the filter just to trade more — that cancels the benefit.
What is repaint and how do you avoid it?
Repaint is when a higher-timeframe value changes while the candle is still forming, misleading the backtest. Avoid it by using the value of the already-closed candle (index [1] in Pine) when pulling higher-timeframe data.