Author:
DayImpuls1

This script is designed as a visual analysis tool for traders, specifically tailored to monitor market momentum and price volatility. It processes historical price data to generate several distinct visual components on a separate chart window, helping users identify trends and potential reversal points.

Core Logic Overview

The script operates by calculating three main types of data: momentum values, smoothed trend lines, and historical range boundaries.

1. Momentum Calculation (DayImpuls) The primary engine of the script calculates an "Impulse" value. It does this by looking at a specific number of preceding candles (defined by the per parameter) and calculating the difference between the opening and closing prices for each. By summing these differences, the script determines the net direction of the price movement over that period. This result is then normalized to provide a steady "Impulse" reading on the chart.

2. Advanced Smoothing (T3 Method) To make the raw impulse data easier to read, the script applies a sophisticated smoothing technique known as the "T3 method." Unlike standard moving averages which can sometimes lag behind the current price, the T3 logic uses a weighted calculation to create a curve that follows the price trend more closely while filtering out "noise" or minor fluctuations. The user can choose to view this smooth line independently or alongside the raw impulse data through the display settings.

3. Dynamic Channeling and Ranges The script also monitors specific historical "look-back" periods based on the timeframe you are viewing (e.g., 15-minute, 30-minute, or 60-minute charts). It scans these periods to identify:

  • Highs and Lows: The highest and lowest momentum points reached during that window.
  • Mid-Point Channels: A calculation that identifies the center point of those highs and lows.

Visual Customization

The script includes a toggle system that allows the user to control what information is displayed on the screen:

  • Mode 0: Shows everything—the raw impulse data, the smoothed T3 curve, the high/low lines, and the channel levels.
  • Mode 1: Focuses only on the primary Impulse data.
  • Mode 2: Focuses only on the smoothed T3 curve, which is ideal for traders who prefer to see the "flow" of the trend rather than raw data points.

Summary of Functionality

Essentially, this tool converts price movement into a momentum score. It then takes that score and smooths it out to show the overall trend (T3), while simultaneously plotting historical boundaries (Max/Min lines) to help traders see where current momentum sits in relation to recent highs and lows.

Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
12 Views
0 Downloads
0 Favorites
DayImpuls1
//+------------------------------------------------------------------+
//| DayImpuls_T3_v2.mq4.mq4
//| 
//| http://www.arkworldmarket.ru/forum/showthread.php?t=966&page=2&pp=10 
//+------------------------------------------------------------------+
// Modest äîáàâèë ñãëàæèâàíèå ïî ìåòîäó t3. Äîáàâèë êàíàëû.
// Ñëåãêà èçìåíèë àëãîðèòì, ÷òîáû ïîíÿòíåå âîñïðèíèìàëñÿ êîä. Íà ñóòü îðèãèíàëà íå âëèÿåò ÍÈÊÀÊ.
// Óáèðàåì ëèøíþþ ãðàôèêó, ââîäèì óïðàâëåíèå ðåæèìîì îòîáðàæåíèÿ
// DisplayMode=0 Îòîáðàæàþòñÿ DayImpuls è ñëàæåííàÿ êðèâàÿ
// DisplayMode=1 Îòîáðàæàþòñÿ òîëüêî DayImpuls 
// DisplayMode=2 Îòîáðàæàþòñÿ òîëüêî ñëàæåííàÿ êðèâàÿ
#property copyright ""
#property link      "http://www.arkworldmarket.ru/forum/showthread.php?t=966&page=2&pp=10"

