MetaTrader 4 indicators: how to test free ones as futures rules
A free MetaTrader 4 indicator is worth testing only if its value on a closed bar never changes later and its signal can be written as a fixed rule with a parameter range. Check it for repainting with a one-bar replay, write the rule and ranges before the first run, and judge it out-of-sample by completed trades after costs.
By Soren Huang · Published · updated · Editorial policy
Contents
- Which MetaTrader 4 indicators translate to a testable futures rule?
- What do trend, momentum and volatility indicators actually measure?
- How do you spot a free MT4 indicator that repaints or looks ahead?
- How do you turn an indicator idea into a rule with parameter ranges?
- How do you test the rule on out-of-sample data before trusting it?
- Why does an indicator alone not give an edge?
- Frequently asked questions
- References
Which MetaTrader 4 indicators translate to a testable futures rule?
Free MetaTrader 4 indicators are worth testing as futures rules only when two things hold: the value on a closed bar never changes later, and the signal can be written as a fixed condition with a parameter range. That rules out most repainting custom indicators and leaves the plain trend, momentum and volatility families, which you then test out-of-sample after costs.
A MetaTrader 4 indicator is a small program that reads the bars on a chart and draws a line, a histogram or an arrow from them. MetaTrader 4 ships with a standard set (moving averages, ADX, RSI, Stochastic, MACD, ATR, Bollinger Bands and others), and thousands of custom ones are shared online, either as readable MQL4 source or as compiled files you cannot read. The claim this article defends is simple: the indicator is never the edge. The edge, if it exists, lives in the full rule, and a free indicator has to pass four conditions before the rule is even worth writing.
- Its value on a closed bar is final. If the line or arrow on bar 50 can change when bar 53 arrives, no backtest of it is honest.
- Its signal can be written as one condition. "RSI closes below 30" is a condition. "The arrow looks strong" is not.
- Its numbers can be given a range. A length of 14 is one setting; a length of 8 to 20 is something you can test for stability.
- Its inputs exist in your futures data. An indicator that needs tick volume from a forex broker feed will behave differently on exchange-traded futures bars.
Because MetaTrader 4 is used mostly with forex and CFD brokers, testing an idea on exchange-traded futures usually means moving the rule to a tool that holds futures bar data. Before that move, know what a usable edge after costs looks like for your contract: the free win rate and expectancy calculator turns a win rate and average win and loss into the average trade you need to beat the round-trip cost.
What do trend, momentum and volatility indicators actually measure?
The three common MT4 indicator families answer three different questions, so each fits a different job in a rule. Trend indicators answer "which direction", momentum indicators answer "how fast", and volatility indicators answer "how big are the moves". Mixing up the jobs is the most common beginner error: using ATR as an entry trigger, or using RSI as a stop distance.
A trend indicator is a calculation that smooths price so the direction of the last few dozen bars stands out; moving averages and ADX are the standard examples. A momentum indicator is a calculation that compares recent gains with recent losses, or the close with its range, so it moves fast and turns before price does; RSI, Stochastic and MACD belong here. A volatility indicator is a calculation that measures how far bars travel, not where they go; ATR and Bollinger Bands are the usual ones. Wilder (1978) introduced RSI, ATR and the DMI family behind ADX in one book, and the jobs he gave them are still the right ones.
| Family | Question it answers | Job in a rule | MT4 examples |
|---|---|---|---|
| Trend | Which direction is price moving? | Filter (trade only with the trend) or slow entry | Moving averages, ADX |
| Momentum | How fast is price moving, and is it stretched? | Entry trigger or exit signal | RSI, Stochastic, MACD |
| Volatility | How big are the moves right now? | Stop and target distance, position size | ATR, Bollinger Bands |
This is also why stacking three momentum indicators adds little. RSI, Stochastic and MACD are built from the same closes and move together most of the time. Three agreeing momentum readings are one reading counted three times. A rule built from one trend filter, one momentum trigger and one volatility stop uses three different pieces of information, which is the structure the later sections test.
How do you spot a free MT4 indicator that repaints or looks ahead?
A repainting indicator rewrites past signals after the bar closes, so its chart looks perfect while a live trade never saw those signals, and a one-bar replay check exposes it before any backtest. Repainting is the behaviour where an indicator's value or arrow on an already closed bar changes when later bars arrive. Look-ahead is the related fault where the calculation reads a bar that has not closed yet, including the current open bar's high or low. Both produce the same symptom: a history of signals that could not have been traded.
The everyday comparison is a weather forecaster who edits last week's forecasts to match what actually happened. The record looks flawless and tells you nothing. Zigzag-style swing markers and many "buy/sell arrow" indicators shared for free work this way, often without the author intending it: the code recalculates the last few bars every tick, and the arrow on bar 7 quietly moves to bar 9 once bar 9 proves to be the better turning point.
The check takes twenty minutes and needs no code reading:
- Load the indicator on a chart and step forward one bar at a time. Use a bar replay or visual tester mode, or simply note the values at a fixed time each day on a live chart.
- Write down the indicator value and any arrow for each newly closed bar at the moment it closes. Thirty bars is enough.
- After the thirty bars, compare your list with the finished chart. Every value and arrow must match. One moved arrow or one changed value means the indicator repaints.
- If the source is readable, search it for references to bar index 0 inside a loop over past bars, or for the current bar's high and low used in a signal. If the file is compiled and cannot be read, rely on the replay only.
Pass this check before spending a single backtest run. The broader family of leaks, including ones that hide in data alignment rather than in the indicator, is covered in look-ahead bias in backtests and the one-bar check. A rule built on a repainting indicator will show a steep, smooth equity curve on the whole history and then do nothing in a forward test, which is the pattern of a leak, not of a weak idea.
How do you turn an indicator idea into a rule with parameter ranges?
A testable rule names the indicator, the exact condition on a closed bar, next-bar execution, the exit and a range for every number, and all of it is written down before the first run. A parameter range is the span of values you allow a setting to take during testing, such as an RSI length from 8 to 20, instead of a single value you picked from a screenshot. Ranges matter because a setting that works only at one value and fails at its neighbours is usually describing noise in that one history.
Think of a recipe. "Add some flour and bake until it looks right" cannot be repeated by anyone. "Add 200 to 250 grams, bake 30 to 35 minutes at 180 degrees" can be repeated and tested. An indicator idea from a forum post is the first kind; a rule is the second kind.
| Rule element | Example wording | Range to test |
|---|---|---|
| Indicator and inputs | RSI on closes | Length 8 to 20 |
| Entry condition (closed bar) | RSI closes below a level, and close is above the 100-bar moving average | Level 20 to 35; average length 50 to 200 |
| Execution | Buy at the open of the next bar | Fixed; not a parameter |
| Stop | Entry price minus a multiple of ATR | Multiple 1.5 to 3.0; ATR length 10 to 20 |
| Exit | RSI closes above a level, or after N bars | Level 55 to 70; N from 5 to 20 |
| Session | Trade the main session only; flat at the session close | Fixed; set from the exchange's contract page |
Two details decide whether the rule is honest. The condition must read the closed bar, never the bar still forming, and the fill must happen on the next bar, because a strategy that decides on a close and fills on that same close is using a price it could not have traded at. The session and the flat-at-close rule come from the exchange's contract page for your contract; exchanges can change session hours, so check the page rather than copying a setting from a forum. When the same ranges go into strategy generation in AlphaPrime (Valynox), the search draws its candidates from exactly the ranges on your sheet, and each candidate is evaluated with fees, slippage and next-bar execution, so a lucky single value cannot sneak in from outside the range you wrote down.
How many parameters is too many? A useful limit is to count the trades per tuned number. Six tuned numbers and sixty trades gives ten trades per number, and almost any six numbers can be bent to fit sixty trades. Whether the best setting sits on a plateau of good neighbours or on a lonely spike is the subject of parameter stability testing, and it is the first thing to look at once the in-sample run finishes.
How do you test the rule on out-of-sample data before trusting it?
Tune the parameter range on the earlier part of the futures history, run the chosen settings unchanged on the later part, and judge the result by completed trades after commission and slippage, with a pass rule written in advance. In-sample data is the earlier part of the history that is allowed to help choose the settings. Out-of-sample data is the later part that only grades them and never changes them. The split is the exam the indicator has not seen.
The need for this step is well documented. Sullivan, Timmermann and White (1999) tested thousands of simple technical rules on one long price history and found that the best-looking rule's result was largely explained by the number of rules tried. Park and Irwin (2007), surveying the research on technical analysis, note that positive results weaken once data snooping and transaction costs are taken into account. A free indicator you found online has already been through this kind of selection: it is shared because it looked good on someone's chart.
- Split the futures history by date at about 75 percent, in-sample first, and write the split date down before the first run.
- Run the whole parameter range on the in-sample part with commission, slippage, next-bar execution and the session rule already set.
- Pick the setting from the middle of a stable region, not the single best cell, and freeze it.
- Run the frozen setting once on the out-of-sample part and count the completed trades.
- Grade against the pass rule you wrote in step 1: for example, the out-of-sample average trade after costs must stay positive and keep at least half of the in-sample average trade, from at least a hundred trades.
Hypothetical example
Suppose the RSI rule from the table runs on 60-minute index futures bars. In-sample, the chosen setting shows an average trade of $30 after costs from 600 trades. Out-of-sample, the frozen setting shows $18 per trade from 200 trades. The ratio is 60 percent, the sign is positive and the trade count clears the hundred-trade line, so under the pass rule written in step 1 the strategy goes forward unchanged. Had the out-of-sample figure been $4 from 35 trades, the trade count alone would have made the result a hint rather than a verdict.
Count trades, not years, because a slow rule can hold twenty trades in two years and tell you nothing. How many out-of-sample trades make an average trustworthy, and how to handle a result that is weaker but not broken, is worked through in in-sample vs out-of-sample: how to split and how much is enough. A rule that passes can then be carried back to a trading platform: AlphaPrime exports the strategy source code to MetaTrader 4 (MQL4) and MetaTrader 5 (MQL5), as well as to MultiCharts, TradingView, TradeStation and NinjaTrader; the current list is on the supported platforms for export page.
Why does an indicator alone not give an edge?
An indicator only describes price; the edge, if any, lives in the full rule with costs, exits and position size, and most free indicator signals have an average trade smaller than the round-trip cost on futures. The same crossover can lose money as a stand-alone trigger and earn its costs back inside a rule with a stop and a filter. Nothing about the indicator changed; the rule around it did.
The reason is arithmetic, not opinion. A momentum trigger fires often, and each signal captures a small move. Every signal pays commission, exchange fees and slippage on both sides. When the gross move per trade is close to that cost, the net result depends more on your fill quality than on the indicator. Bailey, Borwein, López de Prado and Zhu (2014) add the second half of the problem: when many variants are tried on one history, the best of them is inflated by selection, so a free indicator chosen because it looked best is already carrying a bonus that live trading will not pay.
Hypothetical example
Take a moving-average crossover on a micro index future. Round-trip cost is $6: $2 commission and fees plus $2 slippage on each side. Taken on every signal, the gross average trade is $9, which leaves $3 net. Doubling the slippage estimate to $4 per side raises the cost to $10 and turns the same signal into a loss of $1 per trade. Now add a trend filter (trade only in the direction of a 200-bar average) and an ATR stop. The rule trades about a third as often, the gross average trade rises to $28, and the same $6 cost leaves $22 net. The crossover did not get smarter; the rule stopped paying for the trades that were never going anywhere.
This is why a rule of thumb many systematic traders use is that the gross average trade should be several times the round-trip cost before the result deserves attention. How to estimate slippage without live fills, and why costs belong in the search from the first run, is covered in trading costs in backtests: commission, slippage and the average trade. The indicator is the first ingredient on the sheet, not the dish.
A concrete thing to do this week: pick the one free MetaTrader 4 indicator you already have on a chart, run the thirty-bar replay check from the repainting section, and if it passes, fill in the six-row rule table with a range for every number. Then look up the round-trip cost of your futures contract and compare it with the gross average trade from a first in-sample run. If the gross figure is not several times the cost, change the exit and the filter before touching the indicator's settings.
Frequently asked questions
Do free MetaTrader 4 indicators repaint?
Many custom ones do, especially arrow and swing-marker indicators, and often without the author intending it. The only reliable test is a replay: record the value of each newly closed bar for about thirty bars and compare with the finished chart. If any value or arrow changed, the indicator repaints and its backtest cannot be trusted. Standard built-in indicators such as RSI, ATR and moving averages do not repaint when read on closed bars.
Can MT4 indicators be used on futures?
The calculations can, because RSI, ATR, MACD and the others only need open, high, low, close and volume bars. MetaTrader 4 is used mostly with forex and CFD brokers, so testing on exchange-traded futures usually means rewriting the rule in a tool that holds futures bar data, with the contract's session, tick value and costs set from the exchange's contract page.
What is the best MT4 indicator for trading?
There is no best indicator, because an indicator only describes price and the result depends on the rule built around it. The same crossover can lose money as a bare trigger and earn its costs back with a trend filter and an ATR stop. Pick one indicator from each family (trend, momentum, volatility), give each number a range, and test the full rule out-of-sample after costs.
How do I know whether an MT4 indicator looks ahead?
A look-ahead indicator uses a bar that has not closed yet, usually the current bar's high or low or a future bar in a loop. If the MQL4 source is readable, search for signals that read bar index 0 or that loop forward from the current bar. If the file is compiled, use the thirty-bar replay check: values that change after the bar closes point to either repainting or look-ahead, and both disqualify the indicator.
Can I backtest an indicator inside MetaTrader 4?
MetaTrader 4 includes a Strategy Tester that runs expert advisors, which are automated trading programs written in MQL4, so an indicator has to be wrapped in an expert advisor with explicit entry, exit and cost settings before it can be tested there. The rule table in this article is the specification for that wrapper: indicator, closed-bar condition, next-bar execution, exit, and a range for each number.
References
- Wilder, J. W. (1978). New Concepts in Technical Trading Systems. Trend Research.
- Sullivan, R., Timmermann, A., & White, H. (1999). Data-Snooping, Technical Trading Rule Performance, and the Bootstrap. The Journal of Finance, 54(5), 1647–1691.
- Park, C.-H., & Irwin, S. H. (2007). What Do We Know About the Profitability of Technical Analysis? Journal of Economic Surveys, 21(4), 786–826.
- Bailey, D. H., Borwein, J., López de Prado, M., & Zhu, Q. J. (2014). Pseudo-Mathematics and Financial Charlatanism: The Effects of Backtest Overfitting on Out-of-Sample Performance. Notices of the American Mathematical Society, 61(5), 458–471.

