DT_ZZ_Impuls_Slope





//+------------------------------------------------------------------+
//|                                                 DT_ZZ_Impuls.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, klot."
#property link      "klot@mail.ru"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Gold
#property indicator_level1 0.0
//---- indicator parameters
extern int ExtDepth=6;
extern double scale=3000;
//---- indicator buffers
double zzL[];
double zzH[];
double zz[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(3);
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
//---- indicator buffers mapping
   SetIndexBuffer(0,zz);
   SetIndexBuffer(1,zzH);
   SetIndexBuffer(2,zzL);
   SetIndexEmptyValue(0,0.0);
   SetIndexEmptyValue(1,0.0);
   SetIndexEmptyValue(2,0.0);
//---- indicator short name
   IndicatorShortName("DT_Impuls("+ExtDepth+")");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int    i,shift,pos,lasthighpos,lastlowpos,curhighpos,curlowpos;
   double curlow,curhigh,lasthigh,lastlow;
   double min, max;
   int s;
   double h;
   ArrayInitialize(zz,0.0);
   ArrayInitialize(zzL,0.0);
   ArrayInitialize(zzH,0.0);
   
   lasthighpos=Bars; lastlowpos=Bars;
   lastlow=Close[Bars];lasthigh=Close[Bars];
  for(shift=Bars-ExtDepth; shift>0; shift--)
    {
      curlowpos=iLowest(NULL,0,MODE_CLOSE,ExtDepth,shift);
      curlow=Close[curlowpos];
      curhighpos=iHighest(NULL,0,MODE_CLOSE,ExtDepth,shift);
      curhigh=Close[curhighpos];
      //------------------------------------------------
      if( curlow>=lastlow ) { lastlow=curlow; }
      else { 
            //èäåì âíèç
            if( lasthighpos>curlowpos  ) { 
               zzL[curlowpos]=curlow;
               min=100000; pos=lasthighpos;
               for(i=lasthighpos; i>=curlowpos; i--) { 
                    if (zzL[i]==0.0) continue;
                    if (zzL[i]<=min) { min=zzL[i]; pos=i; }
               } 
            } 
            lastlowpos=curlowpos;
            lastlow=curlow; 
      }
      //--- high
      if( curhigh<=lasthigh )  { lasthigh=curhigh;}
      else {  
            // èäåì ââåðõ
            if( lastlowpos>curhighpos ) {  
               zzH[curhighpos]=curhigh;
               max=-100000; pos=lastlowpos;
               for(i=lastlowpos; i>=curhighpos; i--) { 
                    if (zzH[i]==0.0) continue;
                    if (zzH[i]>=max) { max=zzH[i]; pos=i; }
               } 
            }
            lasthighpos=curhighpos;
            lasthigh=curhigh;
      }    
      //---
      if( lasthighpos>=lastlowpos  ) {
         h=(zzH[lasthighpos]-zzL[lastlowpos]);
         s=(lasthighpos-shift); 
         zz[shift]=-MathArctan(scale*(h/(1.0*s)));
      }
      if( lastlowpos>=lasthighpos ) {
         h=(zzH[lasthighpos]-zzL[lastlowpos]);
         s=(lastlowpos-shift);
         zz[shift]=MathArctan(scale*(h/(1.0*s)));
      }
    //----------------------------------------------------------------------
  }
  
  return(0);
}
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:

Series array that contains close prices for each bar


Indicator Curves created:

Implements a curve of type DRAW_LINE


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: