Elder_Impulse_MTF

Author: Copyright � 2007, Hartono Setiono
Elder_Impulse_MTF

The Impulse Indicator is designed to help traders identify the prevailing momentum of a financial market by combining two popular technical analysis tools: the Exponential Moving Average (EMA) and the Moving Average Convergence Divergence (MACD). Instead of looking at these indicators individually, this script analyzes them simultaneously to categorize market behavior into three distinct states.

How the Logic Works

The script continuously monitors the price movement and calculates the relationship between two specific types of data:

  1. Trend Direction (EMA): It looks at the Exponential Moving Average to determine if the general "flow" of the price is moving upward or downward.
  2. Momentum Strength (MACD): It analyzes the MACD (both its main line and its signal line) to determine the speed and strength of that price movement.

The Three Market States

The indicator translates these complex calculations into a visual histogram with three distinct colors, representing different market conditions:

  • Bearish Momentum (Red): When both the EMA is trending downward and the MACD values are decreasing, the indicator signals a dominant downward push.
  • Bullish Momentum (Lime): When both the EMA is trending upward and the MACD values are increasing, the indicator signals a dominant upward push.
  • Neutral / Transitionary Zone (Blue): If the indicators do not agree—for example, if the price is trending up but losing momentum, or vice versa—the indicator enters a neutral state. This suggests that the market is in a period of consolidation, indecision, or a potential reversal.

Key Features for the User

  • Multi-Timeframe Analysis: The script allows you to view these signals across different timeframes (from 1-minute charts to monthly charts), making it easy to see if the overall trend matches the shorter-term price action.
  • Customizable Sensitivity: You can adjust the periods for the EMA and the MACD settings. This allows users to "fine-tune" how quickly or slowly the indicator reacts to price changes based on their personal trading style.
  • Visual Clarity: By simplifying complex data into a clean, three-color histogram, it provides a quick at-a-glance reference for traders who need to know whether the current market environment is aggressively bullish, bearish, or neutral.
Indicators Used
Moving average indicatorMACD Histogram
Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
Elder_Impulse_MTF
//+------------------------------------------------------------------+
//|                                                      eSignal.mq4 |
//|                               Copyright © 2007,  Hartono Setiono |
//|                                          http://www.mitrakom.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007,  Hartono Setiono"
#property link      "http://www.mitrakom.com"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_width1 4
#property indicator_color2 Lime
#property indicator_width2 4
#property indicator_color3 Blue
#property indicator_width3 4
//---- input parameters
extern int       TimeFrame=0;
extern int       EMA_Period=13;
extern int       MACD_FastPeriod=12;
extern int       MACD_SlowPeriod=26;
extern int       MACD_SignalPeriod=9;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
   
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM);
   //SetIndexArrow(0,110);
   SetIndexBuffer(0,ExtMapBuffer1);
   
   SetIndexStyle(1,DRAW_HISTOGRAM);
   //SetIndexArrow(1,110);
   SetIndexBuffer(1,ExtMapBuffer2);
   
   SetIndexStyle(2,DRAW_HISTOGRAM);
   //SetIndexArrow(2,110);
   SetIndexBuffer(2,ExtMapBuffer3);

   switch(TimeFrame)
   {
      case 1 : short_name="Period_M1"; break;
      case 5 : short_name="Period_M5"; break;
      case 15 : short_name="Period_M15"; break;
      case 30 : short_name="Period_M30"; break;
      case 60 : short_name="Period_H1"; break;
      case 240 : short_name="Period_H4"; break;
      case 1440 : short_name="Period_D1"; break;
      case 10080 : short_name="Period_W1"; break;
      case 43200 : short_name="Period_MN1"; break;
      default : {short_name="Current Timeframe"; TimeFrame=0;}
   }
   short_name="Impulse Indicator("+short_name+", "+EMA_Period+":"+MACD_FastPeriod+","+MACD_SlowPeriod+","+MACD_SignalPeriod+")";

   IndicatorShortName(short_name);
   SetIndexLabel(1,NULL);
   SetIndexLabel(2,NULL);
   SetIndexLabel(3,NULL);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    i,limit,y=0,counted_bars=IndicatorCounted();
   double ema1, main1, signal1, ema0, main0, signal0, macd1, macd0;
 
   limit=Bars-counted_bars;
   for(i=0,y=0;i<limit;i++)
   {
      y = iBarShift(NULL,TimeFrame,Time[i]); 
      ema0=iMA(NULL,TimeFrame,EMA_Period,0,MODE_EMA,PRICE_CLOSE,y); 
      ema1=iMA(NULL,TimeFrame,EMA_Period,0,MODE_EMA,PRICE_CLOSE,y+1); 

      main0=iMACD(NULL, TimeFrame, MACD_FastPeriod, MACD_SlowPeriod, MACD_SignalPeriod, PRICE_CLOSE,0,y); 
      main1=iMACD(NULL, TimeFrame, MACD_FastPeriod, MACD_SlowPeriod, MACD_SignalPeriod, PRICE_CLOSE,0,y+1); 

      signal0=iMACD(NULL, TimeFrame, MACD_FastPeriod, MACD_SlowPeriod, MACD_SignalPeriod, PRICE_CLOSE,1,y); 
      signal1=iMACD(NULL, TimeFrame, MACD_FastPeriod, MACD_SlowPeriod, MACD_SignalPeriod, PRICE_CLOSE,1,y+1); 
      
      macd0=main0-signal0;
      macd1=main1-signal1;

      if(ema0<ema1 && macd0<macd1) //both down
      {
        ExtMapBuffer1[i]=1;
        ExtMapBuffer2[i]=0;
        ExtMapBuffer3[i]=0;
      } else
      if(ema0>ema1 && macd0>macd1) //both up
      {
        ExtMapBuffer1[i]=0;
        ExtMapBuffer2[i]=1;
        ExtMapBuffer3[i]=0;
      } else  //otherwise
      {
        ExtMapBuffer1[i]=0;
        ExtMapBuffer2[i]=0;
        ExtMapBuffer3[i]=1;
      }
   }
   return(0);
  }
//+------------------------------------------------------------------+

Comments