Confluence in Trading: What It Is, How to Score It, and the Code
Confluence in trading means several independent reasons line up at one price and time. Learn to define factors, score them and size by score.
Confluence in Trading: What It Is, How to Score It, and the Code
TLDR
Confluence in trading is the condition where two or more independent pieces of evidence point to the same trade at the same price and time: for example, a higher timeframe trend, a pullback to a prior support level, and a momentum reading that has reset. Traders use confluence to filter out low-quality setups and, in more structured systems, to scale position size by how many factors agree. The concept is sound; the common mistakes are counting the same information twice, stacking so many filters that nothing ever triggers, and finding confluence in hindsight. This article defines the term precisely, gives a scoring framework you can code, shows the arithmetic for sizing by score, and provides an original Pine Script v6 confluence indicator.
What confluence actually means
The word comes from hydrology: a confluence is where two rivers join. In trading it describes a location on the chart where several analytical methods, each of which would give a reason to trade on its own, happen to agree. The key word is independent. Two moving averages of different lengths crossing is one piece of evidence about trend, not two. A moving average, a volume profile node and a scheduled session open are three different kinds of evidence, because they are computed from different inputs and would not automatically agree.
Confluence is useful because any single technical signal is weak. Price touching a support level breaks through support often enough that trading every touch is close to a coin flip after costs. Price touching a support level that also coincides with a higher timeframe trend direction, a 61.8 percent retracement and a session open where volume reliably increases is a narrower condition. Whether it is a better condition is an empirical question for your market and your data, but it is at least a different, more specific hypothesis than "support holds".
Three practical definitions are worth separating:
- Price confluence: several levels derived by different methods land within a small band. A prior swing low, a daily pivot and a round number within a few ticks of each other is the classic example.
- Directional confluence: several methods agree on direction at the time of a signal. Higher timeframe trend up, momentum turning up from a reset, order flow leaning to the buy side.
- Time confluence: the signal occurs at a moment with a known structural reason for participation, such as a session open, a scheduled release or a weekly close.
A complete confluence setup usually has at least one of each. Price tells you where, direction tells you which way, time tells you when the move is likely to be contested.
Factor categories and why independence matters
The table below groups the most common confluence factors by what they measure. Factors in the same row are largely redundant with each other; counting two from the same row as two points is double counting. Factors from different rows are closer to independent, although nothing on a price chart is truly independent of price.
| Category | Example factors | Computed from | Redundancy warning |
|---|---|---|---|
| Trend | EMA slope, price above or below a long moving average, higher timeframe higher highs | Smoothed price over a long window | Any two trend measures on the same timeframe agree almost all the time |
| Momentum | RSI, stochastic, MACD histogram, rate of change | Price change over a short window | RSI and stochastic are different scalings of similar information |
| Structure | Prior swing high or low, support and resistance zone, Fibonacci retracement, order block | Past turning points in price | Fibonacci levels are drawn between swing points, so they share inputs with swing analysis |
| Volume and participation | Volume above its average, volume profile high-volume node, delta or cumulative delta | Traded volume, not price | Genuinely different input from the rows above; one of the stronger independent factors |
| Volatility | ATR regime, Bollinger Band width, squeeze | Dispersion of price | Related to momentum in trending regimes |
| Time and session | London or New York open, first hour, end of week, scheduled release | The clock | Fully independent of price; cheap to add and easy to test |
| Cross-market | Correlated instrument direction, index breadth, yield move | A different instrument | Independent in principle, but correlations shift |
A good rule when designing a confluence score: take at most one factor from each category, and prefer categories whose inputs are different data series. A score built from trend, structure, volume and time is more informative than a score built from four momentum oscillators, even though both produce a number between zero and four.
A scoring framework you can code
Discretionary traders apply confluence by eye. That works for some people and is impossible to backtest. The alternative is to define each factor as a boolean condition, assign a weight, sum the weights into a score, and then make trading decisions as a function of the score. Here is a concrete five-factor framework for a pullback entry in the direction of the higher timeframe trend.
Factors for a long setup
- Trend (weight 1): close is above the 50 period EMA on the trading timeframe.
- Higher timeframe (weight 1): the previous completed higher timeframe bar closed above its own 50 period EMA.
- Momentum reset (weight 1): the 14 period RSI is between 40 and 60, meaning it has pulled back from overbought but has not collapsed.
- Structure (weight 1): the current low is within half an ATR of the lowest low of the last 20 bars, meaning price is testing recent support rather than chasing.
- Participation (weight 1): volume on the current bar is above its 20 bar average.
Score ranges from 0 to 5. The mirror conditions produce a short score. You then set a threshold and a sizing map:
- Score 0 to 2: no trade.
- Score 3: trade at 0.5 percent risk.
- Score 4: trade at 0.75 percent risk.
- Score 5: trade at 1.0 percent risk.
Equal weights are the right starting point. It is tempting to give volume a weight of 2 because it feels more important, but until you have tested each factor's contribution in isolation you are guessing. A clean way to test is to run the backtest with each factor removed in turn and see which removal hurts the result most. That ranking tells you more than intuition does.
Worked example: scoring one setup and sizing by score
This example is illustrative. The prices are chosen for clarity and are not a record of a real trade.
Account and instrument. Account 20,000 USD. Instrument EURUSD. One standard lot is 100,000 units, so a one pip move (0.0001) is worth 10 USD per lot. The trading timeframe is 15 minutes, the higher timeframe is 4 hours.
The bar under review. Price has pulled back to 1.0850 after a move up. The factor checks come out as follows:
- Trend: close 1.0852, 50 EMA 1.0838. Close above EMA. Factor true, 1 point.
- Higher timeframe: the last completed 4 hour bar closed at 1.0861, its 50 EMA is 1.0812. Factor true, 1 point.
- Momentum: RSI is 47.3. Inside the 40 to 60 band. Factor true, 1 point.
- Structure: lowest low of the last 20 bars is 1.0846, current low is 1.0849, ATR is 0.0012, half an ATR is 0.0006. Distance 0.0003 is inside the band. Factor true, 1 point.
- Participation: volume on this bar is 1,840 ticks, 20 bar average is 2,110 ticks. Below average. Factor false, 0 points.
Score: 4 out of 5. Per the sizing map, risk is 0.75 percent.
Risk amount: 20,000 x 0.0075 = 150 USD.
Stop placement: below the 20 bar low with a buffer of a quarter ATR: 1.0846 - 0.0003 = 1.0843. Entry at the next bar open, assume 1.0853. Stop distance = 1.0853 - 1.0843 = 0.0010 = 10 pips.
Position size: 150 USD / (10 pips x 10 USD per pip per lot) = 1.5 lots. Round down to 1.5 lots if your broker allows 0.01 lot steps; otherwise round down to 1.0 lot, which risks 100 USD or 0.5 percent.
Target: at 2R the target is 1.0853 + 0.0020 = 1.0873. Gross profit if filled: 20 pips x 10 USD x 1.5 lots = 300 USD. Spread and commission of, say, 1.2 pips round trip reduce both the win and the loss by 1.2 x 10 x 1.5 = 18 USD. Net win 282 USD, net loss 168 USD, realized ratio 1.68.
What the score bought you. If this had been a score 3 setup, the same stop and entry would be sized at 0.5 percent, which is 100 USD risk and 1.0 lot. If the volume factor had been true and the score were 5, risk would be 200 USD and 2.0 lots. The score does not change the trade; it changes how much of your account you commit to it. That is the entire point of scoring rather than filtering: a graded response instead of a binary one.
Original Pine Script v6 confluence indicator
The script below implements the five-factor framework as a separate pane indicator. It plots the long and short scores as columns and raises an alert when a score reaches the threshold on a confirmed bar. The higher timeframe values use the previous completed bar so the indicator does not repaint when the higher timeframe bar is still open.
//@version=6 indicator("Confluence Score (5 factor)", overlay = false)emaLen = input.int(50, "Trend EMA length", minval = 2) rsiLen = input.int(14, "RSI length", minval = 2) volLen = input.int(20, "Volume average length", minval = 2) swingLen = input.int(20, "Structure lookback (bars)", minval = 2) htf = input.timeframe("240", "Higher timeframe") minScore = input.int(3, "Minimum score to signal", minval = 1, maxval = 5)
ema = ta.ema(close, emaLen) rsi = ta.rsi(close, rsiLen) volAvg = ta.sma(volume, volLen) atr = ta.atr(14) loN = ta.lowest(low, swingLen) hiN = ta.highest(high, swingLen)
// Previous completed HTF bar only, so the value does not change intrabar. htfClose = request.security(syminfo.tickerid, htf, close[1], lookahead = barmerge.lookahead_on) htfEma = request.security(syminfo.tickerid, htf, ta.ema(close, emaLen)[1], lookahead = barmerge.lookahead_on)
// Long factors lTrend = close > ema lHtf = htfClose > htfEma lMom = rsi >= 40 and rsi <= 60 lStruct = (low - loN) <= atr * 0.5 lVol = volume > volAvg
// Short factors sTrend = close < ema sHtf = htfClose < htfEma sMom = rsi >= 40 and rsi <= 60 sStruct = (hiN - high) <= atr * 0.5 sVol = volume > volAvg
longScore = (lTrend ? 1 : 0) + (lHtf ? 1 : 0) + (lMom ? 1 : 0) + (lStruct ? 1 : 0) + (lVol ? 1 : 0) shortScore = (sTrend ? 1 : 0) + (sHtf ? 1 : 0) + (sMom ? 1 : 0) + (sStruct ? 1 : 0) + (sVol ? 1 : 0)
longSignal = longScore >= minScore and barstate.isconfirmed shortSignal = shortScore >= minScore and barstate.isconfirmed
plot(longScore, "Long score", color = color.new(color.green, 0), style = plot.style_columns) plot(-shortScore, "Short score", color = color.new(color.red, 0), style = plot.style_columns) hline(minScore, "Long threshold", color = color.gray, linestyle = hline.style_dotted) hline(-minScore, "Short threshold", color = color.gray, linestyle = hline.style_dotted)
alertcondition(longSignal, "Confluence long", "Long score reached threshold") alertcondition(shortSignal, "Confluence short", "Short score reached threshold")
Design notes:
- The
request.securitycalls useclose[1]withlookahead_on, which is the standard idiom for reading the last completed higher timeframe bar without repainting. Readingclosewithout the offset would show a value that keeps changing until the higher timeframe bar closes. The full discussion is in non-repainting indicators. - The momentum factor is deliberately the same for long and short: an RSI between 40 and 60 means momentum has reset, which is a precondition for a pullback entry in either direction. The trend factors decide the direction.
- Volume on forex charts is tick volume, not traded volume. It is still a usable proxy for participation but it varies by broker feed. On futures and equities it is actual contracts or shares.
- The structure factor is crude: proximity to the N bar low. A production version would use swing detection with left and right bars, or a user-drawn level. That is a scope decision, not a correctness issue.
To turn this into a position sizing tool, add an input for account size and risk per score tier, compute the stop from the structure level, and print the lot size in a table. We build that kind of panel regularly; the Pine Script development page describes the scope. The same scoring logic ports cleanly to an MT5 indicator or an EA, where the score feeds the lot calculation directly.
The same scoring in MQL5
If the score drives an expert advisor rather than a chart, the useful piece of code is the sizing function. Given a score, an account balance, a stop distance in price units and the instrument's tick value, it returns a lot size rounded down to the broker's step. Rounding down is deliberate: rounding to nearest can exceed the risk budget.
// Risk fraction by confluence score. Scores below 3 return 0 (no trade). double RiskFractionForScore(const int score) { if(score >= 5) return 0.0100; if(score == 4) return 0.0075; if(score == 3) return 0.0050; return 0.0; }// Lot size for a given risk fraction and stop distance, rounded DOWN to the lot step. double LotsForRisk(const string symbol, const double riskFraction, const double stopDistance) { if(riskFraction <= 0.0 || stopDistance <= 0.0) return 0.0;
double balance = AccountInfoDouble(ACCOUNT_BALANCE); double tickSize = SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_SIZE); double tickValue = SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE); double lotStep = SymbolInfoDouble(symbol, SYMBOL_VOLUME_STEP); double minLot = SymbolInfoDouble(symbol, SYMBOL_VOLUME_MIN); double maxLot = SymbolInfoDouble(symbol, SYMBOL_VOLUME_MAX); if(tickSize <= 0.0 || tickValue <= 0.0 || lotStep <= 0.0) return 0.0;
double riskMoney = balance * riskFraction; double lossPerLot = (stopDistance / tickSize) * tickValue; // money lost per 1.0 lot at the stop double rawLots = riskMoney / lossPerLot; double steppedLots = MathFloor(rawLots / lotStep) * lotStep;
if(steppedLots < minLot) return 0.0; // cannot respect risk budget, skip return MathMin(steppedLots, maxLot); }
Returning zero when the stepped lot size falls below the minimum lot is the correct behavior for a risk-first system. The alternative, trading the minimum lot anyway, silently exceeds the risk budget on small accounts and is one of the most common reasons an EA fails a prop firm daily loss rule; see prop firm EA rules for why that matters.
Where confluence goes wrong
Double counting
The most common error. A trader lists "price above 20 EMA, price above 50 EMA, MACD positive, 20 EMA above 50 EMA" as four confluence factors. These are four views of one fact: price has been rising recently. The score looks like 4 but carries the information of 1. Use the category table above and take one factor per row.
Filter stacking until nothing triggers
Every additional required factor cuts the number of trades. Five required factors, each true a third of the time and partially correlated, might leave a handful of trades a year. That is not enough to evaluate anything. Scoring with a threshold, rather than requiring every factor, keeps the sample size usable while still grading quality.
Hindsight confluence
After a move, it is always possible to find three things that "lined up" at the turn. This is why the factors must be defined as code that evaluates on the bar where you would have acted, not drawn afterwards. The Pine script above is a useful discipline for exactly this reason: it cannot see the future, so if the score was 2 at the time, it was 2.
Unvalidated weights
Weighting volume at 2 and trend at 1 because it feels right is a parameter choice with no evidence behind it. Start equal, test by removal, and only change weights when the test says so. Then check that the weighted version still works on data you did not fit it on.
Treating the score as a probability
A score of 4 out of 5 is not an 80 percent chance of success. It is an ordinal rank of setup quality under your own definitions. The relationship between score and outcome has to be measured in your log; it is not implied by the arithmetic.
Testing a confluence system
Because the score is ordinal, the most useful backtest output is a breakdown of results by score tier rather than one aggregate number. For each tier report the number of trades, the average R, the win rate and the maximum consecutive losses. If higher tiers do not produce better average R than lower tiers, the score is not measuring what you think it is measuring, and the sizing map will make things worse by putting the most money on setups that are not actually better. This tier analysis is a standard deliverable in our backtesting service, and the tooling options are compared in backtesting platforms compared.
Also check factor stability over time. A factor that contributed strongly in one year and nothing in the next is probably fitting a regime. Rolling window analysis, where you compute the per-factor contribution over successive six month windows, exposes this quickly.
Confluence inside other strategies
Confluence is not a strategy on its own; it is a quality filter or a sizing input that sits on top of an entry method. It combines naturally with breakout entries such as the opening range breakout, where the higher timeframe trend and the gap direction act as confluence for the breakout direction. It combines with mean reversion, where structure and momentum reset are the primary factors. And it combines with discretionary trading, where the indicator serves as a pre-trade checklist that stops you from entering on a score of 1 because the candle looked nice.
FAQ
What is a confluence in trading, in one sentence?
A confluence is a point on the chart where several independent analysis methods agree on the same trade at the same price and time, which traders use as evidence that the setup is higher quality than any one method would suggest alone.
How many confluence factors do I need?
Three to five from different categories is a practical range. Fewer than three and you are essentially trading a single signal; more than five and the factors are almost certainly overlapping, and the setup frequency drops too far to evaluate. Use a score and a threshold rather than requiring all of them.
Is a confluence indicator better than a single indicator?
It is more specific, which is different from better. A well-built confluence score should reduce the number of trades and raise the average quality. Whether it improves expectancy after costs depends on the market, the factors chosen and whether they are genuinely independent. That has to be tested, not assumed.
Can I use confluence for position sizing?
Yes, and that is arguably its most useful application. Mapping score tiers to risk fractions, as in the worked example, gives a graded response: more risk on setups where more evidence agrees, less where it does not, and none below a threshold. Keep the top tier within whatever your overall risk rules allow.
Does confluence work on all timeframes?
The concept applies on any timeframe, but the factor definitions change. On a 1 minute chart, a session open is a major time factor and a daily level is a major structure factor. On a daily chart, the session open is irrelevant and a weekly or monthly level takes its place. Define factors relative to the timeframe you trade and one or two steps above it.
Why does my confluence indicator repaint?
Almost always because a higher timeframe value is read from the currently forming higher timeframe bar, or because a swing point is identified using bars to the right that did not exist at the time. The fix is to read the previous completed higher timeframe bar and to only confirm swings after the right-hand bars have closed. The script in this article does the first; swing confirmation is a separate topic covered in non-repainting indicators.
Where Viprasol fits
Viprasol builds confluence tooling as both chart indicators and automation components. On TradingView that means a configurable factor panel with per-factor weights, a tiered sizing table and alerts that carry the score in the message, built under Pine Script development. On MetaTrader it means the same scoring inside an EA that sizes positions from the score and respects a daily loss cap, under MT5 expert advisor development. If the signals should flow from TradingView to a broker, the webhook bridge carries the score and the stop in the payload. Free calculators, including the lot size math from the worked example, are on the tools page; pricing is on the pricing page, and you can describe your factor list through the contact form.
Risk disclaimer: trading forex, futures, CFDs and crypto involves substantial risk of loss. This article is educational, not investment advice; a confluence score is a ranking of setup quality under your own definitions, not a probability of profit.
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.