MQL5 Moving Average Crossover EA: Implementation, Filters, and Practical Trading Risks

目次

1. What Is a Moving Average Crossover in MQL5?

1.1 Definition

[Conclusion]
A moving average crossover is one of the most basic trend-following methods. It uses the intersection of a short-term moving average and a long-term moving average as a trading signal.

[Definition]
A moving average crossover is logic that determines trade direction based on when a short-term price average, or short-term moving average, crosses above or below a long-term price average, or long-term moving average.

This method makes it easier to remove discretionary judgment, so it is widely used as an entry condition for EAs, or automated trading systems. In MQL5, it can be implemented easily by combining the iMA function with CopyBuffer, making it one of the first strategies beginners should learn.

The key points are as follows.

  • Cross above, also called a golden cross, means a buy signal
  • Cross below, also called a dead cross, means a sell signal
  • It is a lagging method that follows after a trend has already started

Because it enters late, this approach can avoid some noise, meaning meaningless price movement. At the same time, late entry is also its main weakness.


1.2 Key Terms for Beginners

[Conclusion]
To understand a moving average crossover, you only need to understand “short-term versus long-term” and what the crossover means.

First, a moving average is the average price over a fixed period.
It smooths price fluctuations, or noise, and makes the trend direction easier to see.

The main terms are as follows.

  • Short-term moving average: Strongly reflects recent prices, such as periods from 5 to 20
  • Long-term moving average: Reflects a broader average that includes older prices, such as periods from 50 to 200
  • Golden cross: The short-term average crosses above the long-term average, suggesting a possible start of an uptrend
  • Dead cross: The short-term average crosses below the long-term average, suggesting a possible start of a downtrend

This matters because the short-term average represents the market’s current intent, while the long-term average represents the market’s broader average valuation.

In other words, the structure is:

  • Short-term > long-term: the market has shifted bullish
  • Short-term < long-term: the market has shifted bearish

Beginners often get confused about the following points.

  • A crossover does not mean a trade will always win
  • False signals often occur in ranging, sideways markets
  • Behavior changes significantly depending on period settings

1.3 What Problems It Solves

[Conclusion]
A moving average crossover can automate trend detection and help build reproducible trading rules at the same time.

Using this method helps solve the following problems.

1. It removes inconsistent discretionary judgment

Human decisions are affected by emotions and circumstances, but a crossover is completely number-based.

  • The decision criteria are clear
  • The result is the same no matter who implements it
  • It can be backtested, so it is reproducible

2. It helps build a trend-following strategy

The forex market tends to continue in one direction once a trend starts.
A moving average crossover is basic logic for riding that flow.

3. It becomes a foundation for EA design

In real trading systems, it is usually combined with the following elements rather than used alone.

  • Spread filter to avoid spread widening
  • Slippage protection
  • Execution conditions and execution control
  • Filters using ATR or RSI

In other words, a moving average crossover is not a complete trading method by itself.
Its correct role is as a core EA component, or signal generation engine.

Common failures include:

  • Trying to win with the crossover alone
  • Not adding filters
  • Ignoring lot management

These issues can cause failure in live trading.

2. Steps to Implement a Moving Average Crossover in MQL5

[Conclusion]
A moving average crossover implementation consists of four steps: get moving averages, retrieve data, detect the crossover, and place orders.
If you convert this flow directly into code, it will work as an EA.

MQL5 moving average crossover signal detection showing fast and slow moving averages crossing on a trading chart, with code overlay demonstrating iMA and CopyBuffer usage, highlighting buy and sell trade execution signals in an algorithmic trading EA system

2.1 Overall Implementation Flow

[Conclusion]
If you fix the processing order, the logic becomes reproducible in any environment.

The implementation steps are as follows.

  • Create short-term and long-term moving average handles with iMA
  • Retrieve the latest data with CopyBuffer
  • Compare previous and current values
  • Detect the crossover
  • Execute buy or sell trades with OrderSend

If you break this order, bugs and incorrect signals become more likely.


2.2 Get Moving Averages with iMA

[Conclusion]
First, create handles, or identifiers, for the moving averages.

int ma_short;
int ma_long;

