Unlike the indicators on this site, which only draw on the chart or fire alerts, an Expert Advisor places real orders for you. This free EA trades a single, transparent strategy built around the OsMA histogram crossing its zero line: it enters the moment the MACD line crosses its signal line, then manages Stop Loss, Take Profit, and position size automatically from the same risk tools taught elsewhere on this site.
How the Strategy Works
The entry signal is the zero-line cross of the OsMA histogram — the Moving Average of Oscillator explained in the OsMA lesson. OsMA is the distance between the MACD line and its signal line: positive when the MACD line is above its signal, negative when it's below. So an OsMA zero cross is exactly the same event as a MACD signal-line crossover, just read off a histogram instead of two lines. This EA uses the standard 12/26/9 MACD settings, so it trades the classic MACD crossover with none of the ambiguity of eyeballing where two wiggling lines meet.
Trading OsMA rather than watching the two MACD lines directly has one practical benefit even for an automated system: the signal is a single value crossing a single level, which is unambiguous to code and to backtest. There's exactly one condition to check per bar — is the histogram above or below zero, and did that just change — which keeps the strategy short and its behavior easy to reason about.
Stop Loss, Take Profit, and Position Sizing
Stops and targets here come from ATR, not fixed pips — when the pair moves more, the stop widens; when it quiets down, the stop tightens, tracking current conditions instead of a number set once and forgotten. Stop Loss distance is ATRMultiplier × ATR (default multiplier 2.0, with ATR over ATRPeriod = 14 bars), and Take Profit is set at RiskRewardRatio × Stop Loss distance (default 2.0), so every trade carries a fixed, known reward-to-risk proportion regardless of pair or timeframe.
Lot size comes from the same arithmetic taught in Risk Management Basics: the account fraction you risk (RiskPercent, default 1.0%) divided by the stop distance. A wider ATR-based stop on a volatile pair automatically produces a smaller lot, and a tighter stop on a calm pair a larger lot, so the dollar risk per trade stays roughly constant even as the price distance to the stop changes trade to trade. A UseFixedLot input is available as an escape hatch for a constant lot size — useful for testing, or for small accounts where percentage-based sizing rounds to the broker's minimum lot anyway.
Entry Conditions
- BUY — OsMA crosses from at-or-below zero to above zero on consecutive completed bars (the MACD line has just crossed above its signal line).
- SELL — OsMA crosses from at-or-above zero to below zero — the mirrored setup (the MACD line has just crossed below its signal line).
Beyond the signal itself, three safety mechanics govern every trade: the EA only evaluates these conditions once per new bar (not on every tick, so a single crossover can't fire multiple trades within the same candle), only opens one position at a time (a new signal is ignored while a position from this EA is already open), and only manages positions tagged with its own magic number (20260802) — so it never touches trades you open manually or trades placed by a different EA on the same account. A spread filter also sits in front of every entry: if the current spread is wider than MaxSpreadPoints, the EA skips that bar entirely rather than opening a trade at a bad price during illiquid conditions.
Parameters
- FastEMA (default 12) — the fast EMA period inside the MACD the OsMA is derived from.
- SlowEMA (default 26) — the slow EMA period.
- SignalSMA (default 9) — the signal-line smoothing period OsMA measures against.
- AppliedPrice (default Close) — the price series the calculation runs on.
The rest of the inputs belong to the shared risk engine every EA here uses: stop and target sizing, position sizing, the spread filter, and the master switch. They are documented once on the EA hub page rather than repeated on every lesson. Orders from this EA carry the magic number 20260802.
Why Trade the Histogram Cross Instead of the Histogram Turn
The OsMA lesson explains that the histogram turns (stops growing and starts shrinking) one step earlier than it crosses zero. This EA deliberately trades the later, more conservative event — the zero cross — rather than the earlier turn, and the reason is reliability. The histogram turning is an aggressive, early read that momentum is decelerating, but decelerating momentum frequently re-accelerates without ever crossing zero, so an EA that fired on every turn would take a large number of premature trades that the trend then invalidates. Waiting for the actual zero cross sacrifices some entry price in exchange for a signal that only fires once the MACD relationship has genuinely flipped, which is a much cleaner rule to automate.
That conservatism doesn't rescue OsMA from its core weakness, which it inherits directly from the MACD: it is a lagging, moving-average-of-moving-averages construction, so in a sharp reversal it confirms the turn well after price has moved, and in a sideways market it crosses zero over and over on meaningless wobbles. This EA therefore performs best in trending or freshly breaking-out markets and worst in tight, directionless ranges. Confirming trend vs range conditions before running it on a given pair, or layering an ADX or higher-timeframe trend filter on top, is the natural way to improve its results — the EA itself makes no attempt to detect that condition and simply trades the cross wherever it happens.
A Word of Caution
Run it on a demo account first, through different market conditions, before real money is involved; past results, whether from backtests or live trading, guarantee nothing about the future. There is no rule set, manual or robotic, that avoids losses — this EA will have losing trades. Because OsMA is derived from moving averages, its zero-cross signal lags real price turns and whipsaws badly in ranging markets, where you should expect a run of small losing trades in quick succession. Consider pairing this EA with a trend filter, or only running it on pairs and timeframes you've confirmed are trending, rather than leaving it on every chart in every condition. Both downloads are plain source files — read them end to end and make sure you understand each input before trusting them with an order. Nothing on this page is personalized investment advice; it is general education about how the tool works.