Price_Channel_v1

Author: Copyright � 2010, MetaQuotes Software Corp.
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Price_Channel_v1
//+------------------------------------------------------------------+
//|                                                      Sredina.mq4 |
//|                      Copyright © 2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- input parameters
extern int       ChannelPeriod=30;
//---- buffers
double MediumBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,MediumBuffer);
   SetIndexLabel(0, "MidCh");
   SetIndexDrawBegin(0, ChannelPeriod);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int i,limit, counted_bars = IndicatorCounted();
   int    k;
   
//----
   if(Bars <= ChannelPeriod) 
       return(0);
//---- initial zero
   if(counted_bars < 1)
      for(i = 1;i <= ChannelPeriod; i++) 
          MediumBuffer[Bars-i] = 0.0;
//----
   i = Bars - ChannelPeriod - 1;
   if(counted_bars >= ChannelPeriod) 
       i = Bars - counted_bars - 1;
//----
   Comment(i);
   while (i>=0)
   {
      double high=High[iHighest(NULL,0,2,ChannelPeriod,i)];
      double low=Low[iLowest(NULL,0,1,ChannelPeriod,i)];
      double high1=High[iHighest(NULL,0,2,ChannelPeriod,i+1)];
      double low1=Low[iLowest(NULL,0,1,ChannelPeriod,i+1)];
      //UpBuffer[i]=iHighest(High,PeriodPR,i);
      //DownBuffer[i]=iLowest(Low,PeriodPR,i);
      if (MathAbs(((high+low)/2.0)-(high1+low1)/2.0)<Point)
      MediumBuffer[i]=(high+low)/2.0;
      //else MediumBuffer[i]=0.0;
      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 ---