ma_short = iMA(_Symbol, _Period, 20, 0, MODE_EMA, PRICE_CLOSE);
ma_long  = iMA(_Symbol, _Period, 50, 0, MODE_EMA, PRICE_CLOSE);

Key points:

  • 20 and 50 are the periods, short-term and long-term
  • MODE_EMA means an exponential moving average, which reacts faster
  • _Symbol is the currency pair, such as EURUSD
  • _Period is the timeframe

Common mistake:

  • Not checking whether handle creation failed
    You need to check INVALID_HANDLE

2.3 Retrieve Data with CopyBuffer

[Conclusion]
To detect a crossover, you need the current value and the value from the previous bar.

double ma_s&#91;2];
double ma_l&#91;2];

CopyBuffer(ma_short, 0, 0, 2, ma_s);
CopyBuffer(ma_long, 0, 0, 2, ma_l);

Important points:

  • [0] means the current bar
  • [1] means the previous bar
  • The array size must be at least 2

Notes:

  • The index order changes depending on whether you use ArraySetAsSeries
  • If you do not check the return value of CopyBuffer, you may use invalid data
if(CopyBuffer(ma_short,0,0,2,ma_s) &lt;= 0) return;

2.4 Crossover Detection Logic

[Conclusion]
You detect a crossover by comparing the previous relationship with the current relationship.

