Change candle border color in mq5 (MT5)

 

Hello folks, i'm trying to edit the code of heiken ashi indicator so i can also change the color of the border of the candle but since i never coded in mq5 i can't make it work. Can anybody suggest me how to do it please?

This is the original code:

//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_plots   1
#property indicator_type1   DRAW_COLOR_CANDLES
#property indicator_color1  DodgerBlue, Red
#property indicator_label1  "Heiken Ashi Open;Heiken Ashi High;Heiken Ashi Low;Heiken Ashi Close"
//--- indicator buffers
double ExtOBuffer[];
double ExtHBuffer[];
double ExtLBuffer[];
double ExtCBuffer[];
double ExtColorBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtOBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ExtHBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,ExtLBuffer,INDICATOR_DATA);
   SetIndexBuffer(3,ExtCBuffer,INDICATOR_DATA);
   SetIndexBuffer(4,ExtColorBuffer,INDICATOR_COLOR_INDEX);
//---
   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
//--- sets first bar from what index will be drawn
   IndicatorSetString(INDICATOR_SHORTNAME,"Heiken Ashi");
//--- sets drawing line empty value
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,0.0);
  }
//+------------------------------------------------------------------+
//| Heiken Ashi                                                      |
//+------------------------------------------------------------------+
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 start;
//--- preliminary calculations
   if(prev_calculated==0)
     {
      ExtLBuffer[0]=low[0];
      ExtHBuffer[0]=high[0];
      ExtOBuffer[0]=open[0];
      ExtCBuffer[0]=close[0];
      start=1;
     }
   else
      start=prev_calculated-1;

//--- the main loop of calculations
   for(int i=start; i<rates_total && !IsStopped(); i++)
     {
      double ha_open =(ExtOBuffer[i-1]+ExtCBuffer[i-1])/2;
      double ha_close=(open[i]+high[i]+low[i]+close[i])/4;
      double ha_high =MathMax(high[i],MathMax(ha_open,ha_close));
      double ha_low  =MathMin(low[i],MathMin(ha_open,ha_close));

      ExtLBuffer[i]=ha_low;
      ExtHBuffer[i]=ha_high;
      ExtOBuffer[i]=ha_open;
      ExtCBuffer[i]=ha_close;

      //--- set candle color
      if(ha_open<ha_close)
         ExtColorBuffer[i]=0.0; // set color DodgerBlue
      else
         ExtColorBuffer[i]=1.0; // set color Red
     }
//---
   return(rates_total);
  }
 

Nobody knows how to do it? Or it's not possible to do?

Since you can draw candles (and not just histograms like on mq4), i guess it would be possible to also change the border color.

 
Take a look at the properties CHART_COLOR_CHART_UP and CHART_COLOR_CHART_DOWN. Good luck.
Examples of Working with the Chart - Chart Constants - Constants, Enumerations and Structures - MQL4 Reference
Examples of Working with the Chart - Chart Constants - Constants, Enumerations and Structures - MQL4 Reference
  • docs.mql4.com
Examples of Working with the Chart - Chart Constants - Constants, Enumerations and Structures - MQL4 Reference
 
Francesco Grassi #: Nobody knows how to do it? Or it's not possible to do? Since you can draw candles (and not just histograms like on mq4), i guess it would be possible to also change the border color.

Not possible!

Indicator drawn candles, are each a single solid colour for all of it (body and wicks, with no distinction between fill and outline).

Only the Chart drawn candles have a distinction between the fill or the outline (the body or wicks).

 

Thanks for the replies.


Carlos Moreno Gonzalez #:
Take a look at the properties CHART_COLOR_CHART_UP and CHART_COLOR_CHART_DOWN. Good luck.

I tried this but unfortunately these functions only change the border color for the actual candlesticks and not for the generated heiken ashi candles.


Fernando Carreiro #:

Not possible!

Indicator drawn candles, are each a single solid colour for all of it (body and wicks, with no distinction between fill and outline).

Only the Chart drawn candles have a distinction between the fill or the outline (the body or wicks).

It seems so. This looks really a big and odd limitation for the platform

Reason: