Oscillators MomentumZero LineAcceleration Available in Builder

Moving Average of Oscillator

OsMA

OsMA is MACD's main line minus its signal line, published as one buffer. It is the indicator most charting packages draw as the 'MACD histogram' — in MetaTrader that histogram is a separate indicator with its own function, and its zero line is the exact moment MACD's two lines cross.

Fast / Slow EMA
12 / 26
Signal period
9
Zero line
MACD cross
Zero — the MACD/Signal crossOsMA(12, 26, 9) — MAIN − SIGNAL

Illustrative — synthetic data, not a live quote.

What OsMA tells you

OsMA measures the gap between MACD's two lines. When the gap widens the move is accelerating; when it narrows the move is losing pace even if price is still going. Because the gap is zero exactly when the two lines touch, OsMA turns a two-line crossover into a single sign change — which is why a rule written on OsMA needs one value where a MACD rule needs two.

  • Above zero: MAIN is above SIGNAL — MACD is in its bullish arrangement
  • Bars growing: the two lines are separating, so the move is accelerating
  • Bars shrinking: they are converging, and a cross is being approached
  1. 1 Take MACD's MAIN_LINE (fast EMA − slow EMA)
  2. 2 Take its SIGNAL_LINE (the average of MAIN)
  3. 3 Plot MAIN − SIGNAL as bars around zero
Show the formula & calculation detail

The Moving Average of Oscillator is one subtraction applied to MACD:

  1. Take MACD’s MAIN_LINE — the fast EMA minus the slow EMA.
  2. Take its SIGNAL_LINE — MAIN_LINE averaged over the signal period.
  3. Plot the difference: OsMA = MAIN − SIGNAL.

That single buffer is drawn as bars around a zero line. The zero line is not an arbitrary level: OsMA = 0 is precisely the condition MAIN = SIGNAL, so every sign change in OsMA is a MACD crossover happening at the same bar. Where a MACD rule reads two buffers and compares them, an OsMA rule reads one and asks whether it is positive.

In MQL5 the call is iOsMA(symbol, period, fast_ema_period, slow_ema_period, signal_period, applied_price). The three periods are MACD’s, because the calculation underneath is MACD’s — OsMA has no settings of its own. The applied price is a real argument here and it feeds the moving averages, so changing it changes the whole construction.

What OsMA adds over the crossover is the size of the gap. Two lines that are far apart and separating describe a different market from two lines that are far apart and closing, and a crossover rule cannot tell them apart because neither has crossed yet. This is the reason the Builder template does not trade the sign change at all: the zero cross would produce the same EA as the MACD Signal template, so the rule is placed on the bars instead — OsMA rising above its own value three bars ago, while still on the trend side of zero, which describes a pullback that has started moving again.

One naming caution, because it causes real errors when porting strategies. MetaTrader draws MACD’s MAIN_LINE as the histogram. Almost every other charting package draws MAIN as a line and MAIN − SIGNAL as the histogram. Both are called “the MACD histogram” and they cross zero at completely different moments — MT5’s when the two EMAs cross, everyone else’s when the two MACD lines cross. If a strategy from elsewhere refers to the histogram, the MetaTrader indicator it means is this one.

Signals

The distinct, backtestable signals OsMA gives — and the regime each one suits.

Zero-Line Cross

Builder ready
Condition
OsMA changes sign
Best regime
Trending
Typical use
Trade the MACD crossover as one condition instead of two

Re-acceleration Above Zero

Builder ready
Condition
OsMA rises above its own value N bars ago while still above zero
Best regime
Trending
Typical use
Enter a pullback that has resumed, without waiting for a fresh cross

Shrinking Bars

Builder ready
Condition
OsMA is above zero but each bar is smaller than the last
Best regime
Trend exhaustion
Typical use
Warn that a cross is coming before it happens

Divergence from Price

Advanced logic
Condition
Price makes a new extreme, OsMA's peaks do not
Best regime
Trend exhaustion
Typical use
A discretionary read that acceleration has stopped confirming price

MT5 implementation

What MetaTrader 5 itself computes and draws — the reference every rule on this page is written against.

Buffers

Index Buffer Drawn in MT5 as What it holds
0 MAIN_LINE Histogram MACD's MAIN_LINE minus its SIGNAL_LINE, drawn as bars around zero. There is only this one buffer — the two series it is built from live in iMACD, not here.

Platform notes

Works best / use carefully

No indicator is a universal edge. Here is where OsMA helps — and where it misleads.

Works best

  • Turning a MACD crossover rule into a single condition
  • Judging whether a trend is still accelerating
  • Timing a pullback entry inside an established trend
  • Higher timeframes, where the bars are less erratic

Use carefully

  • Any fixed threshold — the scale depends on the instrument
  • Ranging markets, where the sign flips constantly
  • Comparing OsMA readings across symbols or timeframes
  • Assuming it leads price; it leads the crossover, which is not the same thing

Build a strategy with OsMA

Wire the signal into entry and exit rules, then export a compilable MT5 EA — no code.

  1. OsMA read at the current bar
  2. A second OsMA node read 3 bars back
  3. Cross the two — rising above the older value means the bars are growing again
  4. Compare OsMA against a Constant of 0 to fix the direction
  5. Both true → Open Buy · SL 45 / TP 135
  6. Stop then trails an EMA(20)

Combine OsMA with other indicators

One indicator rarely stands alone. These pairings cover OsMA's blind spots.

