moving averages (ma)
Info
The moving averages (ma) is a Indicator for MetaTrader 4 that the moving average technical indicator displays the average instrument price value over a specified time frame. when calculating the moving average, the instrument price is averaged for this time period.
Usage
This tool is typically used for enhancing chart analysis and decision making.
Platform
This Indicator works exclusively on MetaTrader 4 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL4/Indicators folder via File ? Open Data Folder in MetaTrader 4.
How to Install and Use moving averages (ma)
1. Installation: Place your file in the MQL/Indicators folder via "Open Data Folder" and restart your terminal.
2. Loading: Find the indicator in the Navigator, drag it onto your chart, and configure the input parameters in the popup window.
3. Customization: Press Ctrl+I to open the indicator list, select your tool, and click "Properties" to change colors, levels, or visual styles.
4. Updating: Replace the old file in the Indicators folder with the new version and restart the platform to apply changes.
Frequently Asked Questions
Q: Why is my indicator not showing? A: Verify the file is in the MQL/Indicators folder, or try right-clicking the "Indicators" tree in the Navigator and clicking "Refresh."
Q: Do custom indicators slow down the platform? A: Too many complex indicators can impact performance; remove unused ones via the "Indicator List" (Ctrl+I).
Q: Can I use MT4 indicators on MT5? A: No, MQL4 and MQL5 are distinct languages; ensure the indicator is compiled specifically for your platform version.
What this tool does
the moving average technical indicator displays the average instrument price value over a specified time frame.
Typical Use Case
This Indicator excels in automated trading and technical analysis on MetaTrader 4.
Compatible Platform & Setup
This Indicator works on MetaTrader 4. Place the file in the MQL4/Indicators folder and restart the terminal.
Description & Settings
Related: Zero Lag Moving Average - another powerful indicator for MetaTrader 4 traders.
the moving average technical indicator displays the average instrument price value over a specified time frame. when calculating the moving average, the instrument price is averaged for this time period. as the price fluctuates, the moving average either rises or falls.Also recommended: dynamic moving average - similar indicator with strong performance on MetaTrader 4.
there are four primary types of moving averages: simple (arithmetic), exponential, smoothed, and linear weighted. moving averages can be calculated for various sequential data sets, including opening and closing prices, highs and lows, trading volume, or any other indicators. it is common to use double moving averages. the main difference between moving averages of different types lies in the weight assigned to the most recent data. in a simple moving average, all prices within the given time frame are equally weighted.
exponential and linear weighted moving averages give more significance to the latest prices. the standard approach to interpreting the price moving average is to compare its trend with the price movement. when the instrument price surpasses its moving average, it signals a potential buying opportunity. conversely, when the price drops below its moving average, it indicates a sell signal. this trading strategy, based on the moving average, aims to capitalize on the prevailing trend rather than pinpointing the exact bottom or peak.
calculation:
- simple moving average (sma):
the sma is calculated by summing the closing prices of the instrument over a specific number of periods (e.g., 12 hours) and dividing the result by the number of periods.
sma = sum(close, n)/n
where: n is the number of calculation periods.
- exponential moving average (ema):
the ema is determined by adding a certain percentage of the current closing price to the previous ema. exponential moving averages emphasize recent prices more.
ema = (close(i)*p)+(ema(i-1)*(100-p))
where: close(i) is the current period's closing price; ema(i-1) is the previous period's ema; p is the percentage of the price value used.
- smoothed moving average (smma):
the initial smma value is calculated as the sma. subsequent smma values are computed using the previous smma and the current closing price.
smma(i) = (sum1-smma1+close(i))/n
where: sum1 is the sum of closing prices for n periods; smma1 is the initial smma; smma(i) is the current smma (excluding the first one); close(i) is the current closing price; n is the smoothing period.
- linear weighted moving average (lwma):
in the lwma, recent data carries more weight. it is calculated by multiplying each closing price in the series by a weight coefficient.
lwma = sum(close(i)*i, n)/sum(i, n)
where: sum(i, n) is the sum of weight coefficients.
moving averages can also be applied to indicators. the interpretation of indicator moving averages follows a similar principle: if the indicator rises above its moving average, it suggests a potential continuation of the upward trend, and vice versa.
types of moving averages on the chart:
- simple moving average (sma)
- exponential moving average (ema)
- smoothed moving average (smma)
- linear weighted moving average (lwma)
technical indicator description:
for a comprehensive description of ma, refer to the
You may also like: moving average of oscillator (osma) - excellent alternative for indicator users on MetaTrader 4.
Source Code
#property copyright "robotfx"
#property link "https://robotfx.org"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 red
extern int ma_period=13;
extern int ma_shift=0;
extern int ma_method=0;
double extmapbuffer[];
int extcountedbars=0;
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.