Automate Your Trading Strategy: Turn Manual Rules Into an MT5 EA

To automate your trading strategy in MetaTrader 5, write every rule (entry, exit, stop loss, position size and filters) so a computer can check it without guessing. Then have those rules coded as an Expert Advisor (EA), test it in the MT5 Strategy Tester and run it on a demo account before any real money is involved. Patterns you “just see” on a chart are the hard part. Most of the work goes into turning a feeling into a number, and this guide shows you how to do that.
Last reviewed: 6 December 2026. This is a software guide, not trading advice.
01What automating a trading strategy really means
An EA doesn’t think or predict anything. It runs on every new tick or bar, checks a list of conditions, and acts when those conditions are true. So automating a strategy means translating your decisions into conditions that are always either true or false. If two people would read the same chart differently under your rules, the EA can’t follow them yet.
That is why the first job is rewriting your strategy, not coding it. Once the rules are exact, an MQL5 developer can turn them into an MT5 Expert Advisor that runs the same way every time, with no missed entries or hesitation.
Easy to automate
Indicator values, crossovers, price levels, times of day, spread limits, fixed or ATR-based stops and lot formulas.
Possible with work
Chart patterns, swing highs and lows, support and resistance zones. Each one needs an exact definition, such as “a swing high is a bar with two lower highs on each side”.
Hard to automate
“The market feels heavy” or “I skip trades when I’m unsure.” Either turn these into a measurable filter or leave them out.
Outside the EA
Your judgment about whether to keep running the system at all. Software follows rules. It doesn’t decide whether the rules still make sense.
02Is your strategy ready? Turn vague rules into codeable ones
Take your trading notes and rewrite each rule so it answers four questions: what is measured, on which symbol and timeframe, compared with what, and when it is checked (on every tick or only when a bar closes). The table shows the difference. The numbers on the right are examples and starting points to test, not recommendations.
| How traders often write it | Codeable version (example starting point) |
|---|---|
| Buy when the trend turns up | On H1 bar close, the fast MA (length 20) crosses above the slow MA (length 50) |
| Don’t trade when it’s too volatile | Skip new entries if the current spread is above a set number of points, or ATR(14) is above twice its 100-bar average |
| Use a sensible stop | Stop loss = 1.5 × ATR(14) from entry. Take profit = 2 × the stop distance |
| Risk a small amount | Lot size calculated so a stop-loss hit loses 1% of account balance |
| Avoid big news | No new trades from 30 minutes before to 30 minutes after high-impact events for the symbol’s currencies |
| Trade the London session | Entries allowed only between 08:00 and 12:00 server time (check your broker’s server time zone) |
| Close when it stops working | Close the position when the fast MA crosses back below the slow MA on bar close, or after 48 bars, whichever comes first |
If you can fill in the right-hand column for every rule, your strategy is ready to be automated. If you can’t, that gap is where your results really come from, and it’s worth finding out before you pay for code. Our page on how to write an EA brief turns this table into a full document a developer can quote from.
03A worked example: an MA crossover strategy
A moving-average crossover is the classic first strategy to automate because every part of it can be measured. Here it is written as an EA would see it, using the CM Ultimate MA indicator for MT5 as the signal source. According to its product page, CM Ultimate MA plots a moving average that changes color with trend direction. It offers several MA types including Tilson T3, can show a second MA with its own color logic, and marks crossovers with dots on the chart. It can send alerts by pop-up, email or push notification. That makes it easy to watch the rules by hand first and automate them afterwards.
📈 Bullish signal
- Checked only on a closed bar
- Fast MA crosses above the slow MA (crossover dot)
- Fast MA line has turned to its “up” color
- Spread and session filters pass
- No open trade on this symbol from this EA
📉 Bearish signal
- Checked only on a closed bar
- Fast MA crosses below the slow MA (crossover dot)
- Fast MA line has turned to its “down” color
- Spread and session filters pass
- No open trade on this symbol from this EA
Notice that the example spells out details a manual trader rarely writes down: closed bar only, one trade at a time, filters checked before entry. These are the details that make a backtest and a live account behave alike. A simple EA built on one indicator and a fixed stop loss is at the low end of the price range for algorithmic trading development. Add a trade panel, a news filter and several strategy modes and it takes longer.
The banner at the top is an illustration, not real market data. It shows the path this guide follows: a vague rule rewritten as a measurable one, the same rule as MQL5 code, and a crossover marked in the Strategy Tester’s visual mode.
04Step by step: from trading idea to running EA
Write the rules
Entries, exits, stop loss, take profit, trailing, position size and filters, each in the codeable form from section 02. Add screenshots of trades you would and wouldn’t take.
Pick the platform and indicators
MT5 or MT4, the symbols and timeframes, and any indicator the EA must read, whether it’s built into MetaTrader, from a library or your own file.
Get a quote
Send the brief to a developer. At SISCo the quote is free and comes back within one day with a price and a timeline, before any work starts.
Build and first test
The EA is coded and checked in the Strategy Tester against your rules. Use visual mode to watch each trade open and close, and compare it with what you would have done by hand.
Demo account
Run it on a demo account for a few weeks. Real spreads, slippage and broker rules show up here, not in a backtest.
Review and adjust
Compare demo trades with your rules. If a trade looks wrong, check whether the code is wrong or the rule was unclear. Free bug fixes cover the first case, and a clearer rule fixes the second.
05Test it properly before it touches real money
The MT5 Strategy Tester has several ways of generating price data. The official help lists Every tick, 1 minute OHLC, Open prices only and Math calculations, and it describes using real tick history from the broker as well (MetaTrader 5 Help: tick generation). “Open prices only” is fast and fine for a quick check on a bar-close strategy. Anything that uses intrabar stops or trailing needs tick-based modelling.
The tester can also hold back the most recent part of your history as a forward test, to show whether settings were simply fitted to the past. It can also add execution delays so orders don’t fill at perfect prices (MetaTrader 5 Help: strategy testing). Use both.
A good backtest doesn’t promise future results. It only shows that the code follows your rules on past data.
Always run a new EA on a demo account first, then with the smallest possible size on a live account.
Be careful with heavy optimization. The more inputs you tune, the easier it is to fit noise.
Build in hard limits, such as a maximum daily loss, maximum open trades and a spread cap. Our gold EA risk management guide lists the controls worth adding.
06What automation costs and how long it takes
Cost depends on how much the EA has to do, not on a price list. These are the points stated on our custom EA cost page:
Starting price
Custom indicators and EAs start from $50 and are quoted per project after we read your rules.
Free quote
Send your rules and get a price and timeline within one day, at no charge.
Delivery time
Simple projects can often be delivered within a couple of hours. Larger systems take longer.
What you get
The finished software with its source code, and free fixes if bugs or errors appear later.
If you plan to sell or share your EA later, ask for licensing and protection at the start. It’s easier to build in than to add afterwards.
07Common mistakes when automating a strategy
- Checking signals on an open bar. An indicator value can change until the bar closes. Decide whether the EA acts intrabar or on close, and say so.
- Forgetting the exit. Many briefs describe entries in detail and exits in one line. Exits decide most of the result.
- No position-size rule. “0.10 lots” on a small account and a large one are very different risks. Use a formula.
- Ignoring broker details. Symbol suffixes, minimum stop distance, server time and hedging or netting accounts all change how the code must work.
- Going live after one backtest. A backtest, then a forward test, then a demo account, then small live size, in that order.
- Adding every idea at once. Start with the core rules, then add filters one at a time so you can see what each one does.
Frequently asked questions
Can any trading strategy be automated?
Any strategy whose rules can be measured can be automated. Discretionary judgment has to be turned into a measurable filter or left out. If two traders would read your rule differently, it needs rewriting before it can be coded.
Do I need to know MQL5 to automate my strategy?
No. You need clear rules. A developer writes the MQL5 code, and you check the result in the Strategy Tester and on a demo account. Getting the source code means you can change developers or learn from it later.
Should I automate in MT4 or MT5?
MT5 is the newer platform, with more timeframes, a built-in economic calendar and a more detailed Strategy Tester. If your broker only supports one platform, that decides it.
Will an automated strategy make money?
No software can promise that. Automation makes a strategy consistent. It doesn’t make it profitable. Test it thoroughly, start on demo, and only risk money you can afford to lose.
Ready to automate your trading strategy?
Send us your rules, whether that’s a written list, screenshots or an existing indicator, and get a free quote within one day. Every EA comes with its source code and free bug fixes. Want to try the crossover idea by hand first? Load CM Ultimate MA on a demo chart and watch the signals before you automate them.
Trading involves risk and you can lose money. This article is educational software information, not financial advice. SISCo builds software only and gives no trading signals.
Custom EA · Expert Advisor · Moving Average · mt5 · Trading Automation
Related articles
Crypto Liquidation Alert Bot: Lessons From Bitcoin’s Drop to $45K
A crypto liquidation alert bot warns you before Bitcoin crashes close your positions. Learn what it watches, how to build one safely and get…
Read more →MT5 Trade Journal: Send Every Trade to a Database and Dashboard
Build an automatic MT5 trade journal: log every deal to SQLite or a database with MQL5 or Python, then see results per strategy. Get…
Read more →Connect Binance to MT5: Data Feed vs Real Execution Explained
Connect Binance to MT5 the right way: see how a custom-symbol data feed differs from real API execution, plus a safe build checklist. Get…
Read more →Need a team that can design, build and maintain it all?
Let's talk. Tell us about your project and we'll reply with honest timelines.


