MQL4 - automated forex trading   /  

Forum

Drawing a Histogram on the Chart

Back to topics list To post a new topic, please log in or register

avatar
39
aparsai 2006.05.16 23:12 

I was wondering how we can draw a histogram on the chart or rather cover the candles with a specific colour. For example I'm trying to cover white candles with green when the white candle is longer than 15 pips. Here is the code I've written and I don't know what's wrong with it. Any ideas?

//+------------------------------------------------------------------+
//|                                                 Colour_White.mq4 |
//+------------------------------------------------------------------+
#property copyright "Alireza Parsai"
#property link      "http://www.cadpanel.com"
 
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Green
//---- input parameters
extern double       Span=15.0;
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM, 0, 2, Green);
   SetIndexBuffer(0,ExtMapBuffer1);
   
   //SetIndexDrawBegin(0,10);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   if (counted_bars<0)
      return(-1);
      else counted_bars--;
      
   int i=Bars-counted_bars;
   
   while (i>=0)
   {
      double _close, _open, _difference;
      
      _close=Close[i];
      _open=Open[i];
      _difference=_close-_open;
      
      if ((_difference>0)&&(_difference>Span*Point))
         {
            ExtMapBuffer1[i]=_open;
            Comment("Bar Lenght:",ExtMapBuffer1[i]);
         }
         else ExtMapBuffer1[i]=0.0;
        
      i--;
   }
//----
   return(0);
  }
//+------------------------------------------------------------------+


Thanks in advance
Displaying of Support/Resistance Levels

Displaying of Support/Resistance Levels

The article deals with detecting and indicating Support/Resistance Levels in the MetaTrader 4 program. The convenient and universal indicator is based on a simple algorithm. The article also tackles such a useful topic as creation of a simple indicator that can display results from different timeframes in one workspace.


avatar
Moderator
5198
stringo 2006.05.17 15:58 

You need for 2 indicator buffers to draw histogram on the main chart.

First buffer for open, second buffer for close prices


avatar
39
aparsai 2006.05.18 16:03 
stringo wrote:

You need for 2 indicator buffers to draw histogram on the main chart.

First buffer for open, second buffer for close prices

Thanks very much. It worked.

avatar
8
kirc 2006.12.19 09:27 
stringo wrote:

You need for 2 indicator buffers to draw histogram on the main chart.

First buffer for open, second buffer for close prices


How to set 2 buffer(start buffer and end buffer)??

I need drew 2 histogram on each bar.

avatar
Moderator
5198
stringo 2006.12.19 12:43 

See Heiken Ashi custom indicator. 'Heiken Ashi' 2 histograms are drawn.


avatar
514
onewithzachy 2010.01.05 11:09 
You may want to see this : http://forum.mql4.com/5348 and http://articles.mql4.com/45 . Hey, cool first name, Alireza.
Back to topics list  

To add comments, please log in or register