The Idea
One of the most common mistakes in trend following is taking entries on a single timeframe without considering the broader market structure. A bullish crossover on the 4-hour chart means very little if the daily trend is firmly bearish. This strategy solves that problem by using two timeframes in a hierarchical relationship: the daily chart establishes the trend direction, and the 4-hour chart provides the entry signal. Only when both timeframes agree does the strategy commit capital.
Gold (XAUUSD) is the ideal instrument for this multi-timeframe approach. As a safe-haven asset, Gold tends to form sustained, well-defined trends driven by macroeconomic forces such as inflation expectations, real interest rates, and geopolitical uncertainty. These trends often persist for weeks or months on the daily chart, providing a stable directional filter. Meanwhile, the 4-hour chart offers frequent pullback-and-continuation patterns that serve as precise entry points within the larger trend.
The strategy uses Exponential Moving Averages (EMAs) on both timeframes because of their responsiveness to recent price action. The daily 50 EMA acts as a trend filter, dividing the market into bullish territory (price above the EMA) and bearish territory (price below). The H4 entry uses a 20/50 EMA crossover, which captures the moment when short-term momentum realigns with the larger trend after a pullback. This combination filters out counter-trend trades and concentrates entries on high-probability continuation setups.
Market & Instruments
This strategy is designed for Gold (XAUUSD) in the Commodities market. The higher timeframe filter operates on the Daily (D1) chart, while entries are executed on the H4 (4-hour) chart. Gold's average daily range typically falls between $20 and $40, which provides ample room for the ATR-based trailing stop to work effectively. Trades can last from several days to several weeks, making this a swing trading approach rather than a day trading strategy. Since Gold trades nearly 24 hours on weekdays, session filtering is less critical than with equity indices, though liquidity peaks during the London and New York overlap (13:00-17:00 GMT).
The Logic
The strategy operates on two layers. The first layer is the daily trend filter: if the current price is above the daily 50 EMA, the trend is classified as bullish and only long trades are permitted. If price is below the daily 50 EMA, the trend is bearish and only short trades are permitted. This filter is evaluated once per day at the close of the daily candle and remains in effect until the next daily close.
The second layer is the H4 entry signal. A long entry is triggered when the 20 EMA crosses above the 50 EMA on the H4 chart, but only if the daily trend filter is bullish. A short entry is triggered when the 20 EMA crosses below the 50 EMA on the H4 chart, but only if the daily trend filter is bearish. This crossover represents the moment when short-term momentum has realigned with the higher timeframe trend direction, typically occurring after a pullback has run its course.
The initial stop loss is placed at the most recent swing low (for long trades) or swing high (for short trades) on the H4 chart. A swing point is defined as a candle whose low is lower than the low of the two candles on either side (for a swing low) or whose high is higher than the high of the two candles on either side (for a swing high). Once the trade moves into profit, a trailing stop at 2x ATR(14) is activated, calculated on the H4 timeframe. This trailing mechanism allows the strategy to ride extended trends while protecting accumulated profits.
TREND FILTER (Daily):
Bullish: Price > 50 EMA (Daily) → only long trades allowed
Bearish: Price < 50 EMA (Daily) → only short trades allowed
ENTRY LONG (H4): 20 EMA crosses above 50 EMA AND daily filter = bullish
ENTRY SHORT (H4): 20 EMA crosses below 50 EMA AND daily filter = bearish
STOP LOSS: Recent H4 swing low (long) / swing high (short)
TRAILING STOP: 2x ATR(14) on H4, activated once in profit
POSITION SIZE: Risk 1-2% of account per trade
TIMEFRAMES: D1 (filter) + H4 (entry & management)
How to Build This in Arconomy
- Open the Canvas Editor and create a new strategy. Name it "Multi-Timeframe Trend Alignment" and select XAUUSD as the instrument. Set the primary execution timeframe to H4.
- Add a Multi-Timeframe Data node and configure it to pull the Daily (D1) chart data. Attach a 50 EMA indicator to this daily data source. This will be your trend filter.
- Create a Trend Filter Rule by adding a comparison node: check if the current Daily close is above or below the Daily 50 EMA. Label the outputs as "Bullish" and "Bearish" for clarity. See the Entry Rules reference for configuring conditional logic.
- On the H4 timeframe, add two EMA Indicator nodes: one with period 20 and one with period 50. Create a Crossover Detection rule that fires when the 20 EMA crosses the 50 EMA in either direction.
- Connect the crossover rule to the trend filter using rule chaining. The long entry should require both an upward crossover AND a bullish daily filter. The short entry requires a downward crossover AND a bearish daily filter.
- Set the initial stop loss using a Swing Point reference. Configure the swing lookback to 2 bars on either side (5-bar swing). For longs, the stop goes at the most recent H4 swing low. For shorts, it goes at the most recent H4 swing high.
- Add a Trailing Stop exit rule at 2x ATR(14) on the H4 timeframe. Set the activation condition to "when trade is in profit" so the trail does not engage prematurely.
- Configure position sizing to risk 1-2% of account equity per trade based on the distance from entry to the initial swing stop.
- Run a backtest using at least 12 months of data. Gold trends can persist for months, so shorter test periods may not capture enough full trade cycles to give statistically meaningful results.
Backtest Considerations
This strategy generates relatively few trades because it requires alignment between two timeframes. Expect approximately 2-4 trades per month on XAUUSD, which means you need at least 12 months of data (ideally 2-3 years) to accumulate a statistically meaningful sample of 30 or more trades. Do not draw conclusions from fewer than 20 completed trades.
Key parameters to optimise carefully: the daily EMA period (50 is standard; test 30-100), the H4 EMA crossover periods (20/50 is the default; test 10/30 through 30/80), and the ATR trailing stop multiplier (2x is the starting point; test 1.5x to 3x). The swing point lookback period (2 bars on either side) is generally robust and should not require adjustment.
Gold has distinct behavioural regimes. During risk-off environments (recessions, geopolitical crises), Gold tends to trend strongly upward and the strategy should perform well. During stable economic periods with rising real interest rates, Gold may enter extended downtrends or consolidation ranges where the strategy will generate more losing trades. Include both types of periods in your backtest to get a realistic expectation of performance. Spread assumptions should be 20-40 cents (0.2-0.4 points) for XAUUSD, with slippage of 10-20 cents per trade.
Key Takeaways
- Using the daily 50 EMA as a trend filter ensures that H4 entries only occur in the direction of the dominant trend, dramatically improving the win rate of EMA crossover signals.
- The hierarchical timeframe approach (Daily filter + H4 entry) eliminates counter-trend trades that are the primary source of losses in single-timeframe crossover strategies.
- Placing the initial stop at a recent swing point rather than a fixed ATR distance respects the market's actual structure and avoids arbitrary stop placement.
- The 2x ATR trailing stop allows the strategy to ride extended Gold trends while locking in profits as the move develops.
- Expect low trade frequency (2-4 trades per month), which requires patience and a long backtest window for meaningful statistical validation.