sinc moving average
Info
The sinc moving average is a Script for MetaTrader 4 that this is another addition to the collection of moving averages. any ma smooths data by filtering out high-frequency price fluctuations.
Usage
This tool is typically used for enhancing chart analysis and decision making.
Platform
This Script works exclusively on MetaTrader 4 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL4/Scripts folder via File ? Open Data Folder in MetaTrader 4.
How to Install and Use sinc moving average
1. Installation: Move your script file into the MQL/Scripts directory and restart the platform.
2. Execution: Drag the script onto a chart; it will perform a one-time action, such as closing all open orders or clearing chart objects.
3. Editing: Use MetaEditor (F4) to modify code, click "Compile," and verify no errors appear in the terminal before running.
4. Removing: Scripts stop automatically, but you can remove them manually by right-clicking the chart and choosing "Remove Script."
Frequently Asked Questions
Q: How are scripts different from EAs? A: Scripts execute a single action and then stop; EAs monitor the market and trade continuously.
Q: Can I assign a hotkey to a script? A: Yes, right-click the script in the Navigator, select "Set Hotkey," and define your preferred keyboard shortcut.
Q: Why did my script stop? A: Scripts are designed to stop immediately after finishing their programmed command; this is normal behavior.
What this tool does
this is another addition to the collection of moving averages.
Typical Use Case
This Script excels in automated trading and technical analysis on MetaTrader 4.
Compatible Platform & Setup
This Script works on MetaTrader 4. Place the file in the MQL4/Scripts folder and restart the terminal.
Description & Settings
Related: e-moving in wl - another powerful script for MetaTrader 4 traders.
this is another addition to the collection of moving averages. any ma smooths data by filtering out high-frequency price fluctuations. there are many filtering methods, from simple digital filters with equal weighting of past prices (like sma) to more complex filters with uneven weighting of past data (ema, hamming, hanning, blackman, etc.).Also recommended: Moving Average Difference Oscillator - similar script with strong performance on MetaTrader 4.
however, digital filters have a lag. data smoothing methods based on fitting smooth functions to price series theoretically have no lag. for example, one can build an ma based on a polynomial, or use trigonometric functions for fitting, as in fourier series decomposition of price series.
the proposed ma is based on the same fitting idea, but uses wavelets as fitting functions. one of the simplest wavelets is the sinc(x) = sin(pi*x) / (pi*x) function.
to control its decay, an additional multiplier is added: wave(x,q) = sinc(x)*(1 + q*x^2) / (1 + x^2).
sinc moving average
the advantages of sinc can be discussed at length. the crucial point, based on the sampling theorem (shannon's theorem), is that any function can be represented as a sum of sinc wavelets. the fitting principle is difficult to describe briefly; those familiar with wavelet usage will understand.
input parameters are:
n - the number of data points. must be = 2^pwr;
htrun - the number of high-frequency wavelets to discard. if htrun = 0, the ma will reproduce the price series;
q - the wavelet decay factor. q = 1 reproduces sinc. the larger q, the greater the oscillations. it is recommended that q <= 1.
the main advantage of the proposed ma is the absence of lag.
You may also like: multi timeframe moving average indicator - excellent alternative for script users on MetaTrader 4.
Source Code
#property copyright "robotfx"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 blue
#property indicator_width1 2
#define pi 3.141592653589793238462643383279502884197169399375105820974944592
extern int n =256; // number of last bars. must be the power of 2. 0: all data.
extern int htrun =3; // number of the last wavelets to truncate.
extern double q =0.5;
int n;
.......
⚠ 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.