impulsmodify
Download scriptThis tool is designed to provide traders with a visual summary of market momentum by combining two popular technical analysis indicators: the Exponential Moving Average (EMA) and the MACD (Moving Average Convergence Divergence). Instead of displaying complex lines on your main price chart, this script translates the relationship between these two indicators into a simplified color-coded histogram in a separate window.
Core Logic and Functionality
The script operates by analyzing the daily price trends to determine whether the market is gaining strength or losing steam. It focuses specifically on the "change" or "velocity" of these indicators rather than just their current values.
1. Momentum Tracking The tool calculates the difference between the current value and the previous value for both the EMA and the MACD. By looking at these differences, it can identify whether the trends are currently moving upward (positive change) or downward (negative change).
2. Signal Interpretation The script uses a specific logic gate to assign colors to the histogram based on these movements:
- Green Signal: If both the EMA and the MACD are showing positive momentum simultaneously, the tool highlights this as a bullish movement (indicated by the green histogram).
- Red Signal: If both indicators are showing negative momentum simultaneously, the tool identifies this as a bearish movement (indicated by the red histogram).
- Blue Signal: If the indicators are not in sync—meaning one is moving up while the other is moving down, or if they are fluctuating without a clear unified direction—the tool highlights this as a neutral or conflicting zone (indicated by the blue histogram).
Summary for the User
Essentially, this script acts as a "sentiment filter." It allows you to see at a glance whether the primary market drivers are aligned:
- Green means the trends are working together to move up.
- Red means the trends are working together to move down.
- Blue means the market is currently conflicted or lacks a clear unified direction.
//--------------------------------------------------------------------
// ravi.mq4
//--------------------------------------------------------------- 1 --
#property copyright "Copyright © Roman Shiredchenko, 2009"
//--------------------------------------------------------------------
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Green
#property indicator_color3 Red
//---- indicator parameters
extern int Period_Ema=13;
extern int Period_Macd1=12;
extern int Period_Macd2=26;
extern int Period_Macd3=9;
double ExtBuffer0[];
double ExtBuffer1[];
double ExtBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0,ExtBuffer0);
SetIndexBuffer(1,ExtBuffer1);
SetIndexBuffer(2,ExtBuffer2);
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(2,DRAW_HISTOGRAM);
IndicatorShortName("impulsmodify");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//----------------------------------------------------------------
int start() // Ñïåöèàëüíàÿ ôóíêöèÿ start()
{
//-----------------------------------------------------------------
double
EMA1, EMA2, SumEMA; // 2 ÌÀ äëÿ ðàñ÷åòà çíà÷åíèé èíäèêàòîðà EMA
double
M_0, M_1, SumMacd ; // Çíà÷åíèå MAIN MACD íà 0 è 1 áàðàõ
//--------------------------------------------------------------- 4 --
int i1 = 0; // ïåðåìåííûå äëÿ îòêðûòèÿ çàêðûòèÿ ïîçèöèè
//---ñðåäíÿÿ ÅÌÀ è ìàéí ÌÀÊÄè ðàñòóò
ExtBuffer1[1] = 0;
ExtBuffer0[1] = 0;
ExtBuffer2[1] = 0;
EMA1=iMA(NULL, PERIOD_D1,Period_Ema,0,MODE_EMA,PRICE_CLOSE,i1); // Çíà÷åíèå EÌÀ1 current
EMA2=iMA(NULL, PERIOD_D1,Period_Ema,0,MODE_EMA,PRICE_CLOSE,i1+1); // Çíà÷åíèå EÌÀ2 prev
SumEMA = 0;
SumEMA = EMA1 - EMA2;
M_0=iMACD(NULL, PERIOD_D1,Period_Macd1,Period_Macd2,Period_Macd3,PRICE_CLOSE,MODE_MAIN,i1); //
M_1=iMACD(NULL, PERIOD_D1,Period_Macd1,Period_Macd2,Period_Macd3,PRICE_CLOSE,MODE_MAIN,i1+1); //
SumMacd=0;
SumMacd=M_0-M_1;
if (SumEMA>0 && SumMacd>0) ExtBuffer1[1] = 4; // mas green
if (ExtBuffer1[1] == 0)
{
if (SumEMA<0 && SumMacd<0) // åñëè åìà è ìàêäè óìåíüøàþòñÿ, òî ðèñóé êðàñíóþ ëèí
{ ExtBuffer2[1] = 2;
} else
ExtBuffer0[1] = 3; // èíà÷å ðèñóé blue ëèíèþ ãèñòîãðàììû
}
//-------------------------------------------
return; // Âûõîä èç ñïåö. ô-èè start()
}
//-------------------------------------------------------------- 15 --
Comments