//+------------------------------------------------------------------+
//|                                                        lm_volat_pourcent.mq4 |
//| pourcentage de variation du cours d'une bougie sur l'autre                  |
//|                                              |
//+------------------------------------------------------------------+
#property copyright   "" 
#property link        ""
#property description "lm_volat_pourcent"
#property strict
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue
//--- input parameter

//--- buffers
double ExtBullsBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit(void)
  {
   string short_name="lm_volat_pourcent";
//--- 1 additional buffer used for counting.
   IndicatorBuffers(1);
   IndicatorDigits(Digits);
//--- drawing style
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtBullsBuffer);
//--- name for DataWindow and indicator subwindow label

   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
  }
//+------------------------------------------------------------------+
//| Bulls Power                                                      |
//+------------------------------------------------------------------+
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;
   double cumul=0,dif=0;


   for(int i=0; i<limit; i++)
     {
      //double v=int(Volume[i]); // transtypage long -> double
      //cumul-=v*(Close[i]-Open[i]);
      dif=(Close[i]+Open[i]+high[i]+low[i]-Close[i-1]-Open[i-1]-high[i-1]-low[i-1])/4;

      ExtBullsBuffer[i]=1; //dif/Close[i]*100;
     }
//---
   return(rates_total);
  }
