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.
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.
| Field | Trading-rule default | Meaning |
|---|---|---|
| Period | 20 | Averaging period |
| Method | SMA | Simple average; EMA, WMA, SMMA and HMA are also available |
| Lookback bars | 5 | Earlier MA value compared with the current value |
| Direction | Buy rising / sell falling | Upward 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.
| Item | Condition |
|---|---|
| Pair | USDJPY |
| Years | 2025-01-01 to 2025-12-31; identical comparison over 2024-01-01 to 2024-12-31 |
| Half-year windows | January–June and July–December 2025, run separately |
| Timeframes | M15 / H1 / H4 |
| MA periods | 5, 10, 20, 30, 50, 100, 200 |
| Lookbacks | 1, 2, 5, 10, 20 bars |
| Methods | SMA, EMA, WMA, SMMA, HMA |
| Grid size | 175 settings per timeframe and window; 2,100 runs |
| Entry | Buy if the MA exceeds its earlier value; otherwise sell |
| Exit | Close and reverse at the same bar close when direction changes; close remaining positions at the window end |
| Cost and size | Fixed 0.3-pip spread, 0.1 lot, no slippage |
| Main-sweep stops and targets | None; 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
| Timeframe | Profitable in 2024 | Profitable in 2025 | Profitable in both | 2025 median (pips) |
|---|---|---|---|---|
| M15 | 115/175 | 115/175 | 93/175 | +477.9 |
| H1 | 154/175 | 122/175 | 104/175 | +503.7 |
| H4 | 159/175 | 36/175 | 28/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 period | Profitable in both | 2024 mean (pips) | 2025 mean (pips) |
|---|---|---|---|
| 5 | 24/25 | +1,669.1 | +1,312.2 |
| 10 | 23/25 | +1,753.4 | +1,230.7 |
| 20 | 20/25 | +1,235.9 | +1,008.4 |
| 30 | 16/25 | +974.4 | +663.8 |
| 50 | 16/25 | +900.9 | +242.7 |
| 100 | 3/25 | +1,285.4 | −488.6 |
| 200 | 2/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 bars | Profitable in both | 2024 mean (pips) | 2025 mean (pips) |
|---|---|---|---|
| 1 | 24/35 | +1,115.7 | +665.7 |
| 2 | 23/35 | +1,305.1 | +484.1 |
| 5 | 20/35 | +1,803.4 | +256.8 |
| 10 | 19/35 | +1,754.4 | +245.4 |
| 20 | 18/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 method | Profitable in both | 2024 mean (pips) | 2025 mean (pips) |
|---|---|---|---|
| SMA | 17/35 | +1,107.0 | +169.4 |
| EMA | 24/35 | +1,560.1 | +539.8 |
| WMA | 21/35 | +1,494.7 | +333.2 |
| SMMA | 18/35 | +1,632.6 | +169.2 |
| HMA | 24/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.
| Timeframe | Year | Trades | Win rate | Annual net (pips) |
|---|---|---|---|---|
| M15 | 2025 | 1,191 | 34.34% | +913.0 |
| M15 | 2024 | 1,199 | 35.36% | +1,694.3 |
| H1 | 2025 | 289 | 39.45% | +875.5 |
| H1 | 2024 | 282 | 37.94% | +2,157.0 |
| H4 | 2025 | 68 | 35.29% | −2,252.3 |
| H4 | 2024 | 65 | 35.38% | +1,674.0 |
Splitting the hourly 2025 run reveals a loss followed by a profit.
| Window | Trades | Win rate | Net (pips) |
|---|---|---|---|
| First half 2025 | 148 | 35.81% | −671.4 |
| Second half 2025 | 142 | 43.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.
| Timeframe | Period / lookback / method | Selection-year net | Other-year net | Other-year median |
|---|---|---|---|---|
| M15 | 50/20/SMA | +3,855.5 | −1,921.5 | +477.9 |
| H1 | 20/5/WMA | +3,792.1 | +438.3 | +503.7 |
| H4 | 50/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:
| Timeframe | Period / lookback / method | Selection-year net | Other-year net | Other-year median |
|---|---|---|---|---|
| M15 | 100/2/HMA | +2,568.4 | +2,129.1 | +490.0 |
| H1 | 5/1/SMA | +2,804.4 | −161.3 | +1,390.9 |
| H4 | 200/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 rule | Year | Trades | Annual net (pips) |
|---|---|---|---|
| None | 2024 | 282 | +2,157.0 |
| None | 2025 | 289 | +875.5 |
| ADX ≥ 20 | 2024 | 198 | +1,257.6 |
| ADX ≥ 20 | 2025 | 194 | +913.0 |
| ADX ≥ 25 | 2024 | 145 | +1,297.1 |
| ADX ≥ 25 | 2025 | 142 | −286.1 |
| UTC 07:00–16:00 | 2024 | 238 | +2,675.4 |
| UTC 07:00–16:00 | 2025 | 246 | +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 rule | Year | Trades | Annual net (pips) |
|---|---|---|---|
| None | 2024 | 282 | +2,157.0 |
| None | 2025 | 289 | +875.5 |
| Stop 50 / target 100 | 2024 | 532 | +2,290.0 |
| Stop 50 / target 100 | 2025 | 524 | +2,027.1 |
| Stop 100 / target 200 | 2024 | 341 | +1,893.3 |
| Stop 100 / target 200 | 2025 | 337 | +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) | Trades | Annual net (pips) |
|---|---|---|
| 0 | 289 | +962.1 |
| 0.3 | 289 | +875.5 |
| 1.0 | 289 | +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.
Related articles
- Moving average crossover settings: entries generated by two lines crossing
- SMA versus EMA: differences between averaging methods
- False-signal filter tests: adding MA slope to other entry rules
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.