Price crossing a moving average
The simplest trend signal: a close above the moving average means the market looks up, below it down. The robot enters on the cross and flips when price closes back on the other side.
Choose a platform: MT5 shows the chart and Inputs screenshots from MetaTrader 5, MT4 shows the chart with entries and the Inputs screenshot from MetaTrader 4.
How the robot trades
When it buys
A candle closes above the moving average after closing below it.
When it sells
A candle closes below the average after closing above it.
When it exits
A buy closes on the opposite cross down, a sell on the cross up.
Screenshot 1 of 5
The conditions as constructor blocks
Open a buy
Open a sell
Close a buy
Close a sell
Inputs
These inputs appear in the expert advisor settings in MetaTrader 5 or MetaTrader 4, and they are what the strategy tester goes through when it optimises the robot.
| Input | Default | What it means |
|---|---|---|
| InpMA_Trend_period | 50 | Period of the average: how many recent candles it averages. A short period makes signals more frequent, a long one calmer. |


How to tune the robot to your style
- Change the period: 20 gives frequent signals, 200 only a few and only along a big trend.
- Check the robot on another timeframe in the strategy tester: H1 gives more signals and more noise.
- Compare it with the MA crossover robot: two averages react later but flip less often in noise.
You can do all of this in the constructor without signing up. To save your changes and come back to them later, you need an account.
Risks
How a strategy behaved in the past does not predict its future results. Check the robot in the strategy tester and on a demo account first, and only then decide whether to trade it with real money. This robot is an example to adapt to your instrument, timeframe and risk rules.