Les bandes de Bollinger indiquent la volatilité du marché mais l'interprétation de ces bandes n'est pas nécessairement évidente pour le profane.
J'ai donc écrit un indicateur séparé qui affiche de manière plus parlante l'élargissement et le rétrécissement des bandes, il peut éventuellement servir de filtre à une méthode en considérant le changement de couleur de l'indicateur.
J'ai donc écrit un indicateur séparé qui affiche de manière plus parlante l'élargissement et le rétrécissement des bandes, il peut éventuellement servir de filtre à une méthode en considérant le changement de couleur de l'indicateur.
Code
//+------------------------------------------------------------------+
//| bandSize.mq4 |
//| Copyright © 2011, Nicolas Tuffier |
//| http://www.furyweb.fr/forex/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, Nicolas Tuffier"
#property link "http://www.furyweb.fr/forex/"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LightSkyBlue
#property indicator_color2 RosyBrown
#property indicator_width1 3
#property indicator_width2 3
//--- input parameters
extern int period = 13;
//--- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexBuffer(1,ExtMapBuffer2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit, counted_bars=IndicatorCounted();
double size, b4size = 0;
//---- check for possible errors
if(counted_bars < 0)
return(-1);
//---- last counted bar will be recounted
if(counted_bars > 0)
counted_bars--;
//---- the first bar must be skipped
if(counted_bars == 0)
counted_bars++;
limit = Bars - counted_bars;
//----
for (int i = limit ; i >= 0 ; i--) {
size = iBands(NULL, 0, period, 2, 0, PRICE_CLOSE, MODE_UPPER, i) - iBands(NULL, 0, period, 2, 0, PRICE_CLOSE, MODE_LOWER, i);
if (size > b4size) {
ExtMapBuffer1[i] = size;
ExtMapBuffer2[i] = EMPTY_VALUE;
} else {
ExtMapBuffer1[i] = EMPTY_VALUE;
ExtMapBuffer2[i] = size;
}
b4size = size;
}
//----
//----
return(0);
}
//+------------------------------------------------------------------+