MAonMA
Download scriptThis script is designed as a visual trading tool that identifies long-term market trends by layering multiple averages on top of one another. Instead of looking at the raw price of an asset (like a currency or stock) directly, this tool smooths out the "noise" of the market through a three-stage filtering process.
How it Works The logic follows a sequential flow where each stage serves as the foundation for the next. It uses three distinct calculation periods to refine the data:
- The First Layer (Base Smoothing): The script starts by calculating a standard moving average based on the first set of parameters provided. This represents the initial "smoothing" of the price, removing minor fluctuations to show a clearer trend.
- The Second Layer (Secondary Smoothing): Rather than calculating another average from the price, the script takes the results of the first smoothing layer and applies a second moving average to it. This further stabilizes the data, making the line less reactive to sudden, temporary market spikes.
- The Third Layer (Final Smoothing): The script then takes the output of the second layer and applies a third moving average to it. By the time you see this final line on your chart, the data has been filtered three times over.
The Visual Result The end result is a set of three lines displayed on your trading window. Because each line is derived from the previous one, they provide a highly sophisticated view of market momentum.
For a trader, this means the lines are significantly more stable than standard indicators. They are designed to highlight the underlying "core" direction of the market, filtering out the distractions of short-term volatility to help users identify broader trends with greater clarity.
//+------------------------------------------------------------------+
//| MAonMA.mq4 |
//| Copyright © 2012 |
//| basisforex@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2012"
#property link "basisforex@gmail.com"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Aqua
#property indicator_color3 Yellow
//---- input parameters
extern int maPeriod_1 = 13;
extern int maMethod_1 = 0;
extern int maAppPrice_1 = 0;
extern int maPeriod_2 = 34;
extern int maMethod_2 = 0;
extern int maPeriod_3 = 89;
extern int maMethod_3 = 0;
//---- indicator buffers
double a[];
double b[];
double c[];
//+------------------------------------------------------------------+
int init()
{
SetIndexDrawBegin(0, maPeriod_1 + maPeriod_2 + maPeriod_3);
SetIndexDrawBegin(1, maPeriod_1 + maPeriod_2 + maPeriod_3);
SetIndexDrawBegin(2, maPeriod_1 + maPeriod_2 + maPeriod_3);
//---
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
//---
SetIndexBuffer(0, a);
SetIndexBuffer(1, b);
SetIndexBuffer(2, c);
//---
SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
//---
return(0);
}
//+------------------------------------------------------------------+
int start()
{
int limit, i;
int counted_bars=IndicatorCounted();
//---
if(counted_bars<0) return(-1);
//----
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//=====================
for(i = 0; i < limit; i++)
{
a[i]=iMA(NULL, 0, maPeriod_1 , 0, maMethod_1, maAppPrice_1, i);
}
for(i=0; i<limit; i++)
{
b[i] = iMAOnArray(a, Bars, maPeriod_2, 0, maMethod_2, i);
}
for(i=0; i<limit; i++)
{
c[i] = iMAOnArray(b, Bars, maPeriod_3, 0, maMethod_3, i);
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments