OPEN-SOURCE SCRIPT

MTF Ichimoku Strategy (4H & 1H) Gus81

83
Core Idea

This is a multi-timeframe Ichimoku alignment strategy.
It looks at the 4-hour (higher timeframe) and the 1-hour (lower timeframe) charts at the same time.
Trades are only allowed when both timeframes agree that price is trending in the same direction.
• Long (Buy) if both 4H and 1H price are:
• Above the top of the Ichimoku cloud (Kumo = Senkou Span A / Senkou Span B)
• Above the Kijun-sen (baseline)
• Short (Sell) if both 4H and 1H price are:
• Below the bottom of the cloud
• Below the Kijun-sen

This ensures trades only happen when trend strength is confirmed on two timeframes.



Ichimoku Logic Used

The script manually computes Ichimoku levels instead of using ta.ichimoku():
• Tenkan-sen (Conversion Line): (9-period highest high + 9-period lowest low) / 2
• Kijun-sen (Base Line): (26-period highest high + 26-period lowest low) / 2
• Senkou Span A: (Tenkan + Kijun) / 2
• Senkou Span B: (52-period highest high + 52-period lowest low) / 2

Then it uses request.security() to fetch these values for 4H and 1H timeframes, regardless of the chart you apply it on.



Trade Execution
• Entry:
• If conditions align, a long or short order is opened.
• If an opposite position is open, the old one is closed first (“flip”).
• Stop Loss & Take Profit (dynamic):
• SL and TP are set as a percentage of the average entry price.
• Example:
• Long trade SL = avgPrice * (1 - riskSLpct/100)
• Long trade TP = avgPrice * (1 + riskTPpct/100)
• Defaults: SL = 2%, TP = 4%.
• Cooldown filter:
• Prevents new trades until cooldownBars candles have passed since the last entry (default 12 bars).
• Reduces over-trading and whipsaws.
• Optional Opposite Exit:
• If enabled, a position will close when the opposite signal appears, even if SL/TP is not hit.



Visuals on Chart
• 4H Kumo Cloud plotted in teal
• 1H Kumo Cloud plotted in orange
• Kijun lines (blue for 4H, orange for 1H)
• Background shading: green when long conditions active, red when short
• Markers: triangles below/above bars for BUY/SELL signals



Alerts

Two layers of alerts:
1. Static alertcondition() → lets you set alerts via TradingView’s UI.
2. Code-fired alerts with cooldown → sends push alerts when conditions trigger, formatted as:

Ichimoku MTF | BUY 4H+1H | EURUSD | TF:60 | Close:1.0765

This way you can link alerts directly to your phone.



Backtesting

Since it’s a strategy():
• Runs through historical bars automatically.
• You can check net profit, drawdown, win rate, profit factor in Strategy Tester.
• Date filtering is possible via inputs (defaults: Sept 2024 → Sept 2025 if toggled on).



Strengths
• Trend alignment filter: only trades in strong, multi-timeframe trends.
• MTF Ichimoku logic: reduces false signals common in single-timeframe Ichimoku.
• Risk control: built-in SL/TP and cooldown.
• Visual clarity: cloud overlays + background shading.



Limitations
• Works best in strong trending conditions (Ichimoku’s strength).
• Will whipsaw in sideways / choppy markets.
• SL/TP are fixed percentages, not volatility-adaptive.
• No position sizing logic beyond “% of equity”.



In short: This is a trend-following breakout/confirmation strategy using Ichimoku across 4H + 1H. It waits for multi-timeframe agreement above/below the Kumo and Kijun before entering trades, manages risk with SL/TP and cooldown, and is fully backtestable in TradingView.

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.