Change Code from Bar to Candlestick - page 2

 

Hello again,

This is how it should look.

//+------------------------------------------------------------------+
//|                                                    Open.mq4 |
//|                                                              CK1 |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
//------------------------------------------------------------------
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1  Lime
#property indicator_color2  Red
#property indicator_maximum 1
#property indicator_minimum 0 
double bartu[];
double bartd[];
double trend[];
double vel[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init()
  {
   int Chart_ID;
   ChartSetInteger(Chart_ID,CHART_SCALE,2);
   ChartSetInteger(Chart_ID,CHART_MODE,CHART_CANDLES);
   ChartSetInteger(Chart_ID,CHART_SHOW_GRID,false);
   IndicatorBuffers(4);
   SetIndexBuffer(0,bartu); SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(1,bartd); SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(2,vel);
   SetIndexBuffer(3,trend);
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int deinit()
  {
   return(0);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(1);
   if(counted_bars>0) counted_bars--;
   int limit=MathMin(Bars-counted_bars,Bars-1);

   for(int i=limit; i>0; i--)
     {
      vel[i]=iMA(NULL,0,8,0,MODE_EMA,0,i);

      if(iClose(NULL,0,i)>vel[i]) trend[i] =  0;
      if(iClose(NULL,0,i)<vel[i]) trend[i] = 1;
      if(trend[i]==1) { bartu[i]=High[i]; bartd[i]=Low[i]; }

     }
   return(0);
  }

//-------------------------------------------------------------------
//
//-------------------------------------------------------------------
//


 

Appreciate you working with me on this @GrumpyDuckMan. So what I am trying to accomplish is to have this indicator paint as candlesticks instead of bars on the main chart. I attached two images as an example. When the candlestick option is chosen on MT4, it looks off.

Files:
Bars.PNG  12 kb
 
Volcom:

Appreciate you working with me on this @GrumpyDuckMan. So what I am trying to accomplish is to have this indicator paint as candlesticks instead of bars on the main chart. I attached two images as an example. When the candlestick option is chosen on MT4, it looks off.

   SetIndexStyle(0,DRAW_HISTOGRAM,0,5,clrBlue);

Read section  SetIndexStyle in MQL4 reference manual. You can just go to properties and change the color of the candles. or you can do this;

   ChartSetInteger(Chart_ID,CHART_COLOR_CANDLE_BEAR,clrRed);
   ChartSetInteger(Chart_ID,CHART_COLOR_CANDLE_BULL,clrBlue);
Reason: