Moving Average of Oscillator
The OsMA is the difference between an oscillator and its moving average, used to confirm trading signals.
Role in the strategy
| Slot | Available | Role |
|---|---|---|
| Entry Point | No | — |
| Entry Rule | Yes | Filters entries by the OsMA direction or its level position. |
| Exit Point | No | — |
| Exit Rule | Yes | Triggers exits by the OsMA direction or its level position. |
The Moving Average of Oscillator produces conditions, not order prices. As an entry rule it is ANDed with the entry point and the other entry rules; as an exit rule it is ORed with the other exit rules. See Indicators for the slot semantics.
Logic rules
The indicator offers the standard oscillator rule set, evaluated on the OsMA value:
| Rule | Long signal is 1 when | Short signal is 1 when |
|---|---|---|
| Indicator rises | OsMA rose on the previous bar | OsMA fell on the previous bar |
| Indicator falls | OsMA fell on the previous bar | OsMA rose on the previous bar |
| Indicator is higher than the Level line | OsMA is above Level | OsMA is below −Level |
| Indicator is lower than the Level line | OsMA is below Level | OsMA is above −Level |
| Indicator crosses the Level line upward | OsMA crossed above Level from below | OsMA crossed below −Level from above |
| Indicator crosses the Level line downward | OsMA crossed below Level from above | OsMA crossed above −Level from below |
| Indicator changes its direction upward | OsMA formed a valley (down then up) | OsMA formed a peak (up then down) |
| Indicator changes its direction downward | OsMA formed a peak (up then down) | OsMA formed a valley (down then up) |
The Level parameter sets the long threshold; the short threshold is always −Level.
Parameters
| Parameter | Type | Default | Range | Purpose |
|---|---|---|---|---|
| Apply to | select | Close | Open, High, Low, Close, Median, Typical, Weighted | Price series the MACD is calculated from |
| Fast EMA | number | 12 | 2 to 1000 | Period of the fast exponential average |
| Slow EMA | number | 26 | 2 to 1000 | Period of the slow exponential average |
| MACD SMA | number | 9 | 2 to 1000 | Period of the signal line |
| Level | number | 0 | −1000 to 1000 | Long threshold; the short threshold is −Level |
Calculation
tech.MACD and tech.MACDSignal in engine/indicator-engine/tech.ts compute the MACD line (Fast EMA − Slow EMA) and the Signal line (SMA of the MACD line); the OsMA value is the MACD line minus the Signal line. The result is drawn as bars named Indicator in a separate chart pane.
Backtesting
- The rule is evaluated on the previous (closed) bar with the standard dead zone (
SIGMA = 0.000001). - The indicator contributes only long/short signal arrays — it never changes the entry or exit order price.
- An entry happens only when the entry point allows the direction and every entry rule passes; an exit happens when the exit point is reached and any exit rule passes.