Miscellaneous
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 Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---