MTF_MACD_sBar_4Cm
Download scriptThis tool is designed for traders who need to monitor specific momentum trends across different timeframes simultaneously without constantly switching between different charts. It functions by analyzing the MACD (Moving Average Convergence Divergence)—a popular technical indicator used to identify changes in price momentum and trend direction.
How it Works
The primary logic of this script revolves around "Multi-Timeframe" (MTF) analysis. Instead of just showing you what is happening on your current screen, it allows you to overlay signals from a higher timeframe (such as viewing Hourly trends while looking at a 5-minute chart).
The indicator looks for two specific components of the MACD:
- The Main Line: Represents the current trend strength.
- The Signal Line: Acts as a smoothed average of the main line to identify potential reversals or confirmations.
Visual Signals and Logic
The script identifies four distinct market conditions based on where these two lines sit in relation to each other and the "Zero Line" (the baseline). It represents these using visual markers on your chart:
- Bullish Strength (Positive Trend): When the trend is above zero, the tool distinguishes between a strong bullish confirmation (where the Signal line is above the Main line) and a potential weakening or cooling-off period in an upward move.
- Bearish Strength (Negative Trend): When the trend is below zero, the tool distinguishes between a strong bearish confirmation (where the Signal line is below the Main line) and a possible slowing of downward momentum.
Key Features for the User
- Timeframe Flexibility: You can set the script to monitor specific periods (e.g., M1, M5, H1, D1, etc.). The tool automatically calculates the data from these larger windows and projects it onto your current view.
- Customizable Sensitivity: The logic includes adjustable parameters for "Fast," "Slow," and "MA" speeds. This allows you to tune the indicator to be more reactive (faster signals) or more stable (slower, confirmed trends) depending on your trading style.
- Buffer Refreshing: The script includes an automated update mechanism. This ensures that if the data from a higher timeframe hasn't changed yet, the visual markers stay consistent and "smooth" across the smaller timeframe candles, preventing flickering or erratic visual jumps.
In short, this tool acts as a sophisticated filter, helping you see the "big picture" of market momentum while staying focused on your immediate trading execution.
//+------------------------------------------------------------------+
//| mod of cja mtf 4c macd / macd Sidebar MTF_MACD_Bar.mq4 |
//| forex-tsd.com Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.metaquotes.net ik |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//+------------------------------------------------------------------+
//| FlatTrend.mq4 |
//| Kirk Sloan |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Kirk Sloan"
#property link "http://www.metaquotes.net"
#property link "Modified by cja"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Green
#property indicator_color2 YellowGreen
#property indicator_color3 Crimson
#property indicator_color4 Tomato
#property indicator_maximum 77
#property indicator_minimum 1
//---- input parameters
extern int Minutes=0;
extern int MACD_Fast = 8; // 5 |12 Standart | 8 CJA Settings | 5 Valeo
extern int MACD_Slow = 17; // 35 |26 | 17 | 8
extern int MACD_MA = 9; // 5 |9 | 9 | 5
extern int MACDbarLevel = 2;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
/*double Ma;
double hhigh, llow;
double Psar;
double MA1,MA2,MA3;
double PADX,NADX;*/
string TimeFrameStr;
double MACD_Signal;
double MACD_Main;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_ARROW);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_ARROW);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_ARROW);
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexArrow(0,59);
SetIndexArrow(1,59);
SetIndexArrow(2,59);
SetIndexArrow(3,59);
SetIndexLabel(0,"MACD>0Up["+Minutes+"]("+MACD_Fast+";"+MACD_Slow+";"+MACD_MA+")");
SetIndexLabel(1,"MACD>0Dn["+Minutes+"]("+MACD_Fast+";"+MACD_Slow+";"+MACD_MA+")");
SetIndexLabel(2,"MACD<0Dn["+Minutes+"]("+MACD_Fast+";"+MACD_Slow+";"+MACD_MA+")");
SetIndexLabel(3,"MACD<0Up["+Minutes+"]("+MACD_Fast+";"+MACD_Slow+";"+MACD_MA+")");
switch(Minutes)
{
case 1 : TimeFrameStr="Period_M1"; break;
case 5 : TimeFrameStr="Period_M5"; break;
case 15 : TimeFrameStr="Period_M15"; break;
case 30 : TimeFrameStr="Period_M30"; break;
case 60 : TimeFrameStr="Period_H1"; break;
case 240 : TimeFrameStr="Period_H4"; break;
case 1440 : TimeFrameStr="Period_D1"; break;
case 10080 : TimeFrameStr="Period_W1"; break;
case 43200 : TimeFrameStr="Period_MN1"; break;
default : TimeFrameStr="Current Timeframe"; Minutes=0;
}
IndicatorShortName("MTF_MACDsb("+TimeFrameStr+")["+MACD_Fast+";"+MACD_Slow+";"+MACD_MA+";");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
datetime TimeArray[];
int i,limit,y=0,counted_bars=IndicatorCounted();
// Plot defined time frame on to current time frame
ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),Minutes);
limit=Bars-counted_bars+Minutes/Period();
for(i=0,y=0;i<limit;i++)
{
if (Time[i]<TimeArray[y]) y++;//for (int i = 0; i < 300; i++){
ExtMapBuffer1[i]=EMPTY_VALUE;
ExtMapBuffer2[i]=EMPTY_VALUE;
ExtMapBuffer3[i]=EMPTY_VALUE;
ExtMapBuffer4[i]=EMPTY_VALUE;
MACD_Signal=iMACD(NULL,Minutes,MACD_Fast,MACD_Slow,MACD_MA,0,1,y);
MACD_Main =iMACD(NULL,Minutes,MACD_Fast,MACD_Slow,MACD_MA,0,0,y);
if(MACD_Signal > MACD_Main && MACD_Main > 0)ExtMapBuffer1[i] = MACDbarLevel;//Sig above MACD & Above 0
if(MACD_Signal <= MACD_Main && MACD_Main > 0)ExtMapBuffer2[i] = MACDbarLevel;//Sig Below=MACD & Above 0
if(MACD_Signal > MACD_Main && MACD_Main < 0)ExtMapBuffer3[i] = MACDbarLevel;//Sig above MACD & Below 0
/* if(ExtMapBuffer1[i] == 0 && ExtMapBuffer2[i] == 0)
{ExtMapBuffer3[i] = 1;}*/
if(MACD_Signal <= MACD_Main && MACD_Main <=0)ExtMapBuffer4[i] = MACDbarLevel;//Sig Below=MACD & Below =0
}
//---- Refresh buffers ++++++++++++++++++++ upgrade by Raff
int TimeFrame; if (TimeFrame>Period()) {
int PerINT=TimeFrame/Period()+1;
datetime TimeArr[]; ArrayResize(TimeArr,PerINT);
ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period());
for(i=0;i<PerINT+1;i++) {if (TimeArr[i]>=TimeArray[0]) {
//----
/********************************************************
Refresh buffers: buffer[i] = buffer[0];
********************************************************/
ExtMapBuffer1[i] = ExtMapBuffer1[0];
ExtMapBuffer2[i] = ExtMapBuffer2[0];
ExtMapBuffer3[i] = ExtMapBuffer3[0];
ExtMapBuffer4[i] = ExtMapBuffer4[0];
//----
} } }
//+++++++++++++++++++++++++++++++++++++++++++++++ Raff
//----
return(0);
}
//+-------------------------------------------------------+
Comments