PChannel_WITH SHIFT

PChannel_WITH SHIFT
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
PChannel_WITH SHIFT
//+------------------------------------------------------------------+
//|                                                   PChannel_m.mq4 |
//+------------------------------------------------------------------+

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 DodgerBlue
#property indicator_color2 DodgerBlue
#property indicator_color3 DodgerBlue
//---- input parameters
extern int Range=14;
extern int Shift=5;
//---- buffers
double UpBuffer[];
double DnBuffer[];
double MdBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   SetIndexStyle(0,DRAW_LINE,1,2);
   SetIndexStyle(1,DRAW_LINE,1,2);
   SetIndexStyle(2,DRAW_LINE,2);
   SetIndexBuffer(0,UpBuffer);
   SetIndexBuffer(1,DnBuffer);
   SetIndexBuffer(2,MdBuffer);
//---- name for DataWindow and indicator subwindow label
   short_name="PriceChannel("+Range+")";
                                        
   IndicatorShortName(short_name);
                                  
   SetIndexLabel(0,"Up Channel");
                                  
   SetIndexLabel(1,"Down Channel");
                                   
   SetIndexLabel(2,"Middle Channel");
                                     
//----
   SetIndexDrawBegin(0,Range + Shift);
   SetIndexDrawBegin(1,Range + Shift);
   SetIndexDrawBegin(2,Range + Shift);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| PriceChannel                                                     |
//+------------------------------------------------------------------+
int start()
  {
   int i;

//----
   
   for(i=Bars-1;i>=0;i--)
   {
      UpBuffer[i]=High[Highest(NULL,0,MODE_HIGH,Range,i + Shift)];
      DnBuffer[i]=Low[Lowest(NULL,0,MODE_LOW,Range,i + Shift)];
      MdBuffer[i]=(UpBuffer[i + Shift]+DnBuffer[i + Shift])/2;
   }
   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 ---