ma_VininI_V_v2
Download scriptThis custom technical indicator is designed to provide traders with a smoothed, reactive visual aid on their price charts. Its primary purpose is to identify underlying trends by calculating a refined moving average that filters out minor market noise while remaining sensitive to significant price shifts.
Core Mechanics
The tool operates by analyzing a specific window of historical price data (determined by the user-defined period). Rather than simply looking at the current price, it calculates an Exponential Moving Average (EMA) across five consecutive data points. By using the EMA as its foundation, the indicator prioritizes recent price action while still acknowledging historical context.
Operating Modes
The script offers two distinct mathematical "modes" that allow users to choose how the indicator reacts to market volatility:
- Mode 0 (Weighted Smoothing): This mode employs a complex weighted calculation. It looks at the difference between the current value and several previous points, applying different levels of importance (weighting) to each. This creates a highly stabilized line that attempts to balance smoothness with responsiveness, making it ideal for identifying long-term trends without being easily distracted by "fake" price spikes.
- Mode 1 (Aggressive Dynamics): This mode utilizes a different arithmetic formula that emphasizes the current data point more heavily against specific historical offsets. It is designed to be more reactive, aiming to catch price turns or trend continuations more quickly than the standard smoothing method might allow.
Visual Representation
On the trading platform, the logic translates into a continuous yellow line plotted directly on the main chart window. This line serves as a visual guide: when the price trends in one direction and stays above or below this line, it signifies a sustained momentum. The specific period setting allows the user to customize the "speed" of the indicator—shorter periods will make the line move more rapidly with the price, while longer periods will provide a much smoother, broader view of the market's trajectory.
//+------------------------------------------------------------------+
//| V.mq4 |
//| Victor Nicolaev |
//| vinin@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Victor Nicolaev"
#property link "vinin@mail.ru"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow
extern int MAPeriod=13;
extern int mode=0;
double MA[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexDrawBegin(0,2*MAPeriod);
SetIndexBuffer(0,MA);
IndicatorShortName("V");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit() { return(0); }
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
int i,j,
counted_bars=IndicatorCounted(),
limit=Bars-counted_bars-1;
double Value[5];
for (i=limit;i>=0;i--) {
for (j=0;j<5;j++) Value[j]=iMA(NULL,0,MAPeriod,0,MODE_EMA,PRICE_CLOSE,i+j);
if (mode==0) MA[i]=Value[0]+(((Value[0]-Value[1])+(Value[0]-Value[2])/2.0+(Value[0]-Value[3])/3.0+(Value[0]-Value[4])/4.0)/4.0);
if (mode==1) MA[i]=Value[0]+(2.0*Value[0]-Value[3]-Value[4])/4;
}
return(0);
}
Comments