All posts
PublishedByEvidence recordMoving averageSlopeSMAEMASettingsBacktestUSDJPY

Moving Average Slope Settings: 2,100 Tests

Test moving average slope settings across periods, lookbacks and five MA methods. Compare USD/JPY annual returns, win rates, year transfers, filters and costs.

A moving average slope strategy buys when the line points up and sells when it points down. Reproducing that rule requires two choices: the averaging period and the earlier bar used for comparison. Being above the value five bars ago does not require five consecutive rises.

Across 2,100 USD/JPY backtests, 104/175 hourly settings made money in both years, compared with 28/175 on the four-hour chart. The hourly default was profitable annually but lost in the first half of 2025. Longer periods did not consistently protect returns.

Profitable in both years / 175 settings each
M1593 / 175
H1104 / 175
H428 / 175
Profitable in both yearsNonpositive in at least one year
Settings profitable in both 2024 and 2025: M15 93/175, H1 104/175, H4 28/175.

How moving average slope is calculated

A moving average (MA) averages prices. This test uses closes and labels the slope upward when the current MA exceeds its value at the lookback bar. The path between those endpoints does not enter the comparison.

For a 20-period simple moving average (SMA), subtracting the previous bar's average cancels the shared closes. The difference equals the current close minus the close 20 bars earlier, divided by 20. With a five-bar lookback, the difference is the sum of the latest five closes minus the sum of five closes shifted back 20 bars, divided by 20. Old prices leaving the average can change its direction even without a rise in the current close. The research harness also checked this identity against the candle data.

No angle threshold is used. The apparent angle changes with the chart's horizontal and vertical scales. An unchanged average belongs to the sell condition in this test, so the rule also differs from one that stays out when the line is flat.

Moving average slope settings and signals

The MA is drawn over price candles. In Formiq's indicator settings, add a moving average and select period 20 and SMA to display the default example. One line is sufficient. Color and line width affect readability; there is no separate oscillator or angle level to add.

The trading rule is configured separately under the backtest trend conditions as MA slope. Match the chart's period and method to the trading rule when inspecting signals.

FieldTrading-rule defaultMeaning
Period20Averaging period
MethodSMASimple average; EMA, WMA, SMMA and HMA are also available
Lookback bars5Earlier MA value compared with the current value
DirectionBuy rising / sell fallingUpward only restricts entries to buys; downward only restricts entries to sells. The main test takes both sides

EMA is exponential, WMA is weighted, SMMA is smoothed, and HMA is the Hull moving average. Increasing the period brings older prices into the calculation. Increasing the lookback compares the current average with a more distant value. Both change response timing, but they change different parts of the calculation.

For SMA 20 with a five-bar lookback on H1 in 2025, the slope was upward on 3,181 bars. Of those, 854, or 26.85%, did not have five consecutive rises. This condition cannot reproduce a rule that requires the line to rise on every intervening bar.

How this was measured

The measurements use Formiq's backtester. No other entry rule was included in the main sweep, so the test measures trades generated by slope itself.

ItemCondition
PairUSDJPY
Years2025-01-01 to 2025-12-31; identical comparison over 2024-01-01 to 2024-12-31
Half-year windowsJanuary–June and July–December 2025, run separately
TimeframesM15 / H1 / H4
MA periods5, 10, 20, 30, 50, 100, 200
Lookbacks1, 2, 5, 10, 20 bars
MethodsSMA, EMA, WMA, SMMA, HMA
Grid size175 settings per timeframe and window; 2,100 runs
EntryBuy if the MA exceeds its earlier value; otherwise sell
ExitClose and reverse at the same bar close when direction changes; close remaining positions at the window end
Cost and sizeFixed 0.3-pip spread, 0.1 lot, no slippage
Main-sweep stops and targetsNone; added separately below

The 2024 comparison is a historical reference window. Applying a 2025 winner backward is not a forward test. Selecting settings after inspecting both years would require another unused period for validation.

Hourly settings retained more profitable results than H4

TimeframeProfitable in 2024Profitable in 2025Profitable in both2025 median (pips)
M15115/175115/17593/175+477.9
H1154/175122/175104/175+503.7
H4159/17536/17528/175−1,087.8

H4 had 159 profitable settings in 2024 but only 36 in 2025. Reading slope on a longer timeframe did not make annual returns stable.

Period 200 left only two settings profitable in both years

The hourly period comparison averages over 25 settings at each period, varying lookback and method. Mean pips are the arithmetic mean of separate annual backtests, not a combined portfolio return.

MA periodProfitable in both2024 mean (pips)2025 mean (pips)
524/25+1,669.1+1,312.2
1023/25+1,753.4+1,230.7
2020/25+1,235.9+1,008.4
3016/25+974.4+663.8
5016/25+900.9+242.7
1003/25+1,285.4−488.6
2002/25+1,804.9−1,228.5

Period 200 averaged +1,804.9 pips in 2024 and −1,228.5 pips in 2025. The 24/25 profitable settings at period 5 are not a forecast success rate: the settings share many trades and are not independent trials.

A longer lookback did not increase the profitable count

Each hourly lookback group contains 35 period-and-method settings.

Lookback barsProfitable in both2024 mean (pips)2025 mean (pips)
124/35+1,115.7+665.7
223/35+1,305.1+484.1
520/35+1,803.4+256.8
1019/35+1,754.4+245.4
2018/35+895.6+305.7

The five-bar lookback averaged +1,803.4 pips in 2024 but +256.8 pips in 2025. Choosing a more distant comparison value did not produce a consistent change in annual returns across years.

EMA and HMA each retained 24 of 35 settings

