Adjustable MA (MA crossover EA)
EA that trades the crossover of two moving averages, with adjustable method, period and price
EA that places buy stop and sell stop orders outside an MA band built on High and Low prices
Open source, Apache License 2.0, by EarnForex.com. See licences
First release on this site.
Drag the EA onto a chart and enable Algo Trading. It uses the symbol and timeframe of that chart and needs at least 144 bars on the chart, otherwise it does not trade.
For a fixed lot set MaximumRisk to 0 and set Lots. The EA does not place orders if free margin is below 1000 times the calculated lot. TakeProfit and PipDifference are in pips, with the code adjusting for 5-digit and 3-digit symbols.
| Name | Default | Description |
|---|---|---|
| MA_Period | 144 | Period of the two MAs that form the band, one calculated on High prices and one on Low prices. |
| MA_Method | MODE_EMA | MA method (SMA, EMA, SMMA or LWMA). |
| TakeProfit | 115 | Take-profit distance in pips, measured from the calculated entry level. |
| PipDifference | 20 | Distance in pips from the MA band edge at which the pending orders are placed, so price has to break out first. |
| Lots | 0.1 | Fixed lot size. It is only used when MaximumRisk is 0. |
| MaximumRisk | 2 | Multiplier for sizing the lot from free margin (lot = free margin x this value / 50000). If above 0 the Lots input is ignored. 0 means fixed Lots. |
| Slippage | 3 | Maximum accepted slippage in points. |
| OrderCommentary | Binario | Comment text put on the orders the EA places. |
| Magic | 16384 | Magic number that separates this EA's orders from other orders. |
Defaults are the values shipped with the EA, not a recommendation. Results depend on the market and on each account. Past results do not guarantee future results. Trading carries a high risk of loss.
The EA builds a band from two moving averages of the same period, the upper one calculated on High prices and the lower one on Low prices. While the Bid is inside the band it places a buy stop above the upper line and a sell stop below the lower line, offset from the band edge by PipDifference.
Every order carries a stop-loss and a take-profit. The buy stop-loss sits at the lower band line and the sell stop-loss at the upper band line; take-profit is TakeProfit pips beyond the entry level. Pending orders, and the stop-loss of open positions, are updated on every tick to follow the MA lines.
With the default settings the lot size is calculated from free margin (MaximumRisk is above 0, so Lots is not used), so the lot grows as the account grows.
Banners from the Exness partner programme

FXIDTH is an independent IB partner of Exness. This channel is not owned or operated by Exness.*Spreads may fluctuate and widen due to factors including market volatility, news events, market open/close, and others.*Processing times may vary depending on the chosen payment method.
EA that trades the crossover of two moving averages, with adjustable method, period and price
EA that opens trend-following Buy/Sell when the EMA slopes the same way, ADX is strong enough and +DI/-DI agree, with SL and TP.
Has alerts
EMA crossover EA with ADX/RSI/session/spread filters, ATR-based SL/TP and a trailing stop