Candle bottom shadow percent histogram

Author: Copyright © 2019, Vladimir Karputov
0 Views
0 Downloads
0 Favorites
Candle bottom shadow percent histogram
ÿþ//+------------------------------------------------------------------+

//|                       Candle bottom shadow percent histogram.mq5 |

//|                              Copyright © 2019, Vladimir Karputov |

//|                                           http://wmua.ru/slesar/ |

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

#property copyright "Copyright © 2019, Vladimir Karputov"

#property link      "http://wmua.ru/slesar/"

#property version   "1.000"

#property indicator_separate_window

#property indicator_buffers 1

#property indicator_plots   1

//--- plot Ratio

#property indicator_label1  "Bottom Ratio"

#property indicator_type1   DRAW_HISTOGRAM

#property indicator_color1  clrGreenYellow

#property indicator_style1  STYLE_SOLID

#property indicator_width1  2

//--- indicator buffers

double         BottomRatioBuffer[];

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,BottomRatioBuffer,INDICATOR_DATA);

//--- sets drawing line to empty value 

   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);

//---

   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=prev_calculated-1;

   if(prev_calculated==0)

      limit=0;



   for(int i=0;i<rates_total;i++)

     {

      double body=(open[i]>close[i])?open[i]-close[i]:close[i]-open[i];

      double shadow=(open[i]>close[i])?close[i]-low[i]:open[i]-low[i];

      if(body==0.0)

        {

         BottomRatioBuffer[i]=0.0;

        }

      else

        {

         BottomRatioBuffer[i]=-shadow/body;

        }

     }

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

   return(rates_total);

  }

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

Comments