Request for help: HLC bars on MT5

To add comments, please log in or register

Hi, appreciate help on modification of this HLC bars

I have manage to modify this simple indicator that draws color bars  mt5 to draw HLC bars base on this criteria...

1:Draw only high, low & close but not the open.

2:color the bars only base on current close of bar to previous close price..instead of the usual open & close.

Current bug: as i only commented the open price in the code..the open price occasionally appears as artifacts on the screen.

My lack of programing knowledge can only go so far & appreciate of experience folks out there could help me to modify a little bit so as to;

1:Prevent the the open price from drawing (DRAW_NONE or something)

2:& to include a new color if close of previous bar is same level as current close.

Additionally (not essential);

is to include an option to draw for example last 100 bars...

Appreciate any help on this matter...

tks ahead.

below showing occasional open price artifacts...

//|                                                    ColorBars.mq5 |
//|                        Copyright 2009, MetaQuotes Software Corp. |
//|                                     |
#property copyright "2009, MetaQuotes Software Corp."
#property link      ""

#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots   1 
//---- plot ColorBars
#property indicator_label1  "ColorBars HLC" 
#property indicator_type1   DRAW_COLOR_BARS
#property indicator_color1  Blue,Red
#property indicator_label1  "High;Low;Close"
//--- indicator buffers
//double ExtOpenBuffer[];
double ExtHighBuffer[];
double ExtLowBuffer[];
double ExtCloseBuffer[];
double ExtColorsBuffer[];
//| Custom indicator initialization function                         |
void OnInit()
//--- indicators
//--- don't show indicator data in DataWindow
//--- set accuracy
//| 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[])
//--- auxiliary variables
   int  i=0;
   bool close_up=true;
//--- set position for beginning
   if(i<prev_calculated) i=prev_calculated-1;
//--- start calculations
      //ExtOpenBuffer[i]=open[i]; --disable open price display--
      //--- define volume change
         if(close[i]>close[i-1]) close_up=true;
         if(close[i]<close[i-1]) close_up=false;
      //--- set color
      if(close_up) ExtColorsBuffer[i]=0.0;
      else       ExtColorsBuffer[i]=1.0;
//--- return value of prev_calculated for next call
To add comments, please log in or register