DynamicRS_Channel_mtf





//+------------------------------------------------------------------+
//|                                            DynamicRS+Channel.mq4 |
//|                                 Copyright © 2007, Nick A. Zhilin |
//|  mtf: ForexTSD.com 2007                          rebus58@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Nick A. Zhilin"
#property link      "rebus58@mail.ru"

extern int Filter=15;
extern string     ____ = "_____";
extern int TimeFrame = 0;
extern string  note_TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN";
extern string  IndicatorCorrectName = "DynamicRS_Channel_mtf";
extern string  note___Ind_Name = "if ind.Name changed - enter New Name";


#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Yellow
#property indicator_color2 Aqua
#property indicator_color3 Red

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorShortName("DynamicRS_Channel");
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,ExtMapBuffer3);
    if (TimeFrame < Period()) TimeFrame = Period();
   SetIndexLabel(0,"DRS_Line");
   SetIndexLabel(1,"DRS+"+Filter+"");
   SetIndexLabel(2,"DRS-"+Filter+"");

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| DynamicRS+Channel                                                |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars1=IndicatorCounted();
   int      limit1,i1;
   if(counted_bars1 < 0) return(-1);
   limit1 = Bars-counted_bars1;
   if (TimeFrame != Period())
      {
         limit1 = MathMax(limit1,TimeFrame/Period());
         datetime TimeArray[];
        ArrayCopySeries(TimeArray ,MODE_TIME ,NULL,TimeFrame);
            for(i1=0,int y=0; i1<limit1; i1++)
           {
              if(Time[i1]<TimeArray[y]) y++;
              ExtMapBuffer1   [i1]   = iCustom(NULL,TimeFrame,IndicatorCorrectName,0,y);
              ExtMapBuffer2   [i1]   = iCustom(NULL,TimeFrame,IndicatorCorrectName,1,y);
              ExtMapBuffer3   [i1]   = iCustom(NULL,TimeFrame,IndicatorCorrectName,2,y);
            }
         return(0);         
      }
   int i,counted_bars=IndicatorCounted();
   double Channel;
//----
   i=Bars-counted_bars-1;
   while(i>=0)
     {
      if(High[i]<High[i+1] && High[i]<ExtMapBuffer1[i+1]-Filter*Point)   
          ExtMapBuffer1[i]=High[i];
      else if(Low[i]>Low[i+1] && Low[i]>ExtMapBuffer1[i+1]+Filter*Point)
          ExtMapBuffer1[i]=Low[i];
      else
          ExtMapBuffer1[i]=ExtMapBuffer1[i+1];
          
      ExtMapBuffer2[i]=ExtMapBuffer1[i]+Filter*Point;
      ExtMapBuffer3[i]=ExtMapBuffer1[i]-Filter*Point;
         
      i--;
     }

//----
   return(0);
  }
//+------------------------------------------------------------------+



Sample





Analysis



Market Information Used:

Series array that contains open time of each bar
Series array that contains the highest prices of each bar
Series array that contains the lowest prices of each bar


Indicator Curves created:

Implements a curve of type DRAW_LINE


Indicators Used:




Custom Indicators Used:
IndicatorCorrectName

Order Management characteristics:

Other Features: