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
示意性 — 合成数据,非实时报价。
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 Take MACD's MAIN_LINE (fast EMA − slow EMA)
- 2 Take its SIGNAL_LINE (the average of MAIN)
- 3 Plot MAIN − SIGNAL as bars around zero
显示公式与计算详情
The Moving Average of Oscillator is one subtraction applied to MACD:
- Take MACD’s MAIN_LINE — the fast EMA minus the slow EMA.
- Take its SIGNAL_LINE — MAIN_LINE averaged over the signal period.
- 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.
信号
OsMA 提供的可回测信号 — 及每个信号适合的市场状态。
Re-acceleration Above Zero
Builder 可实现Shrinking Bars
Builder 可实现Divergence from Price
高级逻辑MT5 实现
MetaTrader 5 实际计算和绘制的内容——本页每条规则的依据。
缓冲区
| 索引 | 缓冲区 | MT5 中的绘制方式 | 存放内容 |
|---|---|---|---|
| 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. |
平台说明
最佳适用场景 / 谨慎使用
没有任何指标具有普适优势。以下是 OsMA 发挥作用的场景 — 以及可能误导的场景。
最佳适用场景
- 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
谨慎使用
- 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
构建 OsMA 策略
将信号接入进场和出场规则,然后导出可编译的 MT5 EA — 无需编写代码。
- OsMA read at the current bar
- A second OsMA node read 3 bars back
- Cross the two — rising above the older value means the bars are growing again
- Compare OsMA against a Constant of 0 to fix the direction
- Both true → Open Buy · SL 45 / TP 135
- Stop then trails an EMA(20)
将 OsMA 与其他指标组合
单一指标很少独立有效。这些组合弥补了 OsMA 的盲点。
OsMA + MACD
- OsMA above zero
- OsMA rising against its own past
- Buy
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.
打开 Builder →OsMA + ADX
- OsMA crosses zero
- ADX above 25
- Buy
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.
打开 Builder →OsMA + Moving Average
- Price above the EMA(200)
- OsMA turns up above zero
- Buy
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.
打开 Builder →参数
在您自己的货币对和时间框架上验证的起始值 — 非保证设置。
| 参数 | 默认值 | 建议测试范围 | 功能说明 |
|---|---|---|---|
| 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. |
初始预设
市场示例
OsMA 有效的场景、失效的场景,以及过滤器如何改变结果。
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.
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.
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.