MAMy v[1].3
Download scriptThis tool is designed to analyze price movements by looking at the relationship between different types of Moving Averages (MA). Instead of just looking at the raw price of an asset, it calculates specific gaps and trends to identify momentum and potential shifts in market direction.
How the Logic Works
The script functions by comparing three distinct moving average data points:
- Current Price Trend: A standard look at the recent price action.
- Opening Price Trend: A comparison against where the price started in a specific timeframe.
- Weighted Comparison: A calculation that prioritizes certain recent price movements over others to provide a "weighted" perspective on the market's direction.
Key Analytical Processes
The logic follows a systematic process to determine whether a trend is strengthening or weakening:
1. Gap Analysis The script calculates the mathematical distance between the current price trend and the weighted trend. By multiplying these differences, it creates a visual representation of how far "stretched" the market is from its weighted average.
2. Trend Confirmation Rules The tool doesn't just react to any price change; it looks for specific conditions to be met before identifying a movement. It checks if:
- Price trends are moving in the same direction as previous bars.
- The current price maintains a specific position relative to the opening prices and weighted averages.
- The "gap" calculated in the first step is either expanding or contracting in a way that suggests consistent momentum.
3. Signal Filtering The script includes a logic gate to filter out "noise." It specifically looks for moments where trends cross over one another. If the tool detects a specific reversal—where a positive trend turns negative or vice versa—it can reset certain values to zero. This helps in identifying clear entry/exit points by smoothing out erratic price fluctuations that don't meet the strict criteria of a sustained move.
Summary for the User
In simple terms, this script acts as a momentum filter. It looks at the "space" between where the price is and where it "should" be based on weighted averages. It only highlights movements when those gaps are moving in a consistent, confirmed direction, helping traders visualize trend strength more clearly than a standard moving average alone.
//+------------------------------------------------------------------+
//| MAMy v.3.mq4 |
//| Copyright © 2006, Victor Chebotariov |
//| http://www.chebotariov.com/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Victor Chebotariov"
#property link "http://www.chebotariov.com/"
//----
extern int period = 3;
extern int ma_method = 3;
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorShortName("MAMy v.3 (" + period + ", " + ma_method + ")");
//---- indicators
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(1, ExtMapBuffer2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int i, counted_bars = IndicatorCounted();
//----
i = Bars - counted_bars - 1;
while(i >= 0)
{
double close = iMA(NULL, 0, period, 0, ma_method, 0, i);
double open = iMA(NULL, 0, period, 0, ma_method, 1, i);
double weighted = iMA(NULL, 0, period, 0, ma_method, 6, i);
double close1 = iMA(NULL, 0, period, 0, ma_method, 0, i + 1);
double open1 = iMA(NULL, 0, period, 0, ma_method, 1, i + 1);
double weighted1 = iMA(NULL, 0, period, 0, ma_method, 6, i + 1);
ExtMapBuffer2[i] = (close - weighted)*1000;
if((close < close1 && weighted < weighted1 && close < weighted &&
weighted < open && weighted1 < open1 &&
ExtMapBuffer2[i] <= ExtMapBuffer2[i+1]) ||
(close > close1 && weighted > weighted1 &&
close>weighted && weighted > open && weighted1>open1 &&
ExtMapBuffer2[i] >= ExtMapBuffer2[i+1]))
{
ExtMapBuffer1[i] = ((weighted - open) + (close - weighted))*1000;
}
else
ExtMapBuffer1[i] = 0;
if(ExtMapBuffer1[i] >= 0 && ExtMapBuffer1[i] > ExtMapBuffer1[i+1] &&
ExtMapBuffer2[i] < 0 && ExtMapBuffer2[i+1] >= 0)
{
ExtMapBuffer2[i] = 0;
}
else
ExtMapBuffer2[i] = (close - weighted)*1000;
i--;
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments