MFI_MACD_mtf
Download scriptThis technical indicator is designed to provide traders with a visual representation of market momentum by combining two primary financial analysis tools: the Money Flow Index (MFI) and Moving Averages. Its core purpose is to identify trends and potential turning points by measuring the volume and price flow across different timeframes.
Core Logic and Functionality
1. Multi-Timeframe Analysis One of the most significant features of this script is its ability to "look ahead" at higher timeframes without requiring the user to switch charts manually. It allows the tool to calculate data from larger periods (such as Hourly, Daily, or Weekly) while displaying that information on your current chart. This helps traders understand if the broader market trend supports the smaller movements they see in real-time.
2. The Momentum Calculation (MFI Difference) The script calculates two different Money Flow Index values simultaneously:
- A "Short-term" MFI based on a smaller window of time.
- A "Long-term" MFI based on a larger window of time.
By subtracting the long-term value from the short-term value, the script identifies the "velocity" of the money flow. When the difference is positive and increasing, it suggests that momentum is accelerating in one direction; when it begins to shrink or turn negative, it may indicate that the current move is losing steam.
3. Signal Smoothing To prevent the data from appearing too erratic or "noisy"—which can lead to false signals—the script applies a Moving Average to the results of the calculation mentioned above. This smoothing process clarifies the trend, making it easier for a human observer to see the underlying direction of the market flow rather than reacting to every minor price fluctuation.
Visual Output
The tool plots these calculations as lines on a separate window below your main price chart.
- Dynamic Labeling: The indicator automatically updates its name to show which timeframe it is currently calculating, ensuring you always know exactly what data you are viewing.
- Trend Recognition: The primary goal is to observe the relationship between the smoothed momentum line and the zero level. This helps traders identify where momentum is strongest and where a reversal might be brewing before the price actually turns.
Summary for the User
In simple terms, this script acts as a "momentum speedometer." It looks at how much money is moving into or out of an asset across multiple timeframes, calculates the gap between short-term and long-term activity, and smooths that data into a readable line. This allows you to see the "big picture" momentum while staying focused on your current trading screen.
//+------------------------------------------------------------------+
//|MFI_MACD_mtf Waddah_Attar_Def_RSI.mq4 |
//| Copyright © 2007, Eng. Waddah Attar |
//| mtf 2008forextsd Keris2112 ki waddahattar@hotmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Eng. Waddah Attar mtf2008forex-tsd.com"
#property link "waddahattar@hotmail.com"
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Crimson
#property indicator_color2 BlueViolet
#property indicator_width1 1
#property indicator_width2 1
#property indicator_level1 0
#property indicator_levelcolor Teal
//----
extern int MFIPeriod1 =14;
extern int MFIPeriod2 =34;
extern int MFISig =7;
double ind_buffer1[];
double MABuffer1[];
double MABuffer1h[];
extern int MaxBarsToCount = 1500;
extern int TimeFrame = 0;
extern string note_TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(3);
SetIndexStyle(0, DRAW_LINE);
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(0, ind_buffer1);
SetIndexBuffer(1, MABuffer1);
SetIndexBuffer(2, MABuffer1h);
//----
switch(TimeFrame)
{
case 1 : string TimeFrameStr= "M1"; break;
case 5 : TimeFrameStr= "M5"; break;
case 15 : TimeFrameStr= "M15"; break;
case 30 : TimeFrameStr= "M30"; break;
case 60 : TimeFrameStr= "H1"; break;
case 240 : TimeFrameStr= "H4"; break;
case 1440 : TimeFrameStr= "D1"; break;
case 10080 : TimeFrameStr= "W1"; break;
case 43200 : TimeFrameStr= "MN1"; break;
default : TimeFrameStr= "CurrTF";
}
IndicatorShortName("MFI_MACD ("+MFIPeriod1+","+MFIPeriod2+","+MFISig+") ["+TimeFrameStr+"]");
if (TimeFrame<Period()) TimeFrame=Period();
return(0);
}
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
double MFI1,MFI2;
datetime TimeArray[];
datetime TimeArray1[];
int limit, i, y=0, counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);
ArrayCopySeries(TimeArray1,MODE_TIME,Symbol(),TimeFrame);
limit = Bars - counted_bars;
limit=MathMax(limit,TimeFrame/Period());
limit= MathMin(limit,MaxBarsToCount);
//----
for(i=0,y=0;i<limit;i++)
{
if (Time[i]<TimeArray[y]) y++;
MFI1 = iMFI(NULL, TimeFrame, MFIPeriod1, y);
MFI2 = iMFI(NULL, TimeFrame, MFIPeriod2, y);
MABuffer1[i] = (MFI1-MFI2);
MABuffer1h[y] = (MFI1-MFI2);
}
for(i=0,y=0;i<limit;i++)
{
if (Time[i]<TimeArray1[y]) y++;
ind_buffer1[i] = iMAOnArray(MABuffer1h,0,MFISig,0,MODE_SMA,y);
}
return(0);
}
//+------------------------------------------------------------------+
Comments