Only way I know how is to add another indicator buffer
Maybe you figured it out already but here's what I did neway:
//+------------------------------------------------------------------+
//| DiNapoli Detrend Oscillator.mq4
//| Ramdass - Conversion only
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
extern int x_prd=14;
extern int CountBars=3000;
//---- buffers
double dpo[], dpo2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
//---- indicator line
IndicatorBuffers(2);
SetIndexBuffer(0,dpo);
SetIndexBuffer(1,dpo2);
//----
return(0);
}
//+------------------------------------------------------------------+
//| DPO |
//+------------------------------------------------------------------+
int start()
{
//Putting the SetIndexStyle here allows the setting to remain after each time you re-compile
//If you dont, the setting will only be applied if you reload the indicator (manually or from a saved template)
SetIndexStyle(0, DRAW_HISTOGRAM, STYLE_SOLID, 3, Lime);
SetIndexStyle(1, DRAW_HISTOGRAM, STYLE_SOLID, 3, Red);
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;
double val = 0;
while(i>=0)
{
val=Close[i]-iMA(NULL,0,7,MODE_SMA,0,PRICE_CLOSE,i);
if (val >= 0) {
dpo[i] = val;
dpo2[i] = 0;
} else if (val < 0) {
dpo2[i] = val;
dpo[i] = 0;
}
i--;
}
return(0);
}
//+------------------------------------------------------------------+
|