Download MetaTrader 5

Customized a DPO

To add comments, please log in or register
zblteam
22
zblteam  
Hello,

i would like customized a DPO like the IG platform (if it's possible) for MT4 platform. Add color for volumes negative and positive (see screen).

IG

MT4

Can you help me please. code DPO default is :

//+------------------------------------------------------------------+
//|                                  Detrended Price Oscillator.mq4  |
//|                                       Ramdass - Conversion only  |
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
//----
extern int x_prd = 14;
extern int CountBars = 300;
//---- buffers
double dpo[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   SetIndexStyle(0, DRAW_LINE);
   SetIndexBuffer(0, dpo);
//---- name for DataWindow and indicator subwindow label
   short_name = "DPO(" + x_prd + ")";
   IndicatorShortName(short_name);
   SetIndexLabel(0, short_name);
//----
   if(CountBars >= Bars) 
   CountBars = Bars;
   SetIndexDrawBegin(0, Bars - CountBars + x_prd + 1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| DPO                                                              |
//+------------------------------------------------------------------+
int start()
  {
   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, x_prd, t_prd, MODE_SMA, PRICE_CLOSE, i);
       i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+-------------+

Thank you very much for your help

Zeb

Ernst Van Der Merwe
5030
Ernst Van Der Merwe  
.
Files:
DPO.ex4 14 kb
zblteam
22
zblteam  
Hello and thank you Pippod for your .ex4 :)

but the comportment is stange for the same time scale and same market price (DPO 20). the signals are not quite the same when i compare with the DPO of IG now.

how I can fix this. I can not modified the .ex4


Thank you very much for your help

Zeb
Ernst Van Der Merwe
5030
Ernst Van Der Merwe  
zblteam:
Hello and thank you Pippod for your .ex4 :)

but the comportment is stange for the same time scale and same market price (DPO 20). the signals are not quite the same when i compare with the DPO of IG now.

how I can fix this. I can not modified the .ex4


Thank you very much for your help

Zeb
It should be right now. Please try again.
zblteam
22
zblteam  
this is what I have. same time scale, screenshot at the same time
dpo default

dpo IG, same curve

Yours dpo. i do not understand the red bars

thank you

Zeb

Ernst Van Der Merwe
5030
Ernst Van Der Merwe  
.
Files:
DPO.ex4 14 kb
zblteam
22
zblteam  

Perfect !

Thank you very much pipPod, you are a chief  :)

Zeb

To add comments, please log in or register