Bandwidth Indicator

Author: Copyright � 2007, Fxid10t@yahoo.com
Indicators Used
Bollinger bands indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Bandwidth Indicator
//+------------------------------------------------------------------+
//| Bandwidth Indicator.mq4
//| Copyright © 2007, Fxid10t@yahoo.com
//| http://www.fxstreet.com/education/technical/identifying-budding-trends-with-bollinger-bands/2006-06-14.html
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, Fxid10t@yahoo.com"
#property link      "http://www.fxstreet.com/education/technical/identifying-budding-trends-with-bollinger-bands/2006-06-14.html"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red

//---- input parameters
extern int chart.timeframe=0; 
extern int period=20;
extern int deviation=2;
extern int bands.shift=0;
extern int applied.price=0;
double BWI,ub,lb,mb;
//---- indicator buffers
double BWI.Buffer[];


int init()  {   
   IndicatorBuffers(1);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0, BWI.Buffer);
   IndicatorShortName("BWI");
   SetIndexDrawBegin(0,period);
   SetIndexLabel(0,"BWI");

return(0); }

int deinit()  {return(0);}

int start() {
   int limit;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
//---- the last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- main loop
   for(int i=0; i<limit; i++)  {
      ub=iBands(Symbol(),chart.timeframe,period,deviation,bands.shift,applied.price,1,i);
      lb=iBands(Symbol(),chart.timeframe,period,deviation,bands.shift,applied.price,2,i);
      mb=iBands(Symbol(),chart.timeframe,period,deviation,bands.shift,applied.price,0,i);
      Print(ub,lb,mb);
      BWI.Buffer[i]=((ub-lb)/mb)*100;}

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