MA methodProfitable in both2024 mean (pips)2025 mean (pips)
SMA17/35+1,107.0+169.4
EMA24/35+1,560.1+539.8
WMA21/35+1,494.7+333.2
SMMA18/35+1,632.6+169.2
HMA24/35+1,079.8+746.0

EMA and HMA each had 24/35 settings profitable in both years, against SMA's 17/35. The counts compare the same candidate periods and lookbacks on H1; they do not establish superiority on other timeframes.

The default lost in the first half of a profitable year

These results use period 20, a five-bar lookback and SMA.

TimeframeYearTradesWin rateAnnual net (pips)
M1520251,19134.34%+913.0
M1520241,19935.36%+1,694.3
H1202528939.45%+875.5
H1202428237.94%+2,157.0
H420256835.29%−2,252.3
H420246535.38%+1,674.0

Splitting the hourly 2025 run reveals a loss followed by a profit.

WindowTradesWin rateNet (pips)
First half 202514835.81%−671.4
Second half 202514243.66%+1,522.8

Each half starts and ends independently. Closing a position at the boundary and starting again changes the trades, so adding the half-year counts and returns does not reproduce the full-year backtest.

Every 2024 winner fell below the 2025 median

The setting with the highest 2024 annual net was applied unchanged to 2025. All return columns are in pips.

TimeframePeriod / lookback / methodSelection-year netOther-year netOther-year median
M1550/20/SMA+3,855.5−1,921.5+477.9
H120/5/WMA+3,792.1+438.3+503.7
H450/2/SMMA+3,196.0−1,995.3−1,087.8

The transferred winner fell below the 2025 median on all three timeframes. On M15, period 50 with a 20-bar lookback and SMA went from +3,855.5 to −1,921.5 pips.

Applying each 2025 winner backward to 2024 gave these results:

TimeframePeriod / lookback / methodSelection-year netOther-year netOther-year median
M15100/2/HMA+2,568.4+2,129.1+490.0
H15/1/SMA+2,804.4−161.3+1,390.9
H4200/1/SMA+1,517.2+1,342.9+1,695.0

Hourly SMA 5 with a one-bar lookback earned +2,804.4 pips in 2025 but lost −161.3 pips in 2024. A favorable aggregate for period 5 does not mean every individual setting was profitable in both years.

How a 39.45% win rate produced a profit

The default H1 run in 2025 had 289 trades, a 39.45% win rate and +875.5 pips. Its average win was +73.66 pips and its average loss was −42.98 pips. Larger winning trades covered the more frequent losses.

The default H4 run in 2025 had 68 trades, a 35.29% win rate and −2,252.3 pips. Its +94.95-pip average win was smaller than its −102.98-pip average loss. Trade count and average win and loss size explain more than the win rate alone.

ADX did not improve annual net in both years

These additions restrict new entries on the hourly default. ADX uses period 14 without a directional requirement; exits still follow MA slope alone. The session restriction also leaves exits unrestricted.

Added ruleYearTradesAnnual net (pips)
None2024282+2,157.0
None2025289+875.5
ADX ≥ 202024198+1,257.6
ADX ≥ 202025194+913.0
ADX ≥ 252024145+1,297.1
ADX ≥ 252025142−286.1
UTC 07:00–16:002024238+2,675.4
UTC 07:00–16:002025246+478.0

ADX ≥ 20 increased annual net in 2025 but reduced it in 2024. ADX ≥ 25 lost money in 2025. The session restriction improved 2024 but reduced 2025 net. This comparison does not establish that ADX or session filters have no value under other trading rules.

A 50-pip stop and 100-pip target improved both years

The opposite-slope exit remains active. A stop or target closes the position first if reached before the signal exit. Stop and target distances are in pips.

Added ruleYearTradesAnnual net (pips)
None2024282+2,157.0
None2025289+875.5
Stop 50 / target 1002024532+2,290.0
Stop 50 / target 1002025524+2,027.1
Stop 100 / target 2002024341+1,893.3
Stop 100 / target 2002025337+914.5

The 50-pip stop and 100-pip target increased annual net in both years, but also increased trade count. After a stop or target exit, an unchanged slope permits another entry. This comparison therefore changes more than the loss size of the original trades. The wider 100-pip stop and 200-pip target reduced 2024 annual net.

The hourly default remained profitable at a 1.0-pip spread

The cost comparison uses the 2025 hourly default without stops or targets.

Spread (pips)TradesAnnual net (pips)
0289+962.1
0.3289+875.5
1.0289+673.2

Changing the spread leaves the timing of all 289 trades unchanged under this signal-only exit. The break-even spread is approximately 3.33 pips. That measures room for a fixed cost; it excludes swaps and variable spreads during actual trading.

Notes

The sample covers USDJPY in 2024 and 2025. Each signal uses closes through the current bar and fills at that same close. Candles before the test window initialize the averages; period 20 with a five-bar lookback requires at least 25 history bars. Spread is fixed, with no slippage or swaps. If a stop and target are both reached within one bar, the stop takes precedence.

Questions people ask

How do you calculate moving average slope?
This test compares the current average with its value a specified number of bars earlier. It uses no angle threshold: the visual angle changes with chart scaling.
Does a five-bar lookback require five consecutive rises?
No. On H1 in 2025, SMA 20 was above its value five bars earlier on 3,181 bars. Of those, 854, or 26.85%, did not have five consecutive rises.
Does a longer moving average avoid false signals?
Length alone did not improve annual returns. On H1, 24/25 settings at period 5 were profitable in both years, compared with 2/25 at period 200. These are standalone slope trades, not tests of adding slope to another entry rule.
Where are the slope settings in Formiq?
Select MA slope under the backtest trend conditions, then set period, method, lookback and direction. Add the moving average separately in chart display settings.

Formiq is a free browser-based FX terminal with replay practice and no-code backtesting. Open the chart or see what the free plan includes.