Size of a candle histogram v3

Author: Copyright © 2021, Vladimir Karputov
0 Views
0 Downloads
0 Favorites
Size of a candle histogram v3
ÿþ//+------------------------------------------------------------------+

//|                                Size of a candle histogram v3.mq5 |

//|                              Copyright © 2021, Vladimir Karputov |

//|                     https://www.mql5.com/ru/market/product/43516 |

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

#property copyright "Copyright © 2021, Vladimir Karputov"

#property link      "https://www.mql5.com/ru/market/product/43516"

#property version   "3.001"

#property description "Size of a candle histogram v3"

#property description "Size from 'Open' to 'High', and from 'Open' to 'Low'"

//--- indicator settings

#property indicator_separate_window

#property indicator_buffers 2

#property indicator_plots   2

//--- plot Open High

#property indicator_label1  "Open High"

#property indicator_type1   DRAW_HISTOGRAM

#property indicator_color1  clrDeepSkyBlue

#property indicator_width1  2

//--- plot Open Low

#property indicator_label1  "Open Low"

#property indicator_type2   DRAW_HISTOGRAM

#property indicator_color2  clrCoral

#property indicator_width2  2

//--- input parameters

//--- indicator buffer

double   OpenHighBuffer[];

double   OpenLowBuffer[];

double   m_point=0.0;

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

//| Custom indicator initialization function                         |

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

int OnInit()

  {

//--- indicator buffers mapping

   SetIndexBuffer(0,OpenHighBuffer,INDICATOR_DATA);

   SetIndexBuffer(1,OpenLowBuffer,INDICATOR_DATA);

//--- set accuracy

   IndicatorSetInteger(INDICATOR_DIGITS,0);

//--- name for DataWindow

   PlotIndexSetString(0,PLOT_LABEL,"Open -> High");

   PlotIndexSetString(1,PLOT_LABEL,"Open -> Low");

//---

   m_point=SymbolInfoDouble(Symbol(),SYMBOL_POINT);

//---

   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=limit; i<rates_total; i++)

     {

      OpenHighBuffer[i]=(high[i]-open[i])/m_point;

      OpenLowBuffer[i]=-(open[i]-low[i])/m_point;

     }

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

   return(rates_total);

  }

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

Comments