View Single Post
  #1 (permalink)  
Old 05-16-2006, 08:28 PM
aparsai's Avatar
aparsai aparsai is offline
Senior Member
 
Join Date: May 2006
Posts: 1,096
aparsai is on a distinguished road
Adding Histogram to a Chart

I was wondering how we can draw histogram on the chart or rather cover the candles with a specific colour. For example I'm trying to cover white candles with the green colour 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
__________________
Disclaimer: If you trade my EAs or systems or taking my advice including but not limited to selecting a broker, you are doing so at your own discretion. Forex is a risky business. You may lose substantial amount of money by taking the risk of live trading. I shall not be held responsible for your losses or problems of any kind with the broker.
PipBoxer.com / PBHelp.com / ForexBrace.com (Free MQL Training) / GridBoxer.com / Investatech.com
Reply With Quote