ZZ_MTF_XO_2
Download scriptOverview of the ZZ_MTF_XO_2 Indicator
The ZZ_MTF_XO_2 is a technical analysis tool designed for the MetaTrader 4 platform. Its primary purpose is to provide traders with visual signals regarding market momentum and trend direction by analyzing data from a higher timeframe than the one currently being viewed on the chart. By combining multiple layers of analysis into a single view, it helps filter out "market noise" and identify stronger, more reliable trends.
Core Logic and Functionality
The script operates through several distinct logical stages to determine the signals displayed on your screen:
1. Multi-Timeframe (MTF) Integration Instead of looking only at the current chart (e.g., a 5-minute or 1-hour chart), this script automatically pulls data from a specific higher timeframe defined in the settings (such as a 4-hour chart). This allows you to see the "big picture" while trading on smaller timeframes, ensuring your trades align with the broader market direction.
2. Dual-Parameter Analysis The indicator utilizes two different sets of sensitivity parameters (referred to as KirPER1 and KirPER2). Think of these as two different "filters" looking at the price action simultaneously:
- One filter is tuned for specific market sensitivities.
- The second filter is tuned to a different level of reactivity.
By checking both filters, the script can differentiate between a minor price fluctuation and a significant trend shift.
3. Signal Synthesis (The Scoring System) The heart of the logic lies in how it combines these two filters. The script evaluates the data for each filter and assigns "points" or states:
- High-Strength Trend: If both filters agree on an upward movement, the script generates a strong bullish signal.
- Strong Downward Trend: If both filters agree on a downward movement, it generates a strong bearish signal.
- Individual Trends: The script also tracks individual movements from the secondary filter to provide more nuanced information about momentum.
4. Visual Representation The results of this complex calculation are displayed in a separate window below your main price chart as a series of histograms. These are color-coded to make them easy to interpret at a glance:
- Teal and Orange: Represent signals derived from the primary filter logic.
- Lime and Red: Represent the high-strength trends where both filters reach a consensus.
Summary for the User
In simple terms, this script acts as a "trend validator." It looks at a larger timeframe, runs the price data through two different analytical filters, and then colors your screen to tell you when those filters are in agreement. When you see the high-strength signals (the consensus), it indicates that the market is moving with significant momentum according to both sets of rules.
//+------------------------------------------------------------------+
//| ZZ_MTF_XO_2.mq4 |
//| |
//+------------------------------------------------------------------+
#property copyright "AHGDP"
#property link " ZZ_MTF_XO_2 "
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Teal
#property indicator_color2 Orange
#property indicator_color3 Lime
#property indicator_color4 Red
#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 3
#property indicator_width4 3
#property indicator_maximum 2.5
#property indicator_minimum -2.5
extern double KirPER1=4.5;
extern double KirPER2=6.5;
extern int TF1= 240 ;
extern int LineSize1=3;
extern int CountBars=5000;
double xoup1 , xodn1 ;
double xoup2 , xodn2 ;
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,LineSize1);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,LineSize1);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_HISTOGRAM,EMPTY,LineSize1);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_HISTOGRAM,EMPTY,LineSize1);
SetIndexBuffer(3,ExtMapBuffer4);
string ThisName = "ZZ_MTF_XO_2";
string Text=ThisName;
Text=Text+" ("+TF1;
Text=Text+")";
Text=Text+"(";
Text=Text+" "+DoubleToStr(KirPER1,1);
Text=Text+", "+DoubleToStr(KirPER2,1);
Text=Text+") ";
IndicatorShortName(Text);
}
//----
return(0);
//+------------------------------------------------------------------+
//| MTF Parabolic Sar |
//+------------------------------------------------------------------+
int start()
{
int i,limit,y=0,counted_bars=IndicatorCounted();
limit=Bars-counted_bars;
limit=Bars-counted_bars;
limit=Bars-counted_bars;
limit=Bars-counted_bars;
if(counted_bars>0) limit++; else if (limit>100) limit=CountBars;
SetIndexDrawBegin(0,Bars-CountBars);
SetIndexDrawBegin(1,Bars-CountBars);
SetIndexDrawBegin(2,Bars-CountBars);
SetIndexDrawBegin(3,Bars-CountBars);
int lastp15=0, lastp30=0, lastp60=0;
for(i=0,y=0;i<limit;i++)
{
int p1;
p1 = iBarShift( NULL, TF1, Time[i], false );
//========================================================================================
double xo1a = iCustom(NULL,TF1,"XO",KirPER1,0,p1);
double xo1b = iCustom(NULL,TF1,"XO",KirPER1,1,p1);
if ((xo1a > 0)){ xoup1 = 1; xodn1 = 0; }
if ((xo1b < 0)){ xoup1 = 0; xodn1 = 1; }
double xo2a = iCustom(NULL,TF1,"XO",KirPER2,0,p1);
double xo2b = iCustom(NULL,TF1,"XO",KirPER2,1,p1);
if ((xo2a > 0)){ xoup2 = 1; xodn2 = 0; }
if ((xo2b < 0)){ xoup2 = 0; xodn2 = 1; }
//========================================================================================
double TF1Up = 0.0;
double TF1Down = 0.0;
double TF2Up = 0.0;
double TF2Down = 0.0;
if ( (xoup1 + xoup2 ) == 2 ) TF1Up = 2 ;
if ( (xodn1 + xodn2 ) == 2 ) TF1Down = - 2 ;
if ( TF1Up == 2 || TF1Down == - 2 )
{
ExtMapBuffer3[i] = TF1Up;
ExtMapBuffer4[i] = TF1Down;
}
//=========================================================================================
if ( ( xoup2) == 1 ) TF2Up = 1 ;
if ( ( xodn2) == 1 ) TF2Down = - 1 ;
if ( TF2Up == 1 || TF2Down == - 1 )
{
ExtMapBuffer1[i] = TF2Up;
ExtMapBuffer2[i] = TF2Down;
}
//==================================================================
}
return(0);
}
//+------------------------------------------------------------------+
Comments