MaxMinBands

Author: Copyright � 2009, Julien Loutre
MaxMinBands
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
MaxMinBands
//+------------------------------------------------------------------+
//|                                                  MaxMinBands.mq4 |
//|                      Copyright © 2005, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Julien Loutre"
#property link      "http://www.zenhop.com"
//---- indicator settings
#property  indicator_chart_window
#property indicator_buffers  2
#property  indicator_color1  LightSkyBlue
#property  indicator_color2  Plum

//---- input parameters


extern int       Band_Period   = 120;


//---- buffers
double WWBuffer1[];
double WWBuffer2[];

double ATR;

int init() {
   IndicatorBuffers(2);
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
   IndicatorDigits(Digits+2);

   SetIndexBuffer(0, WWBuffer1);
   SetIndexBuffer(1, WWBuffer2);
   
   IndicatorShortName("Min/Max Bands");
   
   
   return(0);
  }
int start() {
   int    counted_bars=IndicatorCounted();
   int    limit,i;
   
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   
   for(i=limit-1; i>=0; i--) {

      WWBuffer1[i] = getPeriodHigh(Band_Period,i);
      WWBuffer2[i] = getPeriodLow(Band_Period,i);
      
      
   }
   return(0);
}

double getPeriodHigh(int period, int pos) {
   int i;
   double buffer = 0;
   for (i=pos;i<=pos+period;i++) {
      if (High[i] > buffer) {
         buffer = High[i];
      }
   }
   return (buffer);
}
double getPeriodLow(int period, int pos) {
   int i;
   double buffer = 100000;
   for (i=pos;i<=pos+period;i++) {
      if (Low[i] < buffer) {
         buffer = Low[i];
      }
   }
   return (buffer);
}

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 ---