เทรนด์ TrendFilterCrossover มีใน Builder

Moving Average

MA

A moving average smooths price into a single line that shows the direction and slope of the underlying trend. It is the baseline every other trend tool is built on, the most common filter in an EA, and the simplest indicator to turn into a no-code strategy.

Template periods
10 / 50
Methods
SMA / EMA / SMMA / LWMA
Scale
Price
OverboughtOversoldCentreline 50Divergence

ภาพประกอบ — ข้อมูลสังเคราะห์ ไม่ใช่ราคาจริง

What a moving average tells you

A moving average replaces the last N prices with their average, so the noise of individual bars falls away and only the direction of the move is left. It says nothing about what price will do next — it says what price has been doing, with a lag you choose by picking the period.

  • Price above a rising MA: the trend is up
  • Price below a falling MA: the trend is down
  • A flat MA means there is no trend to follow, whatever price is doing bar to bar
  1. 1 Take the last N applied prices
  2. 2 Average them with the chosen method
  3. 3 Plot the result on the price scale
แสดงสูตรและรายละเอียดการคำนวณ

A moving average replaces the last N applied prices with a single averaged value, recomputed on every bar:

  1. Choose the period N and the applied price (Close by default).
  2. Choose the averaging method. Simple (SMA) weights every bar equally: SMA = (P₁ + P₂ + … + Pₙ) / N. Exponential (EMA) weights the newest bar most, with a smoothing factor of 2 / (N + 1). Smoothed (SMMA) and linear-weighted (LWMA) sit between the two.
  3. Plot the result on the price scale. The line always lags price — that lag is the cost of removing noise, and the period is the dial that sets it.

Because the output shares the price scale, a moving average is directly comparable to price, which is why it doubles as a dynamic support/resistance reference and as the simplest possible trend filter. The trade-off never goes away: a shorter period tracks price closely and inherits its noise, a longer one is smooth but tells you about a turn well after it happened.

In MQL5 the call is iMA(symbol, period, ma_period, ma_shift, ma_method, applied_price) and it returns a handle to a single buffer. Both ma_method (ENUM_MA_METHOD) and applied_price (ENUM_APPLIED_PRICE) are real arguments — the SMA-on-Close form is only the most common configuration, not the indicator’s definition.

สัญญาณ

สัญญาณที่ backtest ได้ของ MA — และสภาวะตลาดที่เหมาะสมกับแต่ละสัญญาณ

Fast / Slow Crossover

พร้อมใช้ใน Builder
เงื่อนไข
A shorter MA crosses a longer one
สภาวะที่ดีที่สุด
Trending markets
การใช้งานทั่วไป
Enter as the shorter average confirms a change of direction

Price vs MA

พร้อมใช้ใน Builder
เงื่อนไข
Price closes above or below a single MA
สภาวะที่ดีที่สุด
Established trends
การใช้งานทั่วไป
Use one MA as a directional filter for another entry rule

Pullback to the MA

พร้อมใช้ใน Builder
เงื่อนไข
Price returns to a rising MA and holds
สภาวะที่ดีที่สุด
Trend continuation
การใช้งานทั่วไป
Join a trend at a better price than the breakout

Slope and Fan

ตรรกะขั้นสูง
เงื่อนไข
Several MAs line up in period order and stay apart
สภาวะที่ดีที่สุด
Strong trends
การใช้งานทั่วไป
Read trend health rather than time a single entry

การทำงานจริงใน MT5

สิ่งที่ MetaTrader 5 คำนวณและวาดจริง — เกณฑ์อ้างอิงของทุกกฎในหน้านี้

บัฟเฟอร์

ดัชนี บัฟเฟอร์ MT5 วาดเป็น เก็บค่าอะไร
0 MAIN_LINE Line The averaged price itself, plotted on the price scale. iMA publishes one buffer — a fast/slow pair is two separate handles, not two buffers of one.

ทำงานได้ดีที่สุด / ใช้อย่างระมัดระวัง

ไม่มีอินดิเคเตอร์ใดที่ได้เปรียบในทุกสภาวะ นี่คือจุดที่ MA ช่วยได้ — และจุดที่มันทำให้เข้าใจผิด

ทำงานได้ดีที่สุด

  • Trending markets
  • As a filter for another signal
  • On higher timeframes
  • When the slope is clearly non-flat

ใช้อย่างระมัดระวัง

  • Sideways, directionless ranges
  • Crossovers as a standalone entry
  • Very short periods on low timeframes
  • Optimised period pairs without validation

สร้างกลยุทธ์ MA

เชื่อมสัญญาณเข้ากับกฎการเปิดและปิดออเดอร์ จากนั้นส่งออก EA MT5 ที่คอมไพล์ได้ — ไม่ต้องเขียนโค้ด

  1. Fast MA (SMA 10)
  2. Slow MA (SMA 50)
  3. Fast crosses above slow → Open Buy · SL 50 / TP 100
  4. Fast crosses below slow → Open Sell

รวม MA กับอินดิเคเตอร์อื่น

อินดิเคเตอร์เดี่ยวแทบไม่เพียงพอ การจับคู่เหล่านี้ครอบคลุมจุดบอดของ MA

MA + TRIX

  1. Price above the EMA(200)
  2. TRIX crosses above zero
  3. Buy
