DynamicRS_Channel_mtf

Author: Copyright � 2007, Nick A. Zhilin
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
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);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---