bool golden_cross = (ma_s&#91;1] &lt; ma_l&#91;1]) &amp;&amp; (ma_s&#91;0] &gt; ma_l&#91;0]);
bool dead_cross   = (ma_s&#91;1] &gt; ma_l&#91;1]) &amp;&amp; (ma_s&#91;0] &lt; ma_l&#91;0]);

Meaning:

  • Golden cross: the short-term average crossed from below to above
  • Dead cross: the short-term average crossed from above to below

Common mistakes:

  • Judging only by the current value, which causes false detection
  • Ignoring equal-value cases

2.5 Trading Process with OrderSend

[Conclusion]
After detecting a crossover, send an order based on the condition.

#include &lt;Trade/Trade.mqh&gt;
CTrade trade;

if(golden_cross)
{
    trade.Buy(0.1, _Symbol);
}
else if(dead_cross)
{
    trade.Sell(0.1, _Symbol);
}

Required practical considerations:

  • Avoid trading when the spread is wide
  • Prepare for slippage
  • Define execution conditions, such as market orders or limit orders
  • Prevent duplicate positions

Example:

if(PositionSelect(_Symbol)) return; // Prevent duplicate positions

2.6 Minimal EA Code Example for Practical Use

[Conclusion]
The following code completes a minimal working structure.

#include &lt;Trade/Trade.mqh&gt;
CTrade trade;

int ma_short, ma_long;

int OnInit()
{
    ma_short = iMA(_Symbol, _Period, 20, 0, MODE_EMA, PRICE_CLOSE);
    ma_long  = iMA(_Symbol, _Period, 50, 0, MODE_EMA, PRICE_CLOSE);

    if(ma_short == INVALID_HANDLE || ma_long == INVALID_HANDLE)
        return(INIT_FAILED);

    return(INIT_SUCCEEDED);
}

void OnTick()
{
    double ma_s&#91;2], ma_l&#91;2];

    if(CopyBuffer(ma_short,0,0,2,ma_s) &lt;= 0) return;
    if(CopyBuffer(ma_long,0,0,2,ma_l) &lt;= 0) return;

    bool golden_cross = (ma_s&#91;1] &lt; ma_l&#91;1]) &amp;&amp; (ma_s&#91;0] &gt; ma_l&#91;0]);
    bool dead_cross   = (ma_s&#91;1] &gt; ma_l&#91;1]) &amp;&amp; (ma_s&#91;0] &lt; ma_l&#91;0]);

    if(PositionSelect(_Symbol)) return;

    if(golden_cross)
        trade.Buy(0.1,_Symbol);
    else if(dead_cross)
        trade.Sell(0.1,_Symbol);
}

Common Failures to Watch For

  • Lot constraints, such as min, max, and step, are not handled, causing Invalid volume
  • No margin check, causing not enough money
  • No handling for order rejection, such as off quotes
  • Execution timing shifts caused by VPS latency

These issues may not appear in backtests, but they can be critical in live trading.

3. Why Moving Average Crossovers Work

[Conclusion]
A moving average crossover is designed to filter out noise by following after a trend has started, giving it an edge under some conditions.
However, its real purpose is not to be a winning method by itself. It is a filter for mechanically detecting trends.


3.1 The Core of a Trend-Following Strategy

[Conclusion]
Because the forex market repeats the cycle of range, trend, and range, a strategy that extracts only the trending phase can be effective.

The market structure has the following characteristics.

  • Most of the time is spent in ranges with no clear direction
  • Strong trends occur only during part of the time
  • Most profits are determined during trending periods

A moving average crossover is designed to target the phase after a trend starts.

The reason for following after confirmation is:

  • The initial move contains a lot of noise and is easy to misread
  • Entering after confirmation improves reproducibility

Important points:

  • Earlier entries may increase profit, but they also increase false signals
  • Later entries are more stable, but they reduce potential profit

A moving average crossover is a method that leans toward stability within this trade-off.


3.2 Why a Crossover Becomes a Signal

[Conclusion]
A crossover becomes a signal because the moment when the short-term and long-term relationship reverses is the point where market participants’ valuation has changed.

The structure is as follows.

  • Short-term moving average: current price pressure, or recent intent
  • Long-term moving average: the market’s broader average valuation

When the relationship between these two changes, it means:

  • Cross above: buying pressure has exceeded the average
  • Cross below: selling pressure has fallen below the average

In short, a crossover detects:

“The moment when the market balance breaks.”

Another important point is the self-reinforcing structure:

  • After a crossover, orders in the same direction tend to increase
  • As a result, the trend is more likely to continue

However, this does not always happen.


3.3 Weaknesses

[Conclusion]
The biggest weaknesses of a moving average crossover are false signals in ranging markets and lag.

The main problems are as follows.

1. Incorrect signals in ranging markets

When price moves sideways:

  • Crossovers occur frequently
  • Signals keep reversing
  • Losses accumulate

This is commonly called a false signal or whipsaw.

2. Delay, or lag

Because moving averages are based on past data:

  • They react only after a trend has started
  • They miss the early part of the profit opportunity

This is a structural limitation.

3. Effect of the execution environment

In live trading, the following factors also matter.

  • Spread widening increases entry cost
  • Slippage fills the order at a worse price than expected
  • Order rejection, such as off quotes

These factors create differences between backtest results and live results.


Practical Countermeasures

[Conclusion]
Do not use a moving average crossover alone. Design it on the assumption that filters are required.

Common improvement methods:

  • Use ATR as a volatility filter
  • Use RSI to avoid overheated conditions
  • Restrict entries with spread conditions
  • Confirm the higher-timeframe trend, also called multi-timeframe analysis

The key idea is:

“A crossover is not the entry condition itself. It is a trend detection condition.”

Without this understanding, it is difficult to build a design that can perform over the long term.

4. Comparison with Other Methods

[Conclusion]
A moving average crossover is strong at trend following but weak in ranges, so in practice it should be used together with other indicators such as RSI, MACD, and ATR. Its edge by itself is limited.


4.1 Comparison with Major Methods

[Conclusion]
Each indicator has a market condition where it works best. Without selection criteria, you can fall into over-optimization, or overfitting.

The comparison criteria are as follows.

  • Trend suitability, or trend following
  • Range suitability, or mean reversion
  • Signal speed, or lag
  • Noise resistance, or resistance to false signals
MethodFeatureStrengthWeaknessBest Market
Moving average crossoverTrend followingSimple and reproducibleWeak in ranges and has lagTrend
RSIOscillator for overbought and oversold conditionsCan support counter-trend entriesWorks poorly during strong trendsRange
MACDDerivative of moving averages, based on differencesTrend plus momentumHas lag and needs tuningTrend
ATRVolatility indicatorNoise filtering and stop-loss designCannot generate direction by itselfAll markets as support

Important points:

  • A moving average crossover judges direction
  • RSI judges overheated conditions
  • ATR judges the size of price movement

Because their roles are different, they are complementary rather than competing tools.


4.2 Combined Strategies for Practical Design

[Conclusion]
A moving average crossover reaches practical trading level only when it is combined with filters.

Common combinations are as follows.

1. MA crossover + RSI filter

  • Condition: crossover occurs and RSI is neutral to aligned with the trend direction
  • Purpose: avoid entering when the market is overheated

Examples:

  • Buy: golden cross and RSI < 70
  • Sell: dead cross and RSI > 30

2. MA crossover + ATR filter

  • Condition: crossover plus enough volatility
  • Purpose: avoid ranges and reduce false signals

Example:

  • Enter only when ATR is above a certain value

3. MA crossover + spread control

  • Condition: crossover plus spread within the allowed range
  • Purpose: optimize execution cost
double spread = SymbolInfoDouble(_Symbol, SYMBOL_SPREAD);
if(spread &gt; 20) return; // Avoid trading when the spread is too wide

4. Multi-timeframe, or MTF

  • Condition: lower-timeframe crossover plus higher-timeframe trend alignment
  • Purpose: reduce false signals and improve win rate

Example:

  • A crossover occurs on the 1-hour chart
  • The daily chart is trending in the same direction

4.3 Core Difference from Other Methods

[Conclusion]
A moving average crossover is a trend detector, while other indicators act as condition filters.

If you do not understand this difference, the design will be wrong.

Moving average crossover

  • Role: direction judgment, or trend direction
  • Output: buy or sell
  • Problem: many false signals

RSI

  • Role: overheated conditions and reversal possibility
  • Output: overbought or oversold
  • Problem: becomes counter-trend during strong trends

ATR

  • Role: market activity, or volatility
  • Output: whether to enter and how wide the stop loss should be
  • Problem: no direction

In other words:

  • MA crossover tells you the direction to enter
  • RSI and ATR help decide whether to enter

This separation of roles is important.


Common Mistakes

[Conclusion]
The idea that adding more indicators automatically improves accuracy is risky.

Typical examples:

  • Too many indicators cause almost no entries
  • Optimization on past data breaks in the future
  • Overly complex conditions reduce reproducibility

In practice, follow these rules.

  • Keep the logic simple
  • Limit filters to two or three
  • Verify with forward testing

5. Common Failures and Important Notes

[Conclusion]
A moving average crossover is easy to implement but difficult to operate.
Most failures come from misreading the market environment, ignoring execution conditions, or weak money management.


5.1 False Signals in Ranging Markets

[Conclusion]
In sideways, ranging markets, crossovers occur frequently and consecutive losses become more likely.

Causes:

  • Price only moves up and down without direction
  • The relationship between the short-term and long-term averages changes frequently
  • Trend-based logic breaks down

Typical pattern:

  • Golden cross, then quick reversal, then stop loss
  • Dead cross, then quick reversal, then stop loss

Countermeasures:

  • Add a volatility filter using ATR
  • Restrict conditions with trend strength, such as ADX
  • Enter only when the signal matches the higher-timeframe trend

Important points:

  • A crossover signal does not automatically mean entry
  • The setup works only as crossover plus market conditions

5.2 Parameter Over-Optimization, or Overfitting

[Conclusion]
If you optimize too much in backtests, the results will not reproduce in live trading.

Common mistakes:

  • Fine-tuning periods too narrowly, such as the difference between 19 and 21
  • Optimizing for a specific period
  • Chasing only maximum profit

Results:

  • The logic becomes specialized for past data
  • It collapses in future data

Countermeasures:

  • Use broad parameter settings, such as 20/50
  • Verify with forward testing on future data
  • Run walk-forward analysis

Important points:

  • Prioritize robustness over the best-looking optimization result
  • Simpler logic is usually more stable over the long term

5.3 Execution Environment Problems

[Conclusion]
Execution costs that are invisible in backtests can reduce profit.

Main factors:

  • Spread widening
  • Slippage
  • Order rejection, such as off quotes
  • Latency

Typical examples:

  • Spread widens sharply during economic news releases
  • Orders fill at worse prices than expected
  • VPS latency delays the signal

Countermeasures:

double spread = SymbolInfoDouble(_Symbol, SYMBOL_SPREAD);
if(spread &gt; 20) return; // Spread limit
if(!trade.Buy(0.1,_Symbol))
{
    Print("Order failed: ", GetLastError());
}

Important points:

  • Design execution conditions, not only entry conditions
  • Results change by broker and account type, such as ECN or STD

5.4 Poor Lot and Margin Management

[Conclusion]
If lot management is wrong, any trading logic can fail.

Common problems:

  • Fixed lots with no risk awareness
  • Order failure due to insufficient margin
  • No handling for lot step, causing Invalid volume

Example:

double minLot = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
double step   = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);

double lot = 0.1;
lot = MathFloor(lot / step) * step;
lot = MathMax(lot, minLot);

Countermeasures:

  • Fix risk per trade, such as 1% of the account
  • Check margin with OrderCalcMargin
  • Normalize with SYMBOL_VOLUME_STEP

Important points:

  • Lot management is the core of risk management
  • It has higher priority than entry accuracy

5.5 Lack of Position Management

[Conclusion]
Without position control, the EA can enter without limit and fail.

Typical mistakes:

  • Opening a new entry on every crossover
  • Continuing to add positions in the same direction

Countermeasure:

if(PositionSelect(_Symbol)) return; // Do not open a new trade if a position already exists

Advanced options:

  • Limit the maximum number of positions
  • Control pyramiding, or additional entries
  • Use a trailing stop

Short Summary of Important Points

  • A crossover alone is not enough to win
  • Range protection is required
  • Ignoring execution can break the strategy
  • Lot management is the most important part

6. Practical Use Cases

[Conclusion]
A moving average crossover has a more stable expectancy when used in a market where a trend exists or is starting.
In contrast, avoiding it in ranges or high-cost environments is a rational decision.


6.1 Effective Market Conditions

[Conclusion]
It works best in markets with clear direction and enough volatility.

Specific conditions include the following.

  • A trend exists on a higher timeframe, such as the daily or 4-hour chart
  • Price is moving away from the moving average in one direction
  • ATR is above a certain level, meaning the market is moving

Practical decision criteria:

  • The higher-timeframe moving average is sloping upward or downward
  • Highs and lows are being updated
  • The spread is stable, meaning trading cost is low

Example for EA implementation:

double atr&#91;];
CopyBuffer(iATR(_Symbol,_Period,14),0,0,1,atr);

if(atr&#91;0] &lt; 0.0005) return; // Avoid trading when volatility is insufficient

Why it works:

  • Trends are more likely to continue
  • Price is more likely to extend in the same direction after a crossover
  • False signals are relatively reduced

6.2 Cases Where It Is Not Suitable

[Conclusion]
A moving average crossover does not work well in markets with no direction or in high-cost environments.

Common bad cases:

1. Ranging markets

  • Price only moves up and down within a fixed area
  • Crossovers occur frequently, leading to consecutive losses

2. Scalping, or ultra-short-term trading

  • Crossovers have lag
  • Entry timing is delayed

3. High-cost environments

  • Spread widening
  • Increased slippage
  • Unstable execution

Example:

double spread = SymbolInfoDouble(_Symbol, SYMBOL_SPREAD);
if(spread &gt; 30) return; // Avoid trading when cost is high

4. Around major economic news releases

  • Sharp price movement
  • Order rejection, such as off quotes
  • Execution at unexpected prices

Important points:

  • Choosing not to trade protects profit
  • Not trading is part of the strategy

6.3 Examples of Incorporating It into EA Design

[Conclusion]
A moving average crossover is best used as a module, not as a standalone strategy.

Main practical uses:

1. Use as an entry condition

  • Crossover occurs, then enter
  • This is the simplest structure

2. Use as a trend filter

  • If the higher timeframe is rising, allow only buys
  • Improve entry precision on lower timeframes

3. Add positions, or pyramiding

  • Add entries while the trend continues
  • Aim to expand profit

4. Use as an exit condition

  • Close the trade on an opposite crossover
  • Use it as a signal that the trend may be ending

Basic Practical Design Pattern

[Conclusion]
A three-layer structure of direction judgment, filters, and execution conditions is more stable.

Example:

  • Direction judgment: moving average crossover
  • Filters: ATR / RSI
  • Execution conditions: spread / slippage / execution

Pseudocode:

if(trend_is_up &amp;&amp; golden_cross &amp;&amp; spread_ok &amp;&amp; atr_ok)
{
    trade.Buy(lot,_Symbol);
}

Short Summary of Important Points

  • Use it in trending markets
  • Do not use it in ranges
  • Always consider execution costs
  • The most important design decision is when to use it

7. Advanced Improvements to Increase Accuracy

[Conclusion]
A moving average crossover is unstable when used as-is, but it can be improved to a practical level by adding filters, integrating timeframes, and selecting indicators carefully.


7.1 Add Filters to Reduce False Signals

[Conclusion]
The most effective improvement is excluding invalid market conditions.

The weakness of a moving average crossover is the ranging market.
For that reason, you add conditions before entry.

Common filters

  • ATR, for volatility
  • RSI, for overheated conditions
  • Spread control, for cost management

Implementation example: ATR filter

int atr_handle = iATR(_Symbol, _Period, 14);
double atr&#91;1];

if(CopyBuffer(atr_handle,0,0,1,atr) &lt;= 0) return;

if(atr&#91;0] &lt; 0.0005) return; // Avoid trading when volatility is insufficient

Implementation example: RSI filter

int rsi_handle = iRSI(_Symbol, _Period, 14, PRICE_CLOSE);
double rsi&#91;1];

CopyBuffer(rsi_handle,0,0,1,rsi);

if(golden_cross &amp;&amp; rsi&#91;0] &gt; 70) return; // Avoid overbought conditions

Important points:

  • Do not add too many filters
  • Limit filters to two or three
  • Choose indicators with different roles, such as direction, overheating, and volatility

7.2 Multi-Timeframe Analysis, or MTF

[Conclusion]
Aligning with the higher-timeframe trend can greatly improve the win rate.

The idea is:

  • Higher timeframe: the larger trend
  • Lower timeframe: entry timing

Specific example

  • Daily chart: uptrend
  • 1-hour chart: golden cross, then buy

Implementation idea

int ma_daily = iMA(_Symbol, PERIOD_D1, 50, 0, MODE_EMA, PRICE_CLOSE);
double ma_d&#91;1];

CopyBuffer(ma_daily,0,0,1,ma_d);

double price = SymbolInfoDouble(_Symbol, SYMBOL_BID);

bool trend_up = price &gt; ma_d&#91;0];

Points:

  • Do not trade against the higher timeframe
  • Reduce false crossover signals
  • Keep consistency as a trend-following strategy

7.3 Choose the Moving Average Type to Reduce Lag

[Conclusion]
Using EMA instead of SMA can reduce signal lag.

Main differences:

TypeFeature
SMA, simple moving averageStable but slow
EMA, exponential moving averageReacts faster
LWMAMore sensitive

Practical judgment:

  • Swing trading: SMA can be acceptable
  • Short-term trading: EMA is recommended

Implementation example: EMA

iMA(_Symbol, _Period, 20, 0, MODE_EMA, PRICE_CLOSE);

Notes:

  • Faster reaction also means more false signals
  • Using filters together is assumed

7.4 Strengthen Entry Conditions

[Conclusion]
Improve accuracy by combining conditions, not by relying on the crossover alone.

Example:

  • Crossover occurs
  • Higher-timeframe trend matches
  • ATR condition is cleared
  • Spread is normal

Pseudocode:

if(golden_cross &amp;&amp; trend_up &amp;&amp; atr_ok &amp;&amp; spread_ok)
{
    trade.Buy(lot,_Symbol);
}

Important:

  • Separate conditions by role
  • Do not stack conditions that mean the same thing

7.5 Improve the Exit Strategy

[Conclusion]
To let profits grow, exit design is more important than entry design.

Main methods:

  • Close on the opposite crossover
  • Use a trailing stop
  • Use an ATR-based stop loss

Example:

double stop_loss = Bid - atr&#91;0] * 2;

Important points:

  • Always set a stop loss
  • You need a design that lets profit extend
  • Exit design determines profitability

Short Summary of Important Points

  • A crossover alone is not enough
  • Use filters to limit the situations where it is applied
  • Alignment with the higher timeframe is very important
  • Exit design strongly affects profit

8. FAQ

[Conclusion]
A moving average crossover is a method whose results change greatly depending on how it is used.
Understanding the commonly misunderstood points can reduce wasted trial and error.


8.1 Can a Moving Average Crossover Really Win?

[Conclusion]
It is not stable by itself, but it can be effective in trending markets.

Reasons:

  • It can extend profit when a trend continues
  • However, losses can accumulate in ranges

In practice, it works only when combined with:

  • Filters such as ATR / RSI
  • Execution conditions such as spread / slippage
  • Money management

8.2 Should I Use SMA or EMA?

[Conclusion]
EMA is suitable for short-term trading, while SMA is suitable when stability is more important.

Differences:

  • EMA reacts faster, so signals appear earlier
  • SMA is smoother and has more noise resistance

Notes:

  • EMA tends to produce more false signals
  • SMA delays entry

8.3 Is There an Optimal Moving Average Period?

[Conclusion]
There is no fixed optimal answer. It changes depending on the market and strategy.

Common examples:

  • Short-term: 5 to 20
  • Long-term: 50 to 200

The important points are:

  • Do not over-optimize small differences
  • Use broad settings and prioritize stability

8.4 How Can I Reduce False Signals?

[Conclusion]
The most effective method is to limit the situations where the strategy is used.

Specific measures:

  • Use ATR to confirm volatility
  • Use RSI to avoid overheated conditions
  • Enter only when aligned with the higher-timeframe trend

Point:

  • The goal is not to add conditions blindly, but to exclude invalid markets

8.5 Can I Put It Directly into an EA?

[Conclusion]
Yes, but it is not durable enough for live trading as-is.

Minimum required elements:

  • Lot management, or risk per trade
  • Spread control
  • Execution error handling
if(!trade.Buy(lot,_Symbol))
{
    Print("Error:", GetLastError());
}

8.6 Is It Suitable for Scalping?

[Conclusion]
In general, it is not suitable for scalping.

Reasons:

  • Crossovers have lag
  • They are weak against short-term noise
  • Execution costs have a large impact

For scalping, the following are more important:

  • Tick-based logic
  • Order book information
  • High-speed execution

8.7 Why Does It Win in Backtests but Lose in Live Trading?

[Conclusion]
The main causes are overfitting and execution differences.

Specific examples:

  • Spread is not fixed in live trading
  • Slippage is not reproduced accurately
  • Order rejection is not considered

Countermeasures:

  • Run forward testing
  • Test in a VPS environment
  • Reflect realistic trading costs

8.8 Which Currency Pairs Are Suitable?

[Conclusion]
Currency pairs with clear trends and high liquidity are suitable.

Examples:

  • EURUSD
  • USDJPY
  • GBPUSD

Reasons:

  • Spread is stable
  • Execution is stable
  • Trends are relatively clear

Short Summary of Important Points

  • A crossover alone is not enough
  • Design on the assumption that filters are required
  • Always consider execution and cost
  • Use both backtesting and forward testing

9. Summary

[Conclusion]
A moving average crossover is one of the simplest trend detection logics. It is not enough by itself, but with appropriate filters it can be developed into a practical trading strategy.

Key points from this article:

  • A moving average crossover is trend judgment based on a change in the relationship between short-term and long-term averages
  • It is simple, reproducible, and suitable as basic EA logic
  • However, it produces many false signals in ranging markets and is unstable as-is

Important practical points:

  • Treat crossover as direction judgment, not automatic entry
  • Combine it with filters such as ATR, RSI, and spread conditions
  • Always consider execution conditions and costs, including spread and slippage
  • Prioritize lot management and margin management in the design

Recommended basic structure:

  • Direction judgment: moving average crossover
  • Filters: ATR / RSI / higher-timeframe trend
  • Execution conditions: spread / slippage / execution
  • Risk management: lot size and drawdown control

Short summary:

  • A crossover is not the entry itself; it is decision material
  • Expectancy is unstable without filters
  • Exit design and money management determine profitability

Topics to learn next:

  • Lot size calculation, or position sizing
  • Drawdown control
  • Equity protection
  • Forward testing and optimization methods

By combining these elements, you can move from a simple logic into a practical EA design that can be tested for live use.