เหตุผล
Use the average the other way round — not as the trigger but as the permission slip, letting a heavily smoothed momentum reading pick the moment while a long EMA decides which side is allowed at all
สภาวะที่ดีที่สุด
Trending
สร้างกลยุทธ์นี้ →

MA + RSI

  1. EMA 5 / 20 / 60 aligned up
  2. RSI > 50
  3. Buy
เหตุผล
Only take the trend direction when a bounded momentum gauge agrees, so a moving average never drags you into an exhausted move
สภาวะที่ดีที่สุด
Trending
สร้างกลยุทธ์นี้ →

MA + Momentum

  1. Price above the EMA
  2. Momentum crosses above 100
  3. Buy
เหตุผล
Let the average say which way the market leans and let an acceleration reading say when to act, so entries land on a move rather than on a lagging line finally turning
สภาวะที่ดีที่สุด
Trending
สร้างกลยุทธ์นี้ →

MA + ADX

  1. ADX > 25
  2. Fast MA crosses slow
  3. Buy
เหตุผล
Trade the crossover only when trend strength confirms there is a trend at all, since crossovers in a flat market are pure cost
สภาวะที่ดีที่สุด
Trending

No single-flow template pairs a moving average with ADX. Start from MA Crossover and add an ADX node with a Compare at 25 into an And gate — the ADX Trend template shows that filter wired up.

เปิด Builder →

MA + ATR

  1. Fast MA crosses slow
  2. ATR sets stop distance
  3. Buy
เหตุผล
Size the stop from current volatility instead of a fixed pip distance, so the same crossover rule survives calm and violent markets
สภาวะที่ดีที่สุด
Any

No single-flow template pairs a moving average with ATR. Start from MA Crossover and add an ATR node feeding a risk-based lot or stop node.

เปิด Builder →

พารามิเตอร์

ค่าเริ่มต้นสำหรับตรวจสอบบนคู่และกรอบเวลาของคุณเอง — ไม่ใช่การตั้งค่าที่รับประกัน

พารามิเตอร์ ค่าเริ่มต้น ช่วงที่แนะนำให้ทดสอบ หน้าที่
Period 10 5–200 How many bars are averaged. Short reacts fast and whipsaws; long is smooth and late. The template pairs 10 with 50.
Method SMA SMA / EMA / SMMA / LWMA How the bars are weighted. SMA treats every bar equally; EMA and LWMA lean on recent bars; SMMA is the smoothest. All four are ENUM_MA_METHOD values iMA accepts.
Applied price Close Close / Open / High / Low / Median / Typical / Weighted Price series that gets averaged. Close is the default; Median and Typical fold the bar's range in, which makes the line slightly steadier on noisy instruments.
Shift 0 0–5 Displaces the plotted line forward in time. Cosmetic for reading a chart, but it changes which bar a rule compares against, so leave it at 0 unless you mean it.

ค่าตั้งต้นเริ่มต้น

Fast pair 5 / 20 More crossovers, more noise
Standard pair 10 / 50 The Builder template's baseline
Slow pair 50 / 200 Few signals, regime-level only

ตัวอย่างในตลาด

ที่ MA ทำงานได้ ที่มันล้มเหลว และตัวกรองเปลี่ยนผลลัพธ์อย่างไร

ทำงานได้

Crossover into a trend

The fast average crosses up through the slow one just as a range resolves, and the two lines stay apart for the whole move — the case the crossover rule is designed for.

ล้มเหลว

Whipsaw in a flat market

In a range the two averages sit on top of each other and cross repeatedly. Each cross is a trade with no move behind it.

ถูกกรอง

Filtered by trend strength

Add a strength or momentum filter and the same cluster of crossings is ignored while price goes nowhere — the filter is what separates a signal from range noise.

FAQ

SMA or EMA — which should an EA use?
Neither is better in general. The EMA reacts sooner because recent bars carry more weight, so it turns earlier and also whipsaws earlier; the SMA is steadier and later. iMA accepts both as ENUM_MA_METHOD values, so make it an input and let the backtest decide per pair and timeframe rather than choosing on principle.
What period should I use?
There is no universal number. 10/50 is the Builder template's baseline and a reasonable starting point; 50/200 describes regime rather than entries. Treat any pair as a value to re-validate on your own data — a period that only wins on one window is a fitted number, not a setting.
Can a moving average be calculated on something other than the close?
Yes. iMA takes an ENUM_APPLIED_PRICE argument, so the average can run on Open, High, Low, Median, Typical or Weighted price as well as Close. Median and Typical include the bar's range, which slightly steadies the line on instruments with long wicks.
Why do crossovers perform so badly on their own?
Because a crossover is a statement about the past — the shorter average has already moved. In a trend that lag is acceptable; in a range it guarantees you buy the top of every swing and sell the bottom. The crossover is a trigger, and it needs a filter that says whether a trend exists.
Can I build a moving-average EA without coding?
Yes. The MA Crossover template wires two MA nodes into a Cross node with period, method and applied price exposed as EA inputs, so you can compile, backtest and optimise it per pair without writing MQL5. Reading a multi-MA fan as one state is the exception — that needs an ordering node such as the Perfect Order template's.
How should I validate settings before going live?
Backtest on quality tick data first, then run the EA on a demo account before risking money. When optimising, hold back data the search never saw and prefer settings that stay profitable across periods over the single in-sample peak — chasing that peak is overfitting the noise. No default or preset here is a performance promise; every value is a starting point to re-validate on your own pair and broker.