OsMA + MACD

  1. OsMA above zero
  2. OsMA rising against its own past
  3. Buy
Why
Read the same calculation two ways — MACD shows where the lines are, OsMA shows how fast the gap between them is changing, so one gives the state and the other gives the rate
Best regime
Trending

No template places MACD and OsMA in one flow, because it would say the same thing twice — OsMA is MAIN − SIGNAL, so its sign already carries MACD's crossover. The OsMA Re-acceleration + Zero Line template is the one-indicator form.

Open Builder →

OsMA + ADX

  1. OsMA crosses zero
  2. ADX above 25
  3. Buy
Why
OsMA changes sign just as readily in a flat market as in a trend; requiring ADX above 25 removes the stretch where the crosses mean nothing
Best regime
Trending

No single-flow template pairs OsMA with ADX. Start from OsMA Re-acceleration + Zero Line and add an ADX node with a Compare at 25, the same filter the Parabolic SAR template uses.

Open Builder →

OsMA + Moving Average

  1. Price above the EMA(200)
  2. OsMA turns up above zero
  3. Buy
Why
Take direction from a long moving average and use OsMA only for timing, so the acceleration signal is never traded against the larger trend
Best regime
Trending

No single-flow template pairs OsMA with a long moving average. Start from OsMA Re-acceleration + Zero Line and add an MA node with a Compare against Price.

Open Builder →

Parameters

Starting values to validate on your own pair and timeframe — not guaranteed settings.

Parameter Default Suggested test range What it does
Fast EMA period 12 5–30 The faster of the two moving averages inside MACD. Shortening it makes OsMA react sooner and cross zero more often; the setting belongs to the MACD underneath, not to OsMA itself.
Slow EMA period 26 20–60 The slower average. The distance between fast and slow sets how large OsMA's readings become, which is one reason absolute thresholds do not transfer between settings.
Signal period 9 5–20 The averaging window applied to MAIN_LINE to produce SIGNAL_LINE. OsMA is the difference between the two, so this parameter alone decides how quickly the bars return to zero. MT5 smooths with a simple moving average here, not an EMA.
Applied price PRICE_CLOSE Close, Open, High, Low, Median, Typical, Weighted Which price series feeds the moving averages. Unlike some MT5 volume indicators, iOsMA really does take this argument, and the Builder's generated code passes it through as an EA input.
Shift 0 0–30 Which bar back the node reads the buffer from. Two OsMA nodes at different shifts is how a rule expresses 'the bars are growing again' — that is exactly what the template does with 0 and 3.

Starting presets

Standard 12 / 26 / 9 MT5's defaults, and the template's
Faster 8 / 17 / 9 Reacts within the session; more sign changes
Slower 19 / 39 / 9 Fewer, larger swings around zero

Market examples

Where OsMA works, where it fails, and how a filter changes the outcome.

Works

Bars grow again inside a trend

OsMA never returned to zero during the pullback, and the bars start lengthening again — the trend resumed without the two MACD lines ever crossing back.

Fails

Sign change with nothing behind it

In a flat stretch OsMA flips above and below zero every few bars. Each flip is a valid MACD crossover and none of them lead anywhere, which is why a trend filter belongs on this signal.

Filtered

The zero condition blocks the trade

The bars expand while OsMA is still below zero — momentum is improving but the arrangement is bearish. Requiring the trend side skips a long entry taken against the larger move.

FAQ

Is OsMA the same as the MACD histogram?
It is the same quantity as the histogram most charting packages draw, but in MetaTrader it is a different indicator. MT5's MACD publishes MAIN_LINE and SIGNAL_LINE only, and it draws MAIN_LINE as the bars. The MAIN − SIGNAL bars you see elsewhere exist in MT5 as OsMA, reached with iOsMA. When a strategy from another platform mentions the histogram, OsMA is what it means.
Why use OsMA instead of MACD if they cross at the same moment?
Because it takes one value rather than two. An OsMA rule reads a single buffer and asks whether it is positive; a MACD rule reads two buffers of the same handle and compares them. The crossing moment is identical, so the reason to prefer OsMA is that it also states how far apart the lines are — which is what lets a rule ask whether the gap is widening, something a crossover cannot say.
What does it mean when the bars shrink?
The two MACD lines are converging. Price may still be making progress, but it is doing so more slowly than the slow average is catching up, so the crossover is approaching. Shrinking bars above zero are a warning that the bullish arrangement is being given back, not yet a signal that it has been.
Can I set a threshold like 'OsMA above 0.001'?
Not one that transfers. OsMA is a difference between two moving averages of price, so its magnitude depends on the instrument, the timeframe and the fast/slow settings. A level tuned on EUR/USD H1 means nothing on gold or on M5. Compare against zero, or against OsMA's own value some bars back — both survive the change of scale.
Can I build an OsMA EA without coding?
Yes. The OsMA Re-acceleration + Zero Line template places two OsMA nodes — one at the current bar, one three bars back — crosses them to detect the histogram expanding again, and requires OsMA to be on the trend side of zero before acting. The periods, the lookback and the trailing stop are all EA inputs.
How should I validate settings before going live?
Backtest on quality tick data, then run on a demo account before risking money. OsMA inherits MACD's weakness in flat markets, so pay attention to how the equity curve behaves during ranging periods rather than only to the headline profit. Hold back data the search never saw, and prefer settings that stay profitable across periods rather than the single best combination.