View Single Post
  #1 (permalink)  
Old 05-10-2006, 07:02 PM
drgoodvibe drgoodvibe is offline
Senior Member
 
Join Date: Dec 2005
Location: Null
Posts: 532
drgoodvibe is on a distinguished road
Help!! simple color change indicator problem..

Anyone help with this?? I've spent the last three hours trying to make this indicator change the bar color when it is below 0. Green above 0, red below 0. I'm not very good with coding, so any help would be greatly appreciated, thanks!


Quote:

//+------------------------------------------------------------------+
//| DiNapoli Detrend Oscillator.mq4
//| Ramdass - Conversion only
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Blue



extern int x_prd=14;
extern int CountBars=3000;
//---- buffers
double dpo[];


//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(1);
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,3);
SetIndexBuffer(0,dpo);
//----
return(0);
}
//+------------------------------------------------------------------+
//| DPO |
//+------------------------------------------------------------------+
int start()
{
if (CountBars>=Bars) CountBars=Bars;
SetIndexDrawBegin(0,Bars-CountBars+x_prd+1);
int i,counted_bars=IndicatorCounted();
double t_prd;
//----
if(Bars<=x_prd) return(0);
//---- initial zero
if(counted_bars<x_prd)
{
for(i=1;i<=x_prd;i++) dpo[CountBars-i]=0.0;
}
//----
i=CountBars-x_prd-1;
t_prd=x_prd/2+1;

while(i>=0)
{
dpo[i]=Close[i]-iMA(NULL,0,7,MODE_SMA,0,PRICE_CLOSE,i);


i--;
}
return(0);
}
//+------------------------------------------------------------------+
Reply With Quote