DayImpuls_v3

Download script
Author:
DayImpuls_v3

This indicator is designed to analyze market momentum by calculating the cumulative price movement over specific periods. Instead of simply looking at the current price, it focuses on the relationship between opening and closing prices across a series of bars to identify "impulses" in the market.

How the Logic Works

The script operates by performing a three-step calculation to visualize market trends:

1. Defining the Observation Window The tool uses two primary settings to determine its scope. It looks at a specific number of bars (the period) and calculates a larger historical range based on a multiplier. This allows the indicator to "reach back" into the past to gather enough data to form a meaningful trend signal.

2. Calculating the Price Impulse The core logic works by summing the difference between the Opening price and the Closing price for every bar within the specified period.

  • If a price opens higher than it closes, it registers a specific value.
  • If it closes higher than it opens, it registers the opposite. By adding all these differences together over the designated timeframe, the tool calculates a "net impulse"—essentially measuring whether the collective movement of that period was predominantly upward or downward.

3. Normalizing and Visualizing the Data To make this data readable on a chart, the script performs several refinements:

  • Scaling: It converts the raw price differences into a standardized numerical format so they can be plotted clearly.
  • Zero-Point Adjustment: If there is no significant movement (an impulse of zero), the script assigns a minimal value to ensure the visual line remains continuous and doesn't "break."
  • Inversion for Visualization: The logic flips the sign of the calculated impulse. This allows the indicator to plot the strength of the move as a visible trend line in a separate window, making it easier for a trader to see the momentum of the market at a glance.

Summary for the User

In simple terms, this tool acts like a "momentum tracker." It looks back at a specific chunk of time, calculates whether the price spent more energy moving up or down, and draws a line representing that total force. A larger movement in the line suggests a stronger trend, while smaller fluctuations indicate a consolidating market.

Miscellaneous
Implements a curve of type %1
10 Views
0 Downloads
0 Favorites
DayImpuls_v3
//+---------------------------------------------------------------------+
//| DayImpuls.mq4                                                       |
//|                                                                     | 
//| http://www.arkworldmarket.ru/forum/showthread.php?t=966&page=2&pp=10| 
//+---------------------------------------------------------------------+
#property copyright ""
#property link      "http://www.arkworldmarket.ru/forum/showthread.php?t=966&page=2&pp=10"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Gold
//---- input parameters
extern int       per=14;
extern int       d=100;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int  shift,i;
   double imp,mBar;
   //SetLoopCount(0);
   // loop from first bar to current bar (with shift=0)
   for( shift=Bars-1; shift>=0; shift--)
      //for shift=Bars-1 Downto 0
     {
      ExtMapBuffer1[shift]=1;
      ExtMapBuffer2[shift]=1;
      //SetIndexValue(shift,0);
      //SetIndexValue2(shift,0); 
     }
   mBar=d*per;
   //for shift=mBar downto per 
   for( shift=mBar; shift>=per; shift--)
     {
      imp=0;
      for( i=shift ;i>=shift-per; i--)
        {
         imp=imp+(Open[i]-Close[i]);
        }
      imp=MathRound(imp/Point);
      if (imp==0 )imp=0.0001;
      if (imp!=0 )
        {
         imp=-imp;
         ExtMapBuffer1[shift-per]=imp;
        }
     }
//---- 
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments