please did you know how to report the Macd difference on the chart


Hello ;

My target is to make a candle basing on Macd indicator, so I would like to keep Close -High -Low like a normal chart but for the open I use the difference between slow and fast signal on Macd

so my idea is like that : if slow > fast (buy) I calculate the open like that : Close -(difference between the 2 lines on macd ) so we report the macd difference on chart

so here is the simple code and the idea is to draw a Candle basing on indicator like MACD

#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 White
#property indicator_color3 Red
#property indicator_color4 White
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 3
#property indicator_width4 3

extern color color1 = Red;
extern color color2 = White;
extern color color3 = Red;
extern color color4 = White;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
int ExtCountedBars=0;
//| Custom indicator initialization function                         |
int init()
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM, 0, 1, color1);
   SetIndexBuffer(0, ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM, 0, 1, color2);
   SetIndexBuffer(1, ExtMapBuffer2);
   SetIndexStyle(2,DRAW_HISTOGRAM, 0, 3, color3);
   SetIndexBuffer(2, ExtMapBuffer3);
   SetIndexStyle(3,DRAW_HISTOGRAM, 0, 3, color4);
   SetIndexBuffer(3, ExtMapBuffer4);
//---- indicator buffers mapping
//---- initialization done
//| Custom indicator deinitialization function                       |
int deinit()
//---- TODO: add your code here
//| Custom indicator iteration function                              |
int start()
   double haOpen, haHigh, haLow, haClose;
   double ligne1,ligne2;
   if(Bars<=10) return(0);
//---- check for possible errors
   if (ExtCountedBars<0) return(-1);
//---- last counted bar will be recounted
   if (ExtCountedBars>0) ExtCountedBars--;
   int pos=Bars-ExtCountedBars-1;
      // slow signal
      ligne1 = iCustom(NULL,0,"MACD",12,26,9,0,pos);
      // fast signal
      ligne2 = iCustom(NULL,0,"MACD",12,26,9,1,pos);

      //   the 2 lines of macd 
      if (ligne1<=ligne2) 
         if (haOpen<=haClose) 

the problem is the way to report the macd as a Candle !!

did you have an idea ??

Brian Dee - Random Trader
Brian Dee - Random Trader  

Look at the standard indicator called 'Moving Average of Oscillator' - Sometimes called MACD Histogram in some systems.

And an example EA that uses it here



This idea is is so damn brilliant, someone else already invented it ;)



May be on of the answer is here :

but for I think is one of the problem is also the way to draw candle : if we do it in the subwindow, we must use Function Object .

so at the moment I can show in the normal Candle the Macd like this :

this is a sample Candle with open close High and Low but if you see the shadow sometimes it's blue and sometimes it's black that means : the fast lines crosses over the slow lines (blue) and the opposite (black )

but the real problem here is the candle represent only open and Close, it means there is a lot of variation