The Gap Between Perception and Code
What the Trader Sees on Chart
Price touches a clear horizontal zone, bounces twice. The trader sees a level. A trade feels obvious.
What the EA Sees in Code
if (Close[0] > iMA(14, MODE_EMA, H4)) {
// trend is up
}if (Close[0] > Highest(High, 20)) {
// breakout โ enter long
}The EA has no concept of "support zone." It checks an EMA and a lookback high. If conditions don't align with where the human sees support, the EA does not act.
The core insight: Support and resistance exist in trader perception. Code requires numerical conditions. These are not the same thing โ and understanding the gap is the key to setting realistic expectations for any EA.
Why Does Your XAUUSD EA
Ignore Support and Resistance?
Published 15 June 2026 ยท 10 min read
Your EA ignores support and resistance because "support" is not a numerical condition that MT5 can evaluate natively. The EA trades whatever rules are in its code โ if those rules do not include a support/resistance check, price at a key level is invisible to it. This is not a bug. It is the fundamental limitation of converting discretionary analysis into code, and understanding it changes how you set expectations for any automated gold strategy.
What Support and Resistance Actually Are โ Mathematically
When a trader draws a support level on a chart, they are identifying a price range where historical buying pressure has exceeded selling pressure with enough consistency to cause price bounces. This is a qualitative observation that incorporates: the number of times price touched the level, how cleanly price bounced, how recent the touches are, and whether the level aligns with round numbers, previous highs/lows, or Fibonacci retracements.
None of these criteria have universally agreed numerical definitions. One trader draws the zone at the candle closes, another at the wicks. One considers three touches minimum, another accepts two. One weights recent touches more heavily, another treats all touches equally. This subjectivity is precisely what makes S/R useful for human traders โ it aggregates qualitative market reading โ and precisely what makes it nearly impossible to code into a rule-based system.
Historical pivot points
CodeablePrevious day/week high and low. Clean, reproducible, widely watched by institutions. Can be calculated as a formula.
Round numbers
CodeablePrices ending in .000, .500, or .250. Gold traders heavily watch $2,300, $2,350, $2,400 etc. Simple modulo arithmetic.
Fibonacci retracements
CodeableFixed ratios (0.382, 0.618) of a defined swing range. The swing itself requires algorithmic identification โ the main challenge.
Manually drawn zones
Not codeableThe most common form of S/R on retail charts. Cannot be coded without introducing subjective parameters that create overfitting.
Trend-based S/R
Not codeableThe level where a trend "should" pause based on market structure. Requires discretionary context that resists algorithmisation.
Institutional levels
Not codeableWhere large orders are believed to sit. Visible only in DOM/market depth data, which most EAs do not access.
How Codeable Is Each Trading Concept?
Select a concept to see how difficult it is to implement reliably in an MT5 EA.
How EAs Approximate Support and Resistance
Rather than coding S/R directly, robust EAs use algorithmic approximations that capture the same market dynamic without requiring subjective zone drawing. The most effective approaches for XAUUSD:
Lookback high/low as range boundaries
rangeHigh = Highest(High, 20); rangeLow = Lowest(Low, 20)The N-period high and low define a trading range programmatically. Price near the top of this range is effectively "at resistance" without requiring a human to draw a zone. This is the most widely used S/R approximation in production EAs.
Pivot point formulas
PP = (H + L + C) / 3; R1 = 2*PP - L; S1 = 2*PP - HStandard pivot points are calculated from the previous day's OHLC and provide four to six price levels that are objective, reproducible, and widely watched. They work particularly well on XAUUSD because gold markets have clear daily rhythms.
Round number proximity filter
isRoundNumber = (MathMod(Price, 100) < 5 || MathMod(Price, 100) > 95)Gold traders watch round dollar levels intensely โ $2,300, $2,350, $2,400. An EA can check whether price is within a few pips of a round number and adjust behaviour accordingly (pause entries or widen stops).
Goldie Razor V2.8.4 uses the lookback approach for range identification โ identifying the recent high and low over a defined M15 lookback period and trading the breakout of those boundaries. This is a programmatic equivalent of the range a human trader would visually identify on the chart, without requiring any subjective zone drawing.
Setting EA Parameters That Align With Key Levels
Even if your EA does not explicitly trade S/R, you can configure parameters that cause the EA to naturally avoid the most dangerous S/R zones. This is often more effective than trying to code S/R detection directly:
Max spread filter
S/R levels often coincide with spread spikes as market makers widen spreads at key levels. A spread filter of 40โ50 pips naturally avoids many S/R-related adverse entries.
ATR minimum threshold
Low ATR environments often mean price is consolidating at or between S/R levels. An ATR minimum filter avoids trading in this compressed environment.
Lookback period for range
On M15, a 20-bar lookback defines approximately 5 hours of range. Increasing this to 40 bars gives a wider range that better aligns with major S/R zones visible on H1 and H4.
Session filter
Major S/R tests most often happen at session opens (London 08:00 GMT, New York 13:00 GMT). If your EA has a time filter, include these sessions. Avoid trading in the Asian session when S/R levels are less actively tested.
Related Reading
MA vs price action for XAUUSD EAs
The broader comparison of which indicator approach codes more reliably into an Expert Advisor.
What indicators work in gold EAs
A full review of every indicator commonly used in XAUUSD EAs โ with honest notes on where each fails.
EMA settings that approximate trend direction
The specific MA periods that provide the most reliable directional context on gold.
Best single indicator for XAUUSD
If one indicator had to substitute for S/R reading, this is the most defensible candidate.
What automated strategies actually use
The strategies that get around the S/R coding problem by using algorithmic approximations.
Frequently Asked Questions
Not in the discretionary sense. What a human calls a support level involves weighting multiple timeframes, market context, recent price behaviour, and a qualitative sense of market structure. An EA can only use rules that produce a true/false output. The closest approximation is a lookback-based pivot point (highest/lowest close over N bars) combined with an ATR tolerance band. This is a codeable approximation โ useful and often effective โ but it is not the same as how a skilled manual trader identifies levels.
Your EA is not checking for support. It is checking whatever conditions are in its code โ usually MA crossover, ATR level, or a breakout condition. If those conditions do not align with the support level at that moment, the EA will not act. The EA does not "see" the level because support is not a condition in the code. This is not a flaw โ it is a feature. The EA trades its rules consistently; it does not interpret the chart.
Pivot point formulas (Standard, Camarilla, Fibonacci) provide objective, reproducible price levels that approximate institutional support/resistance and are fully codeable. Round number detection (price ending in .000 or .500) is another clean approach for gold. For dynamic levels, the lookback high/low over 20โ50 bars gives a programmatic approximation of the "range" concept. Each of these avoids the subjectivity of manual zone drawing.
Possibly โ but it could equally be a spread or timing problem. Gold at key resistance levels often has wider spreads and faster price movement immediately after the touch. Even if your EA's logic is unrelated to S/R, if it happens to fire entries near key levels (which are often coincident with round numbers and ATR extremes), the adverse price action at those levels can cause the first candle after entry to spike against you. Check whether losses cluster around specific price levels or round numbers.
This is underused but effective. Rather than trying to trade support/resistance bounces (hard to code), you can code a filter that pauses the EA when price is near a key level โ defined as within 15โ20 pips of the N-period high or low. This avoids taking breakout entries that are about to fail at a major level. It is simpler to code, easier to test, and reduces false breakout losses significantly on XAUUSD.
Goldie Razor V2.8.4
M15 breakout + H4 EMA filter โ built for XAUUSD on MT5