Confluence Trading Strategy: Structure, Trend and Momentum
A confluence trading strategy built from three independent factors: market structure, higher-timeframe trend and momentum. Rules, example, code.
Confluence Trading Strategy: Structure, Trend and Momentum
TLDR
A confluence trading strategy takes a trade only when several independent pieces of evidence agree. The three-factor version in this article uses market structure (a break of the most recent swing level), higher-timeframe trend (price relative to a slow moving average on a higher timeframe) and momentum (an oscillator on the correct side of its midline). Each factor comes from a different kind of information, which is what makes their agreement meaningful; three trend indicators agreeing is not confluence, it is the same fact three times. The article gives exact rules for each factor, a comparison of ways to define them, a worked example with the sizing arithmetic, and an original Pine Script v6 strategy that requires all three before entering.
What this article adds to the pillar
Our pillar on confluence in trading explains the concept, why factor independence matters, how to build a weighted score and how to size by that score. This piece is narrower: one concrete strategy, three factors with fixed definitions, no weights. The scored approach is more flexible; the all-or-nothing approach is easier to test, easier to execute and much harder to fool yourself with. If you are new to confluence, start here and graduate to scoring once you have a sample of trades to study.
Why these three factors
Each factor answers a different question, and they are measured in ways that do not share inputs.
- Structure answers: has price done something it was not doing before? A close through the most recent confirmed swing high says buyers have absorbed the supply that turned price back last time. This is a fact about price levels, not about averages.
- Trend answers: is the larger context on your side? Price above a slow average on a timeframe several steps higher than your trading chart says the pressure over days or weeks has been upward. This is a fact about the average level over a long window.
- Momentum answers: is the recent push strong enough to be more than drift? An oscillator above its midline says recent closes have been net upward over a short window. This is a fact about the rate of change.
Levels, long-window averages and short-window rate of change are three different measurements. They can and do disagree, which is the whole point: when they agree, you have learned something you would not learn from one of them alone.
Defining each factor so a machine can check it
"Structure is bullish" is not a rule. Below are definitions that can be coded, with the alternatives and what each costs.
| Factor | Definition used here | Common alternatives | Trade-off |
|---|---|---|---|
| Structure (long) | Close above the most recent confirmed swing high, where a swing high is a bar whose high exceeds the N bars on each side | Close above previous day's high; break of a drawn trendline; close above a Donchian channel | Swing pivots adapt to volatility but confirm N bars late; daily highs are simpler but ignore intraday structure |
| Trend (long) | Close above a 50-period EMA computed on a timeframe four to six steps higher (for example 4 hour EMA on a 15 minute chart) | 200 EMA on the trading timeframe; higher-timeframe higher highs and higher lows; ADX above a threshold with +DI over -DI | Higher-timeframe EMA is slow and stable; same-timeframe EMAs flip more often and share inputs with momentum |
| Momentum (long) | 14-period RSI above 50 | MACD histogram above zero; rate of change above zero; stochastic above 50 | RSI midline is simple and bounded; MACD is unbounded and reacts faster but is itself built from EMAs, which weakens independence from the trend factor |
Short setups mirror every rule: close below the most recent confirmed swing low, close below the higher-timeframe EMA, RSI below 50.
Notice what was avoided. Using an EMA crossover for trend and a MACD for momentum would be two EMA-based measures that agree with each other most of the time. That inflates the number of "confluent" setups without adding information. The pillar article's section on double counting explains the mechanism.
The complete rule set
- Trading timeframe: 15 minute. Trend timeframe: 4 hour. Instrument: anything liquid; the example below uses an index CFD, but the rules are not instrument-specific.
- Compute the 50 EMA on the 4 hour chart using only completed 4 hour bars (no lookahead). Long bias if the 15 minute close is above it, short bias if below.
- Track the most recent confirmed swing high and swing low on the 15 minute chart with a 10 bar pivot (10 bars each side).
- Long entry: all three true on the same closed bar: close above the swing high for the first time (the previous bar's close was at or below it), long bias, RSI(14) above 50. Short entry is the mirror.
- Stop: the most recent confirmed swing low for longs, swing high for shorts.
- Target: 1.5 times the stop distance. Time stop: close any open trade after 40 bars (10 hours on a 15 minute chart) if neither level has been hit.
- One position at a time. No pyramiding.
- Position size: account risk per trade divided by stop distance in money terms, rounded down.
Every number above is a starting point. The reward multiple, pivot length and EMA length should be tested on your market and then frozen. Changing them after a bad week is how a tested strategy turns back into guesswork.
Worked example: one setup from scratch
Illustrative figures on a US index CFD quoted in index points, with a contract worth 1 USD per point per unit and minimum size 0.1 units. Account 20,000 USD, risk per trade 0.5% (100 USD).
- 4 hour 50 EMA, last completed bar: 5,212.4. Current 15 minute close: 5,241.0. Long bias confirmed.
- Most recent confirmed 15 minute swing high: 5,238.6, formed 14 bars ago. Most recent confirmed swing low: 5,219.8.
- Previous bar close 5,237.9 (below the swing high). Current bar close 5,241.0 (above it). Structure condition true for the first time.
- RSI(14) on the current bar: 58.3. Above 50. Momentum condition true.
- All three agree. Enter long at 5,241.0 on the next bar open (assume 5,241.3 after a small gap).
- Stop at the swing low, 5,219.8. Stop distance: 5,241.3 - 5,219.8 = 21.5 points.
- Size: 100 USD / (21.5 points x 1 USD per point per unit) = 4.65 units, rounded down to 4.6 units. Risk at stop: 21.5 x 4.6 = 98.90 USD.
- Target at 1.5R: 5,241.3 + (1.5 x 21.5) = 5,273.55, rounded to the quote precision as 5,273.6. Potential gain: 32.3 x 4.6 = 148.58 USD before spread.
Now the same bar with one factor missing. Suppose RSI had been 47.2. Structure and trend agree but momentum does not, so no trade. The chart would look nearly identical to a trader eyeballing it; the rule set says the push through the level lacked force. Whether that filter earns its keep is an empirical question that your log answers over a few hundred bars, not a matter of opinion.
Original Pine Script v6 strategy
The strategy below implements the rule set. The higher-timeframe EMA uses the standard confirmed-bar idiom so it does not repaint; the swing levels come from ta.pivothigh and ta.pivotlow and update only when a pivot confirms. Set commission and slippage in the strategy properties before you read the report, and see the backtesting platforms article for how to interpret it.
//@version=6
strategy("Structure + Trend + Momentum (illustrative)", overlay=true,
default_qty_type=strategy.percent_of_equity, default_qty_value=1)
htf = input.timeframe("240", "Trend timeframe")
emaLen = input.int(50, "Trend EMA length", minval=5)
swingLen = input.int(10, "Swing lookback (bars each side)", minval=3)
rsiLen = input.int(14, "RSI length", minval=2)
rsiMid = input.float(50, "RSI midline")
rr = input.float(1.5, "Reward to risk", step=0.25)
maxBars = input.int(40, "Time stop (bars)", minval=1)
// Trend: higher-timeframe EMA from completed bars only (no lookahead)
htfEma = request.security(syminfo.tickerid, htf, ta.ema(close, emaLen)[1],
lookahead=barmerge.lookahead_on)
upTrend = close > htfEma
dnTrend = close < htfEma
// Structure: most recent confirmed swing high and low
ph = ta.pivothigh(high, swingLen, swingLen)
pl = ta.pivotlow(low, swingLen, swingLen)
var float swingHigh = na
var float swingLow = na
if not na(ph)
swingHigh := ph
if not na(pl)
swingLow := pl
bosUp = not na(swingHigh) and not na(swingLow) and close > swingHigh and close[1] <= swingHigh
bosDn = not na(swingHigh) and not na(swingLow) and close < swingLow and close[1] >= swingLow
// Momentum: RSI relative to its midline
r = ta.rsi(close, rsiLen)
momUp = r > rsiMid
momDn = r < rsiMid
longOk = upTrend and bosUp and momUp
shortOk = dnTrend and bosDn and momDn
flat = strategy.position_size == 0
if longOk and flat
strategy.entry("L", strategy.long)
strategy.exit("LX", "L", stop=swingLow, limit=close + (close - swingLow) * rr)
if shortOk and flat
strategy.entry("S", strategy.short)
strategy.exit("SX", "S", stop=swingHigh, limit=close - (swingHigh - close) * rr)
barsIn = bar_index - strategy.opentrades.entry_bar_index(0)
if not flat and barsIn >= maxBars
strategy.close_all("Time stop")
plot(htfEma, "HTF EMA", color.orange)
plot(swingHigh, "Swing high", color.new(color.teal, 40), 1, plot.style_linebr)
plot(swingLow, "Swing low", color.new(color.maroon, 40), 1, plot.style_linebr)
Reading the code: the entry fires on the bar where the structure break first appears and all three conditions hold; the exit order is placed at the same time with the stop at the opposite swing level and the limit at the reward multiple. The time stop counts bars since the entry bar. If you want the scored version from the pillar, replace the three booleans with integer contributions and compare the sum to a threshold; the rest of the script does not change.
Where this strategy struggles
Late structure
A pivot with 10 bars each side confirms 10 bars after the actual high. In a fast market the break of that level can come long after the move has started. Shorter pivot lengths confirm sooner but produce more, smaller swing points and more false breaks. There is no free setting; pick by testing.
Trend flips at the EMA
When price hugs the higher-timeframe EMA, the trend factor flips between long and short bias every few bars, and you get a sequence of small losses in both directions. A buffer (require price to be more than a fraction of ATR away from the EMA) reduces this at the cost of missing early entries in new trends.
Momentum lag after a long consolidation
RSI can sit under 50 for the first bar or two of a genuine breakout out of a long range, so the strategy misses the first entry and takes the retest instead, or misses the move entirely. Some traders relax the momentum condition to "RSI rising" rather than "RSI above 50"; test it as a separate variant.
Correlated factors on some instruments
On strongly trending instruments all three factors spend most of their time agreeing, and the filter does little. On choppy instruments they rarely agree and the strategy barely trades. Check the agreement rate on your instrument before concluding the method is good or bad.
Extending the strategy without breaking it
Adding a fourth factor is tempting. Before you do, ask what new kind of information it brings. Volume (a close through the swing high on above-average volume) is a genuinely different measurement and is a reasonable fourth factor on exchange-traded instruments; it is much less meaningful on spot forex where volume is broker-specific. Session timing (only trade during the London or New York hours) is another independent factor and pairs well with the breakout methods in the ORB strategy article. A second oscillator is not a new factor and should not be added.
Each added factor cuts the number of trades. A strategy that fires twice a month cannot be evaluated inside a year. Keep the factor count at the level where you still get a sample you can learn from.
FAQ
What is the minimum number of factors for confluence?
Two independent factors is the floor; three is the common practical number. More than four usually means some factors are measuring the same thing or the strategy trades so rarely that you cannot judge it.
Can I use MACD instead of RSI for momentum?
Yes, but MACD is built from two EMAs, so it shares its construction with an EMA-based trend factor and the two will agree more often than independent measures would. If you use MACD for momentum, consider a non-EMA trend definition such as higher-timeframe higher highs and higher lows.
Why does the strategy enter late compared to what I see on the chart?
Because every factor is checked on closed bars and the swing level needs 10 bars to confirm. What you see on the chart in hindsight includes the pivot that had not yet confirmed at the time. The non-repainting indicators article explains why this is the price of a signal you can actually trade.
Should I size bigger when the setup looks very strong?
Not in this version. The all-or-nothing rule set deliberately sizes every trade by the stop distance only. Once you have a logged sample, the scoring approach in the confluence pillar lets you test whether higher scores deserve larger size.
Does this work on crypto and forex as well as indices?
The rules are instrument-agnostic. The settings are not: pivot length, EMA timeframe and reward multiple that suit an index on 15 minute bars may not suit a crypto pair on 1 hour bars. Re-test each instrument rather than carrying settings across.
Where Viprasol fits
Viprasol builds confluence indicators and strategies for TradingView in Pine Script v6 and for MetaTrader 5 in MQL5. The usual deliverable is a confluence indicator that shows which of your chosen factors is currently true, fires a non-repainting alert when they all agree, and comes with a strategy version for testing with realistic costs; the three-factor rule set above is a typical starting specification that we then adapt to your factors and markets. See the MT5 indicator development service for the MetaTrader route, the pricing page for rates, and the contact form to describe your factors.
Risk disclaimer: trading indices, forex, futures, CFDs and crypto involves substantial risk of loss. This article is educational and is not investment advice; illustrative figures do not indicate future performance.
External Resources
About the Author
Viprasol Tech Team
Custom Software Development Specialists
The Viprasol Tech team specialises in algorithmic trading software, AI agent systems, and SaaS development. With 1000+ projects delivered across MT4/MT5 EAs, fintech platforms, and production AI systems, the team brings deep technical experience to every engagement.
Ready to Automate Your Trading?
Discuss a custom Expert Advisor with defined strategy rules, risk controls and a testing plan.
Free consultation • No commitment • Response within 24 hours
Need a custom EA or trading bot built?
We build MT4/MT5 Expert Advisors around your strategy, broker and risk requirements. Each project has an agreed scope, testing plan and individual quote.