Author: Yuriy Tokman (YTG)
Indicators Used
Bollinger bands indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
speed BB
ÿþ//+------------------------------------------------------------------+

//|                                                           bb.mq4 |

//|                                               Yuriy Tokman (YTG) |

//|                       https://www.mql5.com/ru/users/satop/seller |

//+------------------------------------------------------------------+

#property copyright "Yuriy Tokman (YTG)"

#property link      "https://www.mql5.com/ru/users/satop/seller"

#property version   "1.00"

#property strict

#property indicator_separate_window



#property indicator_buffers 2

#property indicator_width1 2

#property indicator_width2 2

#property indicator_color1 clrGreen

#property indicator_color2 clrRed



input int    period = 250;                // ?5@8>4 

input double deviation = 2;               // :>;-2> AB0=40@B=KE >B:;>=5=89 

input int    bands_shift = 0;             // A4283 >B=>A8B5;L=> F5=K 

input int    applied_price = PRICE_CLOSE; // B8? F5=K 



//---- buffers period,deviation,bands_shift,applied_price

double BU1[];

double BU2[];



string i_name ="";

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

  {

//--- indicator buffers mapping

 i_name = "speed BB("+DoubleToStr(1,0)+")";

 IndicatorShortName(i_name);

 IndicatorDigits(1);



   SetIndexStyle(0,DRAW_LINE);

   SetIndexBuffer(0,BU1);

   SetIndexLabel(0,i_name);

   SetIndexDrawBegin(0,period);

   

   SetIndexStyle(1,DRAW_LINE);

   SetIndexBuffer(1,BU2);

   SetIndexLabel(1,i_name);

   SetIndexDrawBegin(1,period);    

//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

  {

//---

   int limit=rates_total-prev_calculated;

   if(prev_calculated==0)limit--;

   else  limit++;

   

   if(limit<period)return(0);

   if(limit>=rates_total-1)limit = rates_total - period;

     

   for( int i=limit; i>=0 && !IsStopped(); i--)

    {

      BU1[i]=(iBB(1,i) - iBB(1,i+1))/Point;

      BU2[i]=(iBB(2,i) - iBB(2,i+1))/Point;        

    }   

//--- return value of prev_calculated for next call

   return(rates_total);

  }

//+------------------------------------------------------------------+

 double iBB(int buf =0, int shi = 0)

  {

   return iBands(Symbol(),0,period,deviation,bands_shift,applied_price,buf,shi);

  }

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