#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 Indigo
#property indicator_level1 0.0
//---- input parameters
extern int       per=14;
extern int       d=100;
extern int t3_period=8;
extern double b=0.7;
//extern  ChanPercent=70;
extern int DisplayMode=0;
//---- buffers
double  DayImp[];
double  t3[];
//double  MaxH[];
//double  MinH[];
double  MaxLine[];
double  MinLine[];
double  ChanLineMax[];
double  ChanLineMin[];
double Level[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   if (DisplayMode>2 || DisplayMode<0)  DisplayMode=0;
   
   switch ( DisplayMode )
      {
      case 0: 
         SetIndexStyle(5,DRAW_LINE,EMPTY,2,White);
         SetIndexBuffer(5,DayImp); 
         SetIndexStyle(6,DRAW_LINE,EMPTY,2,Red);
         SetIndexBuffer(6,t3);
         break;
      
      case 1: 
         SetIndexStyle(5,DRAW_LINE,EMPTY,2,White);
         SetIndexBuffer(5,DayImp); 
         SetIndexStyle(6,DRAW_NONE,EMPTY,2,Red);
         SetIndexBuffer(6,t3);
         break;
      case 2: 
         SetIndexStyle(5,DRAW_NONE);
         SetIndexBuffer(5,DayImp); 
         SetIndexStyle(6,DRAW_LINE,EMPTY,2,Red);
         SetIndexBuffer(6,t3);
         break;
      
      
      default: 
         SetIndexStyle(5,DRAW_LINE,EMPTY,2,White);
         SetIndexBuffer(5,DayImp); 
         SetIndexStyle(6,DRAW_LINE,EMPTY,2,Red);
         SetIndexBuffer(6,t3);
         break;
      }
   /*
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,DayImp);
   SetIndexStyle(1,DRAW_LINE,EMPTY,2,Red);
   SetIndexBuffer(1,t3);
   */   
   SetIndexStyle(0,DRAW_LINE,EMPTY,1,Goldenrod);
   SetIndexBuffer(0,MaxLine);
   SetIndexStyle(1,DRAW_LINE,EMPTY,1,Goldenrod);
   SetIndexBuffer(1,MinLine);
   SetIndexLabel(0,NULL); SetIndexLabel(1,NULL);SetIndexLabel(2,NULL);SetIndexLabel(3,NULL);
   SetIndexLabel(4,NULL);SetIndexLabel(5,NULL);
   
   SetIndexStyle(2,DRAW_LINE,EMPTY,1,DarkGreen);
   SetIndexBuffer(2,ChanLineMax);
   SetIndexStyle(3,DRAW_LINE,EMPTY,1,DarkGreen);
   SetIndexBuffer(3,ChanLineMin);
   SetIndexStyle(4,DRAW_LINE,EMPTY,1,Blue);
   SetIndexBuffer(4,Level);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   
   
int  shift,i,N;
double imp,mBar,Max,Min;
double e1,e2,e3,e4,e5,e6,c1,c2,c3,c4,n,w1,w2, b2,b3,dpo,Prise,k;
//SetLoopCount(0);
// loop from first bar to current bar (with shift=0)


//===========================================  Ýòî ÿ óæå íàêîëáàñèë t3: ===============
//=========================================== Âçÿò òèïîâîé êîä          ===============
   if(Bars<=t3_period) return(0);
//---- initial zero
   if(counted_bars<t3_period)
   {
     // for(i=1;i<=t3_period;i++) prise[Bars-i]=0.0;
      for(i=1;i<=t3_period;i++) t3[Bars-i]=0.0;
   }
//----
b2=b*b;
b3=b2*b;
c1=-b3;
c2=(3*(b2+b3));
c3=-3*(2*b2+b+b3);
c4=(1+3*b+b3+3*b2);
n=t3_period;

if (n<1) n=1;
n = 1 + 0.5*(n-1);
w1 = 2 / (n + 1);
w2 = 1 - w1;
//----
//================= Êîíåö   ====================  Ýòî ÿ óæå íàêîëáàñèë t3: ===============

int limit;
    counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- main loop


for(shift=0; shift<limit; shift++)
//for shift=Bars-1 Downto 0

{
DayImp[shift]=1; 
t3[shift]=0; 

//SetIndexValue(shift,0);
//SetIndexValue2(shift,0); 
}

mBar=d*per;

//for shift=mBar downto per 
for( shift=Bars-96-1; shift>=0; shift--)
{
   imp=0;
   Level[shift]=0.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;
         DayImp[shift]=imp; 
      }
   
   //for( i=shift ;i<=shift+per; i++) 

     // DayImp[shift]=iMA(NULL,0,14,0,MODE_SMMA,PRICE_HIGH,i);
  
  // ==================================== Ýòî ÿ óæå íàêîëáàñèë t3: ========================
  dpo=DayImp[shift];
    
  e1 = w1*dpo + w2*e1;
  e2 = w1*e1 + w2*e2;
  e3 = w1*e2 + w2*e3;
  e4 = w1*e3 + w2*e4;
  e5 = w1*e4 + w2*e5;
  e6 = w1*e5 + w2*e6;

  t3[shift] = c1*e6 + c2*e5 + c3*e4 + c4*e3;
  // ==========^^^====================== Ýòî ÿ óæå íàêîëáàñèë t3: ====^^^================
      switch ( Period() )
      {
      case 5: N=288; break;
      case 15: N=96; break;
      case 30: N=48; break;
      case 60: N=24; break;
      default: N=0; break;
      }

      if (N==0) {Alert("Work only in M15,M30,M60 timeframes");return(0);}
      Max=DayImp[shift+N-1];
      Min=DayImp[shift+N-1];
      
      for( i=shift ;i<=shift+N-1; i++) 
      {
         if (Max<DayImp[i]) Max=DayImp[i];
         if (Min>DayImp[i]) Min=DayImp[i];
      }
      //MaxH[shift]=Max;//+(Max-Min)*(1-kChannel);
      //MinH[shift]=Min;//+(Max-Min)*(kChannel);
      MaxLine[shift]=Max;//+(Max-Min)*(1-kChannel);
      MinLine[shift]=Min;//+(Max-Min)*(kChannel);
      
      //k=((100-ChanPercent)/2)/100;
      ChanLineMax[shift]=Max/2; // Min+(Max-Min)*(1-k);
      ChanLineMin[shift]=Min/2; //Min+(Max-Min)*(k);
}
   
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments